+ -
当前位置:首页 → 问答吧 → 如何是python窗口居中和判断Radiobutton是否选中

如何是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写个小插件,所以才有了上述两个问题,还请大家指点.

作者: dzhl01   发布时间: 2011-07-14

大家给个回复啊

作者: dzhl01   发布时间: 2011-07-15