【发布时间】:2014-06-29 22:57:09
【问题描述】:
我正在使用 wxpython 为一个软件创建前端,我遇到的问题是我无法让 evt_button 在我打开脚本时自动关闭窗口。它没有给出任何错误消息或警告。
class MyFrame(wx.Frame):
def __init__(self, parent, title):
wx.Frame.__init__(self, parent, -1, 'form title', wx.DefaultPosition, (560, 472), style=wx.CLOSE_BOX | wx.SYSTEM_MENU | wx.CAPTION | wx.RESIZE_BORDER | 0 | 0 | wx.MAXIMIZE_BOX | wx.MINIMIZE_BOX)
self.panel = wx.Panel(self, -1)
self.button1 = wx.Button(self.panel, -1, 'button', (8,72), (75, 23))
self.button1.SetFont(wx.Font(8.25, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL, 0, 'Microsoft Sans Serif'))
self.button1.SetCursor(wx.StockCursor(wx.CURSOR_DEFAULT))
self.Bind(wx.EVT_BUTTON,self.onclick,button1)
def onclick(self,event):
print "yay it works"
问题显然是绑定,但我没有看到或理解的是原因
【问题讨论】:
标签: python events button wxpython wxwidgets