Python-Uso diwx.PostEvent事件
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Python-Uso diwx.PostEvent事件相关的知识,希望对你有一定的参考价值。
import wx, thread, time def EVT_RESULT(win,func): win.Connect(-1,-1,111,func) class RESULT(wx.PyEvent): def __init__(self, data): wx.PyEvent.__init__(self) self.SetEventType(111) self.data = data class Main_Frame(wx.Frame): def __init__(self, parent=None, id=-1, title='Example PostEvent...'): self.ID_S = wx.NewId() self.ID_ST = wx.NewId() wx.Frame.__init__(self, parent, id, title) self.CenterOnScreen() self.Show() self._panel = wx.Panel(parent=self, id=-1) self._bu = wx.Button(parent=self._panel, id=self.ID_S, label='OK', size=(100, 100)) self.Bind(wx.EVT_BUTTON, self.OnStart, id=self.ID_S) self._bo = wx.Button(parent=self._panel, id=self.ID_ST, label='KO',pos=(0, 200), size=(100, 100)) self.Bind(wx.EVT_BUTTON, self.OnStop, id=self.ID_ST) EVT_RESULT(self, self.OnR) self.CreateStatusBar() def OnR(self, event): self.SetStatusText(str(event.data)) def OnStart(self, evt): thread.start_new_thread(self.avvia, (self,)) def OnStop(self, evt): print 'Cliccato....' def avvia(self, n): for i in range(10): time.sleep(1) wx.PostEvent(n, RESULT(i)) class Main_App(wx.App): def OnInit(self): self._main_frame = Main_Frame() self.SetTopWindow(self._main_frame) return True if __name__ == '__main__': main_app = Main_App() main_app.MainLoop()
以上是关于Python-Uso diwx.PostEvent事件的主要内容,如果未能解决你的问题,请参考以下文章