Revision: 1833
                            
                                                            
                                    
                                        
Updated Code
                                    
                                    
                                                    
                        at November 9, 2006 23:57 by whitetiger
                            
                            Updated Code
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()
                                
                            Revision: 1832
                            
                                                            
                                    
                                        
Initial Code
                                    
                                    
                                                            
                                    
                                        
Initial URL
                                    
                                    
                                
                                                            
                                    
                                        
Initial Description
                                    
                                    
                                
                                                            
                                    
                                        
Initial Title
                                    
                                    
                                                            
                                    
                                        
Initial Tags
                                    
                                    
                                                            
                                    
                                        
Initial Language
                                    
                                    
                                                    
                        at November 9, 2006 23:55 by whitetiger
                            
                            Initial Code
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()
                                Initial URL
Initial Description
Initial Title
Python - Uso di wx.PostEvent
Initial Tags
regex, python
Initial Language
Python