【发布时间】:2014-04-14 19:43:24
【问题描述】:
呃,该死的我的程序。我有更多问题:按钮的命令 (onExit()) 在导入时执行,但在单击按钮后不执行。
from Tkinter import *
import decoding
import encoding
import zxc
version="v0.0"
class widgets():
def NewLabel(self, text, column, row, container):
self.label=Label(container, text=text)
self.label.grid(column=column,row=row)
def NewEntry(self, container, text, column, row, action, key='<Return>', sticky="EW"):
self.entry=Entry(container, textvariable=StringVar())
self.entry.grid(column=column, row=row, sticky=sticky)
self.entry.bind(key, action)
StringVar().set(text)
def NewButton(self, text, action, column, row, container, sticky="N"):
self.button=Button(container, text=text, command=action)
self.button.grid(column=column,row=row,sticky=sticky)
class actions():
def OnEncode(self):
try:
zxc.encode()
quit()
except KeyboardInterrupt:
print "goodbye"
quit()
def OnDecode(self):
try:
decoding.decode(version)
except KeyboardInterrupt:
print "Goodbye"
quit()
def OnExit(self):
print __name__
if __name__=="zxc":
quit()
按钮包括:
widgets().NewButton(u'Exit',actions().OnExit(),0,4,self)
现在运行时,程序会打印出“定义”并弹出带有不可点击按钮的窗口
【问题讨论】:
标签: python button tkinter function