我一直在看文档,但对如何使用Tkinter设置变量感到困惑。你知道吗
我通常通过脚本设置变量,例如:
nb=5
path='/Users/ashleighclayton/Files
navg=24
sdthresh=25
absstepthresh=100
但是,我希望能够使用GUI设置这些值。 目前我已经构建了这个GUI,但是我正在努力实现它,尽管它看起来很简单。(还要注意,在大多数情况下,它们是整数而不是字符串)
class Application(Frame):
def exc(self):
execfile('currentmethod merlin.py',{'nb':nb,'path':path, 'navg':navg, 'sdthresh':sdthresh, 'absstepthresh':absstepthresh})
def exe(self):
execfile('new method merlin.py',{'nb':nb,'path':path, 'navg':navg, 'sdthresh':sdthresh, 'absstepthresh':absstepthresh} )
numblades=IntVar()
def createWidgets(self):
self.QUIT = Button(self)
self.QUIT["text"] = "QUIT"
self.QUIT["fg"] = "red"
self.QUIT["command"] = self.quit
self.QUIT.pack({"side": "left"})
self.CRTM = Button(self)
self.CRTM["text"] = "CRTM",
self.CRTM["command"] = self.exc
self.CRTM.pack({"side": "left"})
self.ERTM = Button(self)
self.ERTM["text"] = "ERTM",
self.ERTM["command"] = self.exe
self.ERTM.pack({"side": "left"})
# this is what I attempted, but I'm unsue how to set the input as the variable.
self.nb = Entry(self)
self.nb.pack(side = RIGHT)
def __init__(self, master=None):
Frame.__init__(self, master)
self.pack()
self.createWidgets()
root = Tk()
app = Application(master=root)
app.mainloop()
root.destroy()
对不起,我是Tkinter的新手,所以我们非常感谢您的帮助,甚至可以给我指一下相关的文档。你知道吗
首先为条目创建一个变量
然后将其与您的输入小部件链接
然后使用
我通常使用textvariable配置选项和Tkinter变量,但也可以使用insert。http://effbot.org/tkinterbook/entry.htm
相关问题 更多 >
编程相关推荐