如何是python窗口居中和判断Radiobutton是否选中
时间:2011-07-14
来源:互联网
1.如何控制窗体启动位置,使其居中
2.如何判断哪个Radiobutton被选中,我试过if var=="value1":和if var.get()=="vlaue1":结果都不行,这两个语句我也是猜的,网上没搜到相应代码。
代码如下:
from Tkinter import *
class App:
def __init__(self,master):
self.label=Label(root,text='焊脚值:',font=(10))
self.label.place(x=1,y=7)
self.weldtext=Entry(root,font=10)
self.weldtext["width"]=14
self.weldtext.place(x=62,y=8)
self.shun=Button(root,text="沿着标注方向",font=10,command=self.shun)
self.shun["width"]=21
self.shun.place(x=1,y=70)
self.ni1=Button(root,text="逆着标注方向",font=10,command=root.quit)
self.ni1["width"]=21
self.ni1.place(x=1,y=100)
self.double=Button(root,text="两个方向",font=10,command=self.double)
self.double["width"]=21
self.double.place(x=1,y=130)
def shun(self):
text=self.weldtext.get()
root.quit()
def ni1(self):
root.quit()
def double(self):
root.title(var)
root = Tk()
root.title('焊脚标注:')
root.maxsize(180,162)
root.minsize(180,162)
var = IntVar()
Radiobutton(root, text='正交方向',font=10, variable=var, value='value1').place(x=1,y=40)
Radiobutton(root, text='指定方向',font=10, variable=var, value='value2').place(x=88,y=40)
var.set('value1')
app=App(root)
root.mainloop()
这个代码只是个界面,别笑话,我没学过python,今天刚接触,但没办法,必须用python写个小插件,所以才有了上述两个问题,还请大家指点.
2.如何判断哪个Radiobutton被选中,我试过if var=="value1":和if var.get()=="vlaue1":结果都不行,这两个语句我也是猜的,网上没搜到相应代码。
代码如下:
from Tkinter import *
class App:
def __init__(self,master):
self.label=Label(root,text='焊脚值:',font=(10))
self.label.place(x=1,y=7)
self.weldtext=Entry(root,font=10)
self.weldtext["width"]=14
self.weldtext.place(x=62,y=8)
self.shun=Button(root,text="沿着标注方向",font=10,command=self.shun)
self.shun["width"]=21
self.shun.place(x=1,y=70)
self.ni1=Button(root,text="逆着标注方向",font=10,command=root.quit)
self.ni1["width"]=21
self.ni1.place(x=1,y=100)
self.double=Button(root,text="两个方向",font=10,command=self.double)
self.double["width"]=21
self.double.place(x=1,y=130)
def shun(self):
text=self.weldtext.get()
root.quit()
def ni1(self):
root.quit()
def double(self):
root.title(var)
root = Tk()
root.title('焊脚标注:')
root.maxsize(180,162)
root.minsize(180,162)
var = IntVar()
Radiobutton(root, text='正交方向',font=10, variable=var, value='value1').place(x=1,y=40)
Radiobutton(root, text='指定方向',font=10, variable=var, value='value2').place(x=88,y=40)
var.set('value1')
app=App(root)
root.mainloop()
这个代码只是个界面,别笑话,我没学过python,今天刚接触,但没办法,必须用python写个小插件,所以才有了上述两个问题,还请大家指点.
作者: dzhl01 发布时间: 2011-07-14
大家给个回复啊
作者: dzhl01 发布时间: 2011-07-15
相关阅读 更多
热门阅读
-
office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具
阅读:74
-
如何安装mysql8.0
阅读:31
-
Word快速设置标题样式步骤详解
阅读:28
-
20+道必知必会的Vue面试题(附答案解析)
阅读:37
-
HTML如何制作表单
阅读:22
-
百词斩可以改天数吗?当然可以,4个步骤轻松修改天数!
阅读:31
-
ET文件格式和XLS格式文件之间如何转化?
阅读:24
-
react和vue的区别及优缺点是什么
阅读:121
-
支付宝人脸识别如何关闭?
阅读:21
-
腾讯微云怎么修改照片或视频备份路径?
阅读:28