рдЬрдм рдЧреНрд░рд╛рдлрд┐рдХрд▓ рдЗрдВрдЯрд░рдлрд╝реЗрд╕ рдХрд╛ рдЙрдкрдпреЛрдЧ рдХрд░рдХреЗ рдкрд╛рдпрдерди рдореЗрдВ рдкреНрд░реЛрдЧреНрд░рд╛рдо рд▓рд┐рдЦрддреЗ рд╣реИрдВ, рддреЛ рдХрднреА-рдХрднреА рдЖрдкрдХреЛ рдХрд┐рд╕реА рднреА рдбреЗрдЯрд╛ рдХреЗ рд╡рд┐рднрд┐рдиреНрди рджреАрд░реНрдШрдХрд╛рд▓рд┐рдХ рдкреНрд░рд╕рдВрд╕реНрдХрд░рдг рд╢реБрд░реВ рдХрд░рдирд╛ рдкрдбрд╝рддрд╛ рд╣реИ, рдФрд░ рдЬреНрдпрд╛рджрд╛рддрд░ рдорд╛рдорд▓реЛрдВ рдореЗрдВ рдЗрдВрдЯрд░рдлрд╝реЗрд╕ рдЕрд╡рд░реБрджреНрдз рд╣реЛ рдЬрд╛рдПрдЧрд╛ рдФрд░ рдЙрдкрдпреЛрдЧрдХрд░реНрддрд╛ рдкреНрд░реЛрдЧреНрд░рд╛рдо рдХреЛ рдЬрдореЗ рд╣реБрдП рджреЗрдЦреЗрдВрдЧреЗред рдЗрд╕рд╕реЗ рдмрдЪрдиреЗ рдХреЗ рд▓рд┐рдП, рд╣рдорд╛рд░реЗ рдХрд╛рд░реНрдп рдХреЛ рд╕рдорд╛рдирд╛рдВрддрд░ рдзрд╛рдЧреЗ рдпрд╛ рдкреНрд░рдХреНрд░рд┐рдпрд╛ рдореЗрдВ рдЪрд▓рд╛рдирд╛ рдЖрд╡рд╢реНрдпрдХ рд╣реИред рдЗрд╕ рд▓реЗрдЦ рдореЗрдВ, рд╣рдо рдереНрд░реЗрдбрд┐рдВрдЧ рдореЙрдбреНрдпреВрд▓ рдХрд╛ рдЙрдкрдпреЛрдЧ рдХрд░рдХреЗ wxPython рдореЗрдВ рдРрд╕рд╛ рдХрд░рдиреЗ рдХреЗ рдмрд╛рд░реЗ рдореЗрдВ рджреЗрдЦреЗрдВрдЧреЗред
рдереНрд░реЗрдб рд╕реБрд░рдХреНрд╖рд┐рдд wxPython рд╡рд┐рдзрд┐рдпрд╛рдБ
WxPython рдореЗрдВ рдереНрд░реЗрдбреНрд╕ рдХреЗ рд╕рд╛рде рдХрд╛рдо рдХрд░рдиреЗ рдХреА рддреАрди рд╡рд┐рдзрд┐рдпрд╛рдБ рд╣реИрдВред рдпрджрд┐ рдЖрдк рдЙрдирдХрд╛ рдЙрдкрдпреЛрдЧ рдирд╣реАрдВ рдХрд░рддреЗ рд╣реИрдВ, рддреЛ рдЗрдВрдЯрд░рдлрд╝реЗрд╕ рдХреЛ рдЕрдкрдбреЗрдЯ рдХрд░рддреЗ рд╕рдордп, рдкрд╛рдпрдерди рдкреНрд░реЛрдЧреНрд░рд╛рдо рдлреНрд░реАрдЬ рд╣реЛ рд╕рдХрддреЗ рд╣реИрдВред рдЗрд╕рд╕реЗ рдмрдЪрдиреЗ рдХреЗ рд▓рд┐рдП, рдЖрдкрдХреЛ рдереНрд░реЗрдб рд╕реБрд░рдХреНрд╖рд┐рдд рд╡рд┐рдзрд┐рдпреЛрдВ рдХрд╛ рдЙрдкрдпреЛрдЧ рдХрд░рдирд╛ рдЪрд╛рд╣рд┐рдП: wx.PostEvent, wx.CallAfter, рдФрд░ wx.CallLaterред рд░реЙрдмрд┐рди рдбрди рдХреЗ рдЕрдиреБрд╕рд╛рд░ (wxPython рдХреЗ рдирд┐рд░реНрдорд╛рддрд╛) wx.CallAfter рдПрдХ рдЖрд╡реЗрджрди рд╡рд╕реНрддреБ рдХреЗ рд▓рд┐рдП рдПрдХ рдШрдЯрдирд╛ рднреЗрдЬрдиреЗ рдХреЗ рд▓рд┐рдП wx.PostEvent рдХрд╛ рдЙрдкрдпреЛрдЧ рдХрд░рддрд╛ рд╣реИред рдЗрд╕ рдШрдЯрдирд╛ рдХреЗ рд▓рд┐рдП рдПрдкреНрд▓рд┐рдХреЗрд╢рди рдореЗрдВ рдПрдХ рд╣реИрдВрдбрд▓рд░ рд╣реЛрдЧрд╛ рдФрд░ рдиреАрдЪреЗ рджрд┐рдП рдЧрдП рдПрд▓реНрдЧреЛрд░рд┐рджрдо рдХреЗ рдЕрдиреБрд╕рд╛рд░ рдЗрд╕рдХрд╛ рдЬрд╡рд╛рдм рджреЗрдЧрд╛ред рдЬрд╣рд╛рдВ рддрдХ тАЛтАЛрдореИрдВ рд╕рдордЭрддрд╛ рд╣реВрдВ, wx.CallLater wx.CallAfter рджрд┐рдП рдЧрдП рд╕рдордп рдкреИрд░рд╛рдореАрдЯрд░ рдХреЗ рд╕рд╛рде рдХреЙрд▓ рдХрд░рддрд╛ рд╣реИ, рддрд╛рдХрд┐ рдпрд╣ рдкрддрд╛ рдЪрд▓реЗ рдХрд┐ рдШрдЯрдирд╛ рдХреЛ рднреЗрдЬрдиреЗ рд╕реЗ рдкрд╣рд▓реЗ рдЗрд╕рдХреЗ рд▓рд┐рдП рдХрд┐рддрдирд╛ рдЗрдВрддрдЬрд╛рд░ рдХрд░рдирд╛ рд╣реИред
рд░реЙрдмрд┐рди рдбрди рдиреЗ рдпрд╣ рднреА рдиреЛрдЯ рдХрд┐рдпрд╛ рдХрд┐ рдЧреНрд▓реЛрдмрд▓ рдЗрдВрдЯрд░рдкреНрд░реЗрдЯрд░ рд▓реЙрдХ (GIL) рдПрдХ рд╕реЗ рдЕрдзрд┐рдХ рдереНрд░реЗрдб рдХреЛ рдПрдХ рд╕рд╛рде рдЪрд▓рд╛рдиреЗ рдХреА рдЕрдиреБрдорддрд┐ рдирд╣реАрдВ рджреЗрдЧрд╛, рдЬреЛ рдХрд┐ рдЗрд╕реНрддреЗрдорд╛рд▓ рдХрд┐рдП рдЬрд╛рдиреЗ рд╡рд╛рд▓реЗ рдкреНрд░реЛрд╕реЗрд╕рд░ рдХреЛрд░ рдХреА рд╕рдВрдЦреНрдпрд╛ рдХреЛ рд╕реАрдорд┐рдд рдХрд░ рд╕рдХрддрд╛ рд╣реИред рджреВрд╕рд░реА рдУрд░, рдЙрдиреНрд╣реЛрдВрдиреЗ рдпрд╣ рднреА рдХрд╣рд╛ рдХрд┐ wxPython рдХреЛ wx рд▓рд╛рдЗрдмреНрд░реЗрд░реА рдХреЗ API рдлрдВрдХреНрд╢рдВрд╕ рдХреЛ рд▓рд╛рдЧреВ рдХрд░рдиреЗ рд╕реЗ GIL рд╕реЗ рдореБрдХреНрдд рдХрд┐рдпрд╛ рдЬрд╛рддрд╛ рд╣реИ, рдЗрд╕рд▓рд┐рдП рдЕрдиреНрдп рдереНрд░реЗрдбреНрд╕ рдПрдХ рд╕рд╛рде рдХрд╛рдо рдХрд░ рд╕рдХрддреЗ рд╣реИрдВред рджреВрд╕рд░реЗ рд╢рдмреНрджреЛрдВ рдореЗрдВ, рдорд▓реНрдЯреАрдХреЛрд░ рдорд╢реАрдиреЛрдВ рдкрд░ рдереНрд░реЗрдбреНрд╕ рдХрд╛ рдЙрдкрдпреЛрдЧ рдХрд░рддреЗ рд╕рдордп рдкреНрд░рджрд░реНрд╢рди рдмрджрд▓ рд╕рдХрддрд╛ рд╣реИред рдЗрд╕ рдореБрджреНрджреЗ рдХреА рдЪрд░реНрдЪрд╛ рджрд┐рд▓рдЪрд╕реНрдк рд╣реЛ рд╕рдХрддреА рд╣реИ рдФрд░ рд╕реНрдкрд╖реНрдЯ рдирд╣реАрдВ ...
рд▓рдЧрднрдЧред рдЯреНрд░рд╛рдВрд╕ред - рдЬреАрдЖрдИрдПрд▓ рдХреЗ рд╕рд╛рде рдЕрдзрд┐рдХ рдкреВрд░реНрдг рдкрд░рд┐рдЪрд┐рдд рдХреЗ рд▓рд┐рдП, рдореИрдВ рдпрд╣рд╛рдВ рдкреВрдЫрддрд╛ рд╣реВрдВредрд╣рдорд╛рд░реЗ рддреАрди рддрд░реАрдХреЛрдВ рдХреЛ рдЕрдореВрд░реНрддрддрд╛ рдХреЗ рд╕реНрддрд░ рдореЗрдВ рд╡рд┐рднрд╛рдЬрд┐рдд рдХрд┐рдпрд╛ рдЬрд╛ рд╕рдХрддрд╛ рд╣реИ, wx.CallLater рд╕рдмрд╕реЗ рдКрдкрд░ рд╣реИ, рдЗрд╕рдХреЗ рдмрд╛рдж wx.CallAfter, рдФрд░ wx.PostEvent рд╕рдмрд╕реЗ рдирд┐рдЪрд▓реЗ рд╕реНрддрд░ рдкрд░ рд╣реИред рдирд┐рдореНрдирд▓рд┐рдЦрд┐рдд рдЙрджрд╛рд╣рд░рдгреЛрдВ рдореЗрдВ, рдЖрдк рджреЗрдЦреЗрдВрдЧреЗ рдХрд┐ рдХреИрд╕реЗ Wx.CallAfter рдФрд░ wx.PostEvent рдХрд╛ рдЙрдкрдпреЛрдЧ WxPytson рдХрд╛рд░реНрдпрдХреНрд░рдореЛрдВ рдореЗрдВ рдХрд░реЗрдВред
wxPython, рдереНрд░реЗрдбрд┐рдВрдЧ, wx.CallAfter рдФрд░ PubSub
WxPython рдореЗрд▓рд┐рдВрдЧ рд╕реВрдЪреА рдореЗрдВ, рдЖрдк рджреЗрдЦреЗрдВрдЧреЗ рдХрд┐ рд╡рд┐рд╢реЗрд╖рдЬреНрдЮ рдЕрдиреНрдп рдЙрдкрдпреЛрдЧрдХрд░реНрддрд╛рдУрдВ рдХреЛ рдПрдкреНрд▓рд┐рдХреЗрд╢рди рдФрд░ рдереНрд░реЗрдб рдХреЗ рдмреАрдЪ рд╕рдВрджреЗрд╢реЛрдВ рдХрд╛ рдЖрджрд╛рди-рдкреНрд░рджрд╛рди рдХрд░рдиреЗ рдХреЗ рд▓рд┐рдП
PubSub рдХреЗ рд╕рд╛рде wx.CallAfter рдХрд╛ рдЙрдкрдпреЛрдЧ рдХрд░рдиреЗ рдХреЗ рд▓рд┐рдП рдХрд╣реЗрдВрдЧреЗред рдирд┐рдореНрдирд▓рд┐рдЦрд┐рдд рдЙрджрд╛рд╣рд░рдг рдореЗрдВ, рд╣рдо рдЗрд╕реЗ рдкреНрд░рджрд░реНрд╢рд┐рдд рдХрд░реЗрдВрдЧреЗ:
Copy Source | Copy HTML import time import wx from threading import Thread from wx.lib.pubsub import Publisher ######################################################################## class TestThread (Thread): """Test Worker Thread Class.""" #---------------------------------------------------------------------- def __init__ (self): """Init Worker Thread Class.""" Thread. __init__ (self) self .start() # start the thread #---------------------------------------------------------------------- def run (self): """Run Worker Thread.""" # This is the code executing in the new thread. for i in range ( 6 ): time .sleep( 10 ) wx.CallAfter( self . postTime , i) time .sleep( 5 ) wx.CallAfter(Publisher().sendMessage, "update" , "Thread finished!" ) #---------------------------------------------------------------------- def postTime (self, amt): """ <br/> Send time to GUI <br/> """ amtOfTime = (amt + 1 ) * 10 Publisher().sendMessage( "update" , amtOfTime) ######################################################################## class MyForm (wx.Frame): #---------------------------------------------------------------------- def __init__ (self): wx.Frame. __init__ (self, None, wx.ID_ANY, "Tutorial" ) # Add a panel so it looks the correct on all platforms panel = wx.Panel(self, wx.ID_ANY) self .displayLbl = wx.StaticText(panel, label= "Amount of time since thread started goes here" ) self .btn = btn = wx.Button(panel, label= "Start Thread" ) btn.Bind(wx.EVT_BUTTON, self . onButton ) sizer = wx.BoxSizer(wx.VERTICAL) sizer.Add( self .displayLbl, 0 , wx.ALL|wx.CENTER, 5 ) sizer.Add(btn, 0 , wx.ALL|wx.CENTER, 5 ) panel.SetSizer(sizer) # create a pubsub receiver Publisher().subscribe( self . updateDisplay , "update" ) #---------------------------------------------------------------------- def onButton (self, event): """ <br/> Runs the thread <br/> """ TestThread () self .displayLbl.SetLabel( "Thread started!" ) btn = event.GetEventObject() btn.Disable() #---------------------------------------------------------------------- def updateDisplay (self, msg): """ <br/> Receives data from thread and updates the display <br/> """ t = msg.data if isinstance (t, int): self .displayLbl.SetLabel( "Time since thread started: %s seconds" % t) else : self .displayLbl.SetLabel( "%s" % t) self .btn.Enable() #---------------------------------------------------------------------- # Run the program if __name__ == "__main__" : app = wx.PySimpleApp() frame = MyForm ().Show() app.MainLoop()
Copy Source | Copy HTML import time import wx from threading import Thread from wx.lib.pubsub import Publisher ######################################################################## class TestThread (Thread): """Test Worker Thread Class.""" #---------------------------------------------------------------------- def __init__ (self): """Init Worker Thread Class.""" Thread. __init__ (self) self .start() # start the thread #---------------------------------------------------------------------- def run (self): """Run Worker Thread.""" # This is the code executing in the new thread. for i in range ( 6 ): time .sleep( 10 ) wx.CallAfter( self . postTime , i) time .sleep( 5 ) wx.CallAfter(Publisher().sendMessage, "update" , "Thread finished!" ) #---------------------------------------------------------------------- def postTime (self, amt): """ <br/> Send time to GUI <br/> """ amtOfTime = (amt + 1 ) * 10 Publisher().sendMessage( "update" , amtOfTime) ######################################################################## class MyForm (wx.Frame): #---------------------------------------------------------------------- def __init__ (self): wx.Frame. __init__ (self, None, wx.ID_ANY, "Tutorial" ) # Add a panel so it looks the correct on all platforms panel = wx.Panel(self, wx.ID_ANY) self .displayLbl = wx.StaticText(panel, label= "Amount of time since thread started goes here" ) self .btn = btn = wx.Button(panel, label= "Start Thread" ) btn.Bind(wx.EVT_BUTTON, self . onButton ) sizer = wx.BoxSizer(wx.VERTICAL) sizer.Add( self .displayLbl, 0 , wx.ALL|wx.CENTER, 5 ) sizer.Add(btn, 0 , wx.ALL|wx.CENTER, 5 ) panel.SetSizer(sizer) # create a pubsub receiver Publisher().subscribe( self . updateDisplay , "update" ) #---------------------------------------------------------------------- def onButton (self, event): """ <br/> Runs the thread <br/> """ TestThread () self .displayLbl.SetLabel( "Thread started!" ) btn = event.GetEventObject() btn.Disable() #---------------------------------------------------------------------- def updateDisplay (self, msg): """ <br/> Receives data from thread and updates the display <br/> """ t = msg.data if isinstance (t, int): self .displayLbl.SetLabel( "Time since thread started: %s seconds" % t) else : self .displayLbl.SetLabel( "%s" % t) self .btn.Enable() #---------------------------------------------------------------------- # Run the program if __name__ == "__main__" : app = wx.PySimpleApp() frame = MyForm ().Show() app.MainLoop()
Copy Source | Copy HTML import time import wx from threading import Thread from wx.lib.pubsub import Publisher ######################################################################## class TestThread (Thread): """Test Worker Thread Class.""" #---------------------------------------------------------------------- def __init__ (self): """Init Worker Thread Class.""" Thread. __init__ (self) self .start() # start the thread #---------------------------------------------------------------------- def run (self): """Run Worker Thread.""" # This is the code executing in the new thread. for i in range ( 6 ): time .sleep( 10 ) wx.CallAfter( self . postTime , i) time .sleep( 5 ) wx.CallAfter(Publisher().sendMessage, "update" , "Thread finished!" ) #---------------------------------------------------------------------- def postTime (self, amt): """ <br/> Send time to GUI <br/> """ amtOfTime = (amt + 1 ) * 10 Publisher().sendMessage( "update" , amtOfTime) ######################################################################## class MyForm (wx.Frame): #---------------------------------------------------------------------- def __init__ (self): wx.Frame. __init__ (self, None, wx.ID_ANY, "Tutorial" ) # Add a panel so it looks the correct on all platforms panel = wx.Panel(self, wx.ID_ANY) self .displayLbl = wx.StaticText(panel, label= "Amount of time since thread started goes here" ) self .btn = btn = wx.Button(panel, label= "Start Thread" ) btn.Bind(wx.EVT_BUTTON, self . onButton ) sizer = wx.BoxSizer(wx.VERTICAL) sizer.Add( self .displayLbl, 0 , wx.ALL|wx.CENTER, 5 ) sizer.Add(btn, 0 , wx.ALL|wx.CENTER, 5 ) panel.SetSizer(sizer) # create a pubsub receiver Publisher().subscribe( self . updateDisplay , "update" ) #---------------------------------------------------------------------- def onButton (self, event): """ <br/> Runs the thread <br/> """ TestThread () self .displayLbl.SetLabel( "Thread started!" ) btn = event.GetEventObject() btn.Disable() #---------------------------------------------------------------------- def updateDisplay (self, msg): """ <br/> Receives data from thread and updates the display <br/> """ t = msg.data if isinstance (t, int): self .displayLbl.SetLabel( "Time since thread started: %s seconds" % t) else : self .displayLbl.SetLabel( "%s" % t) self .btn.Enable() #---------------------------------------------------------------------- # Run the program if __name__ == "__main__" : app = wx.PySimpleApp() frame = MyForm ().Show() app.MainLoop()
Copy Source | Copy HTML import time import wx from threading import Thread from wx.lib.pubsub import Publisher ######################################################################## class TestThread (Thread): """Test Worker Thread Class.""" #---------------------------------------------------------------------- def __init__ (self): """Init Worker Thread Class.""" Thread. __init__ (self) self .start() # start the thread #---------------------------------------------------------------------- def run (self): """Run Worker Thread.""" # This is the code executing in the new thread. for i in range ( 6 ): time .sleep( 10 ) wx.CallAfter( self . postTime , i) time .sleep( 5 ) wx.CallAfter(Publisher().sendMessage, "update" , "Thread finished!" ) #---------------------------------------------------------------------- def postTime (self, amt): """ <br/> Send time to GUI <br/> """ amtOfTime = (amt + 1 ) * 10 Publisher().sendMessage( "update" , amtOfTime) ######################################################################## class MyForm (wx.Frame): #---------------------------------------------------------------------- def __init__ (self): wx.Frame. __init__ (self, None, wx.ID_ANY, "Tutorial" ) # Add a panel so it looks the correct on all platforms panel = wx.Panel(self, wx.ID_ANY) self .displayLbl = wx.StaticText(panel, label= "Amount of time since thread started goes here" ) self .btn = btn = wx.Button(panel, label= "Start Thread" ) btn.Bind(wx.EVT_BUTTON, self . onButton ) sizer = wx.BoxSizer(wx.VERTICAL) sizer.Add( self .displayLbl, 0 , wx.ALL|wx.CENTER, 5 ) sizer.Add(btn, 0 , wx.ALL|wx.CENTER, 5 ) panel.SetSizer(sizer) # create a pubsub receiver Publisher().subscribe( self . updateDisplay , "update" ) #---------------------------------------------------------------------- def onButton (self, event): """ <br/> Runs the thread <br/> """ TestThread () self .displayLbl.SetLabel( "Thread started!" ) btn = event.GetEventObject() btn.Disable() #---------------------------------------------------------------------- def updateDisplay (self, msg): """ <br/> Receives data from thread and updates the display <br/> """ t = msg.data if isinstance (t, int): self .displayLbl.SetLabel( "Time since thread started: %s seconds" % t) else : self .displayLbl.SetLabel( "%s" % t) self .btn.Enable() #---------------------------------------------------------------------- # Run the program if __name__ == "__main__" : app = wx.PySimpleApp() frame = MyForm ().Show() app.MainLoop()
Copy Source | Copy HTML import time import wx from threading import Thread from wx.lib.pubsub import Publisher ######################################################################## class TestThread (Thread): """Test Worker Thread Class.""" #---------------------------------------------------------------------- def __init__ (self): """Init Worker Thread Class.""" Thread. __init__ (self) self .start() # start the thread #---------------------------------------------------------------------- def run (self): """Run Worker Thread.""" # This is the code executing in the new thread. for i in range ( 6 ): time .sleep( 10 ) wx.CallAfter( self . postTime , i) time .sleep( 5 ) wx.CallAfter(Publisher().sendMessage, "update" , "Thread finished!" ) #---------------------------------------------------------------------- def postTime (self, amt): """ <br/> Send time to GUI <br/> """ amtOfTime = (amt + 1 ) * 10 Publisher().sendMessage( "update" , amtOfTime) ######################################################################## class MyForm (wx.Frame): #---------------------------------------------------------------------- def __init__ (self): wx.Frame. __init__ (self, None, wx.ID_ANY, "Tutorial" ) # Add a panel so it looks the correct on all platforms panel = wx.Panel(self, wx.ID_ANY) self .displayLbl = wx.StaticText(panel, label= "Amount of time since thread started goes here" ) self .btn = btn = wx.Button(panel, label= "Start Thread" ) btn.Bind(wx.EVT_BUTTON, self . onButton ) sizer = wx.BoxSizer(wx.VERTICAL) sizer.Add( self .displayLbl, 0 , wx.ALL|wx.CENTER, 5 ) sizer.Add(btn, 0 , wx.ALL|wx.CENTER, 5 ) panel.SetSizer(sizer) # create a pubsub receiver Publisher().subscribe( self . updateDisplay , "update" ) #---------------------------------------------------------------------- def onButton (self, event): """ <br/> Runs the thread <br/> """ TestThread () self .displayLbl.SetLabel( "Thread started!" ) btn = event.GetEventObject() btn.Disable() #---------------------------------------------------------------------- def updateDisplay (self, msg): """ <br/> Receives data from thread and updates the display <br/> """ t = msg.data if isinstance (t, int): self .displayLbl.SetLabel( "Time since thread started: %s seconds" % t) else : self .displayLbl.SetLabel( "%s" % t) self .btn.Enable() #---------------------------------------------------------------------- # Run the program if __name__ == "__main__" : app = wx.PySimpleApp() frame = MyForm ().Show() app.MainLoop()
Copy Source | Copy HTML import time import wx from threading import Thread from wx.lib.pubsub import Publisher ######################################################################## class TestThread (Thread): """Test Worker Thread Class.""" #---------------------------------------------------------------------- def __init__ (self): """Init Worker Thread Class.""" Thread. __init__ (self) self .start() # start the thread #---------------------------------------------------------------------- def run (self): """Run Worker Thread.""" # This is the code executing in the new thread. for i in range ( 6 ): time .sleep( 10 ) wx.CallAfter( self . postTime , i) time .sleep( 5 ) wx.CallAfter(Publisher().sendMessage, "update" , "Thread finished!" ) #---------------------------------------------------------------------- def postTime (self, amt): """ <br/> Send time to GUI <br/> """ amtOfTime = (amt + 1 ) * 10 Publisher().sendMessage( "update" , amtOfTime) ######################################################################## class MyForm (wx.Frame): #---------------------------------------------------------------------- def __init__ (self): wx.Frame. __init__ (self, None, wx.ID_ANY, "Tutorial" ) # Add a panel so it looks the correct on all platforms panel = wx.Panel(self, wx.ID_ANY) self .displayLbl = wx.StaticText(panel, label= "Amount of time since thread started goes here" ) self .btn = btn = wx.Button(panel, label= "Start Thread" ) btn.Bind(wx.EVT_BUTTON, self . onButton ) sizer = wx.BoxSizer(wx.VERTICAL) sizer.Add( self .displayLbl, 0 , wx.ALL|wx.CENTER, 5 ) sizer.Add(btn, 0 , wx.ALL|wx.CENTER, 5 ) panel.SetSizer(sizer) # create a pubsub receiver Publisher().subscribe( self . updateDisplay , "update" ) #---------------------------------------------------------------------- def onButton (self, event): """ <br/> Runs the thread <br/> """ TestThread () self .displayLbl.SetLabel( "Thread started!" ) btn = event.GetEventObject() btn.Disable() #---------------------------------------------------------------------- def updateDisplay (self, msg): """ <br/> Receives data from thread and updates the display <br/> """ t = msg.data if isinstance (t, int): self .displayLbl.SetLabel( "Time since thread started: %s seconds" % t) else : self .displayLbl.SetLabel( "%s" % t) self .btn.Enable() #---------------------------------------------------------------------- # Run the program if __name__ == "__main__" : app = wx.PySimpleApp() frame = MyForm ().Show() app.MainLoop()
Copy Source | Copy HTML import time import wx from threading import Thread from wx.lib.pubsub import Publisher ######################################################################## class TestThread (Thread): """Test Worker Thread Class.""" #---------------------------------------------------------------------- def __init__ (self): """Init Worker Thread Class.""" Thread. __init__ (self) self .start() # start the thread #---------------------------------------------------------------------- def run (self): """Run Worker Thread.""" # This is the code executing in the new thread. for i in range ( 6 ): time .sleep( 10 ) wx.CallAfter( self . postTime , i) time .sleep( 5 ) wx.CallAfter(Publisher().sendMessage, "update" , "Thread finished!" ) #---------------------------------------------------------------------- def postTime (self, amt): """ <br/> Send time to GUI <br/> """ amtOfTime = (amt + 1 ) * 10 Publisher().sendMessage( "update" , amtOfTime) ######################################################################## class MyForm (wx.Frame): #---------------------------------------------------------------------- def __init__ (self): wx.Frame. __init__ (self, None, wx.ID_ANY, "Tutorial" ) # Add a panel so it looks the correct on all platforms panel = wx.Panel(self, wx.ID_ANY) self .displayLbl = wx.StaticText(panel, label= "Amount of time since thread started goes here" ) self .btn = btn = wx.Button(panel, label= "Start Thread" ) btn.Bind(wx.EVT_BUTTON, self . onButton ) sizer = wx.BoxSizer(wx.VERTICAL) sizer.Add( self .displayLbl, 0 , wx.ALL|wx.CENTER, 5 ) sizer.Add(btn, 0 , wx.ALL|wx.CENTER, 5 ) panel.SetSizer(sizer) # create a pubsub receiver Publisher().subscribe( self . updateDisplay , "update" ) #---------------------------------------------------------------------- def onButton (self, event): """ <br/> Runs the thread <br/> """ TestThread () self .displayLbl.SetLabel( "Thread started!" ) btn = event.GetEventObject() btn.Disable() #---------------------------------------------------------------------- def updateDisplay (self, msg): """ <br/> Receives data from thread and updates the display <br/> """ t = msg.data if isinstance (t, int): self .displayLbl.SetLabel( "Time since thread started: %s seconds" % t) else : self .displayLbl.SetLabel( "%s" % t) self .btn.Enable() #---------------------------------------------------------------------- # Run the program if __name__ == "__main__" : app = wx.PySimpleApp() frame = MyForm ().Show() app.MainLoop()
Copy Source | Copy HTML import time import wx from threading import Thread from wx.lib.pubsub import Publisher ######################################################################## class TestThread (Thread): """Test Worker Thread Class.""" #---------------------------------------------------------------------- def __init__ (self): """Init Worker Thread Class.""" Thread. __init__ (self) self .start() # start the thread #---------------------------------------------------------------------- def run (self): """Run Worker Thread.""" # This is the code executing in the new thread. for i in range ( 6 ): time .sleep( 10 ) wx.CallAfter( self . postTime , i) time .sleep( 5 ) wx.CallAfter(Publisher().sendMessage, "update" , "Thread finished!" ) #---------------------------------------------------------------------- def postTime (self, amt): """ <br/> Send time to GUI <br/> """ amtOfTime = (amt + 1 ) * 10 Publisher().sendMessage( "update" , amtOfTime) ######################################################################## class MyForm (wx.Frame): #---------------------------------------------------------------------- def __init__ (self): wx.Frame. __init__ (self, None, wx.ID_ANY, "Tutorial" ) # Add a panel so it looks the correct on all platforms panel = wx.Panel(self, wx.ID_ANY) self .displayLbl = wx.StaticText(panel, label= "Amount of time since thread started goes here" ) self .btn = btn = wx.Button(panel, label= "Start Thread" ) btn.Bind(wx.EVT_BUTTON, self . onButton ) sizer = wx.BoxSizer(wx.VERTICAL) sizer.Add( self .displayLbl, 0 , wx.ALL|wx.CENTER, 5 ) sizer.Add(btn, 0 , wx.ALL|wx.CENTER, 5 ) panel.SetSizer(sizer) # create a pubsub receiver Publisher().subscribe( self . updateDisplay , "update" ) #---------------------------------------------------------------------- def onButton (self, event): """ <br/> Runs the thread <br/> """ TestThread () self .displayLbl.SetLabel( "Thread started!" ) btn = event.GetEventObject() btn.Disable() #---------------------------------------------------------------------- def updateDisplay (self, msg): """ <br/> Receives data from thread and updates the display <br/> """ t = msg.data if isinstance (t, int): self .displayLbl.SetLabel( "Time since thread started: %s seconds" % t) else : self .displayLbl.SetLabel( "%s" % t) self .btn.Enable() #---------------------------------------------------------------------- # Run the program if __name__ == "__main__" : app = wx.PySimpleApp() frame = MyForm ().Show() app.MainLoop()
Copy Source | Copy HTML import time import wx from threading import Thread from wx.lib.pubsub import Publisher ######################################################################## class TestThread (Thread): """Test Worker Thread Class.""" #---------------------------------------------------------------------- def __init__ (self): """Init Worker Thread Class.""" Thread. __init__ (self) self .start() # start the thread #---------------------------------------------------------------------- def run (self): """Run Worker Thread.""" # This is the code executing in the new thread. for i in range ( 6 ): time .sleep( 10 ) wx.CallAfter( self . postTime , i) time .sleep( 5 ) wx.CallAfter(Publisher().sendMessage, "update" , "Thread finished!" ) #---------------------------------------------------------------------- def postTime (self, amt): """ <br/> Send time to GUI <br/> """ amtOfTime = (amt + 1 ) * 10 Publisher().sendMessage( "update" , amtOfTime) ######################################################################## class MyForm (wx.Frame): #---------------------------------------------------------------------- def __init__ (self): wx.Frame. __init__ (self, None, wx.ID_ANY, "Tutorial" ) # Add a panel so it looks the correct on all platforms panel = wx.Panel(self, wx.ID_ANY) self .displayLbl = wx.StaticText(panel, label= "Amount of time since thread started goes here" ) self .btn = btn = wx.Button(panel, label= "Start Thread" ) btn.Bind(wx.EVT_BUTTON, self . onButton ) sizer = wx.BoxSizer(wx.VERTICAL) sizer.Add( self .displayLbl, 0 , wx.ALL|wx.CENTER, 5 ) sizer.Add(btn, 0 , wx.ALL|wx.CENTER, 5 ) panel.SetSizer(sizer) # create a pubsub receiver Publisher().subscribe( self . updateDisplay , "update" ) #---------------------------------------------------------------------- def onButton (self, event): """ <br/> Runs the thread <br/> """ TestThread () self .displayLbl.SetLabel( "Thread started!" ) btn = event.GetEventObject() btn.Disable() #---------------------------------------------------------------------- def updateDisplay (self, msg): """ <br/> Receives data from thread and updates the display <br/> """ t = msg.data if isinstance (t, int): self .displayLbl.SetLabel( "Time since thread started: %s seconds" % t) else : self .displayLbl.SetLabel( "%s" % t) self .btn.Enable() #---------------------------------------------------------------------- # Run the program if __name__ == "__main__" : app = wx.PySimpleApp() frame = MyForm ().Show() app.MainLoop()
Copy Source | Copy HTML import time import wx from threading import Thread from wx.lib.pubsub import Publisher ######################################################################## class TestThread (Thread): """Test Worker Thread Class.""" #---------------------------------------------------------------------- def __init__ (self): """Init Worker Thread Class.""" Thread. __init__ (self) self .start() # start the thread #---------------------------------------------------------------------- def run (self): """Run Worker Thread.""" # This is the code executing in the new thread. for i in range ( 6 ): time .sleep( 10 ) wx.CallAfter( self . postTime , i) time .sleep( 5 ) wx.CallAfter(Publisher().sendMessage, "update" , "Thread finished!" ) #---------------------------------------------------------------------- def postTime (self, amt): """ <br/> Send time to GUI <br/> """ amtOfTime = (amt + 1 ) * 10 Publisher().sendMessage( "update" , amtOfTime) ######################################################################## class MyForm (wx.Frame): #---------------------------------------------------------------------- def __init__ (self): wx.Frame. __init__ (self, None, wx.ID_ANY, "Tutorial" ) # Add a panel so it looks the correct on all platforms panel = wx.Panel(self, wx.ID_ANY) self .displayLbl = wx.StaticText(panel, label= "Amount of time since thread started goes here" ) self .btn = btn = wx.Button(panel, label= "Start Thread" ) btn.Bind(wx.EVT_BUTTON, self . onButton ) sizer = wx.BoxSizer(wx.VERTICAL) sizer.Add( self .displayLbl, 0 , wx.ALL|wx.CENTER, 5 ) sizer.Add(btn, 0 , wx.ALL|wx.CENTER, 5 ) panel.SetSizer(sizer) # create a pubsub receiver Publisher().subscribe( self . updateDisplay , "update" ) #---------------------------------------------------------------------- def onButton (self, event): """ <br/> Runs the thread <br/> """ TestThread () self .displayLbl.SetLabel( "Thread started!" ) btn = event.GetEventObject() btn.Disable() #---------------------------------------------------------------------- def updateDisplay (self, msg): """ <br/> Receives data from thread and updates the display <br/> """ t = msg.data if isinstance (t, int): self .displayLbl.SetLabel( "Time since thread started: %s seconds" % t) else : self .displayLbl.SetLabel( "%s" % t) self .btn.Enable() #---------------------------------------------------------------------- # Run the program if __name__ == "__main__" : app = wx.PySimpleApp() frame = MyForm ().Show() app.MainLoop()
Copy Source | Copy HTML import time import wx from threading import Thread from wx.lib.pubsub import Publisher ######################################################################## class TestThread (Thread): """Test Worker Thread Class.""" #---------------------------------------------------------------------- def __init__ (self): """Init Worker Thread Class.""" Thread. __init__ (self) self .start() # start the thread #---------------------------------------------------------------------- def run (self): """Run Worker Thread.""" # This is the code executing in the new thread. for i in range ( 6 ): time .sleep( 10 ) wx.CallAfter( self . postTime , i) time .sleep( 5 ) wx.CallAfter(Publisher().sendMessage, "update" , "Thread finished!" ) #---------------------------------------------------------------------- def postTime (self, amt): """ <br/> Send time to GUI <br/> """ amtOfTime = (amt + 1 ) * 10 Publisher().sendMessage( "update" , amtOfTime) ######################################################################## class MyForm (wx.Frame): #---------------------------------------------------------------------- def __init__ (self): wx.Frame. __init__ (self, None, wx.ID_ANY, "Tutorial" ) # Add a panel so it looks the correct on all platforms panel = wx.Panel(self, wx.ID_ANY) self .displayLbl = wx.StaticText(panel, label= "Amount of time since thread started goes here" ) self .btn = btn = wx.Button(panel, label= "Start Thread" ) btn.Bind(wx.EVT_BUTTON, self . onButton ) sizer = wx.BoxSizer(wx.VERTICAL) sizer.Add( self .displayLbl, 0 , wx.ALL|wx.CENTER, 5 ) sizer.Add(btn, 0 , wx.ALL|wx.CENTER, 5 ) panel.SetSizer(sizer) # create a pubsub receiver Publisher().subscribe( self . updateDisplay , "update" ) #---------------------------------------------------------------------- def onButton (self, event): """ <br/> Runs the thread <br/> """ TestThread () self .displayLbl.SetLabel( "Thread started!" ) btn = event.GetEventObject() btn.Disable() #---------------------------------------------------------------------- def updateDisplay (self, msg): """ <br/> Receives data from thread and updates the display <br/> """ t = msg.data if isinstance (t, int): self .displayLbl.SetLabel( "Time since thread started: %s seconds" % t) else : self .displayLbl.SetLabel( "%s" % t) self .btn.Enable() #---------------------------------------------------------------------- # Run the program if __name__ == "__main__" : app = wx.PySimpleApp() frame = MyForm ().Show() app.MainLoop()
Copy Source | Copy HTML import time import wx from threading import Thread from wx.lib.pubsub import Publisher ######################################################################## class TestThread (Thread): """Test Worker Thread Class.""" #---------------------------------------------------------------------- def __init__ (self): """Init Worker Thread Class.""" Thread. __init__ (self) self .start() # start the thread #---------------------------------------------------------------------- def run (self): """Run Worker Thread.""" # This is the code executing in the new thread. for i in range ( 6 ): time .sleep( 10 ) wx.CallAfter( self . postTime , i) time .sleep( 5 ) wx.CallAfter(Publisher().sendMessage, "update" , "Thread finished!" ) #---------------------------------------------------------------------- def postTime (self, amt): """ <br/> Send time to GUI <br/> """ amtOfTime = (amt + 1 ) * 10 Publisher().sendMessage( "update" , amtOfTime) ######################################################################## class MyForm (wx.Frame): #---------------------------------------------------------------------- def __init__ (self): wx.Frame. __init__ (self, None, wx.ID_ANY, "Tutorial" ) # Add a panel so it looks the correct on all platforms panel = wx.Panel(self, wx.ID_ANY) self .displayLbl = wx.StaticText(panel, label= "Amount of time since thread started goes here" ) self .btn = btn = wx.Button(panel, label= "Start Thread" ) btn.Bind(wx.EVT_BUTTON, self . onButton ) sizer = wx.BoxSizer(wx.VERTICAL) sizer.Add( self .displayLbl, 0 , wx.ALL|wx.CENTER, 5 ) sizer.Add(btn, 0 , wx.ALL|wx.CENTER, 5 ) panel.SetSizer(sizer) # create a pubsub receiver Publisher().subscribe( self . updateDisplay , "update" ) #---------------------------------------------------------------------- def onButton (self, event): """ <br/> Runs the thread <br/> """ TestThread () self .displayLbl.SetLabel( "Thread started!" ) btn = event.GetEventObject() btn.Disable() #---------------------------------------------------------------------- def updateDisplay (self, msg): """ <br/> Receives data from thread and updates the display <br/> """ t = msg.data if isinstance (t, int): self .displayLbl.SetLabel( "Time since thread started: %s seconds" % t) else : self .displayLbl.SetLabel( "%s" % t) self .btn.Enable() #---------------------------------------------------------------------- # Run the program if __name__ == "__main__" : app = wx.PySimpleApp() frame = MyForm ().Show() app.MainLoop()
Copy Source | Copy HTML import time import wx from threading import Thread from wx.lib.pubsub import Publisher ######################################################################## class TestThread (Thread): """Test Worker Thread Class.""" #---------------------------------------------------------------------- def __init__ (self): """Init Worker Thread Class.""" Thread. __init__ (self) self .start() # start the thread #---------------------------------------------------------------------- def run (self): """Run Worker Thread.""" # This is the code executing in the new thread. for i in range ( 6 ): time .sleep( 10 ) wx.CallAfter( self . postTime , i) time .sleep( 5 ) wx.CallAfter(Publisher().sendMessage, "update" , "Thread finished!" ) #---------------------------------------------------------------------- def postTime (self, amt): """ <br/> Send time to GUI <br/> """ amtOfTime = (amt + 1 ) * 10 Publisher().sendMessage( "update" , amtOfTime) ######################################################################## class MyForm (wx.Frame): #---------------------------------------------------------------------- def __init__ (self): wx.Frame. __init__ (self, None, wx.ID_ANY, "Tutorial" ) # Add a panel so it looks the correct on all platforms panel = wx.Panel(self, wx.ID_ANY) self .displayLbl = wx.StaticText(panel, label= "Amount of time since thread started goes here" ) self .btn = btn = wx.Button(panel, label= "Start Thread" ) btn.Bind(wx.EVT_BUTTON, self . onButton ) sizer = wx.BoxSizer(wx.VERTICAL) sizer.Add( self .displayLbl, 0 , wx.ALL|wx.CENTER, 5 ) sizer.Add(btn, 0 , wx.ALL|wx.CENTER, 5 ) panel.SetSizer(sizer) # create a pubsub receiver Publisher().subscribe( self . updateDisplay , "update" ) #---------------------------------------------------------------------- def onButton (self, event): """ <br/> Runs the thread <br/> """ TestThread () self .displayLbl.SetLabel( "Thread started!" ) btn = event.GetEventObject() btn.Disable() #---------------------------------------------------------------------- def updateDisplay (self, msg): """ <br/> Receives data from thread and updates the display <br/> """ t = msg.data if isinstance (t, int): self .displayLbl.SetLabel( "Time since thread started: %s seconds" % t) else : self .displayLbl.SetLabel( "%s" % t) self .btn.Enable() #---------------------------------------------------------------------- # Run the program if __name__ == "__main__" : app = wx.PySimpleApp() frame = MyForm ().Show() app.MainLoop()
Copy Source | Copy HTML import time import wx from threading import Thread from wx.lib.pubsub import Publisher ######################################################################## class TestThread (Thread): """Test Worker Thread Class.""" #---------------------------------------------------------------------- def __init__ (self): """Init Worker Thread Class.""" Thread. __init__ (self) self .start() # start the thread #---------------------------------------------------------------------- def run (self): """Run Worker Thread.""" # This is the code executing in the new thread. for i in range ( 6 ): time .sleep( 10 ) wx.CallAfter( self . postTime , i) time .sleep( 5 ) wx.CallAfter(Publisher().sendMessage, "update" , "Thread finished!" ) #---------------------------------------------------------------------- def postTime (self, amt): """ <br/> Send time to GUI <br/> """ amtOfTime = (amt + 1 ) * 10 Publisher().sendMessage( "update" , amtOfTime) ######################################################################## class MyForm (wx.Frame): #---------------------------------------------------------------------- def __init__ (self): wx.Frame. __init__ (self, None, wx.ID_ANY, "Tutorial" ) # Add a panel so it looks the correct on all platforms panel = wx.Panel(self, wx.ID_ANY) self .displayLbl = wx.StaticText(panel, label= "Amount of time since thread started goes here" ) self .btn = btn = wx.Button(panel, label= "Start Thread" ) btn.Bind(wx.EVT_BUTTON, self . onButton ) sizer = wx.BoxSizer(wx.VERTICAL) sizer.Add( self .displayLbl, 0 , wx.ALL|wx.CENTER, 5 ) sizer.Add(btn, 0 , wx.ALL|wx.CENTER, 5 ) panel.SetSizer(sizer) # create a pubsub receiver Publisher().subscribe( self . updateDisplay , "update" ) #---------------------------------------------------------------------- def onButton (self, event): """ <br/> Runs the thread <br/> """ TestThread () self .displayLbl.SetLabel( "Thread started!" ) btn = event.GetEventObject() btn.Disable() #---------------------------------------------------------------------- def updateDisplay (self, msg): """ <br/> Receives data from thread and updates the display <br/> """ t = msg.data if isinstance (t, int): self .displayLbl.SetLabel( "Time since thread started: %s seconds" % t) else : self .displayLbl.SetLabel( "%s" % t) self .btn.Enable() #---------------------------------------------------------------------- # Run the program if __name__ == "__main__" : app = wx.PySimpleApp() frame = MyForm ().Show() app.MainLoop()
Copy Source | Copy HTML import time import wx from threading import Thread from wx.lib.pubsub import Publisher ######################################################################## class TestThread (Thread): """Test Worker Thread Class.""" #---------------------------------------------------------------------- def __init__ (self): """Init Worker Thread Class.""" Thread. __init__ (self) self .start() # start the thread #---------------------------------------------------------------------- def run (self): """Run Worker Thread.""" # This is the code executing in the new thread. for i in range ( 6 ): time .sleep( 10 ) wx.CallAfter( self . postTime , i) time .sleep( 5 ) wx.CallAfter(Publisher().sendMessage, "update" , "Thread finished!" ) #---------------------------------------------------------------------- def postTime (self, amt): """ <br/> Send time to GUI <br/> """ amtOfTime = (amt + 1 ) * 10 Publisher().sendMessage( "update" , amtOfTime) ######################################################################## class MyForm (wx.Frame): #---------------------------------------------------------------------- def __init__ (self): wx.Frame. __init__ (self, None, wx.ID_ANY, "Tutorial" ) # Add a panel so it looks the correct on all platforms panel = wx.Panel(self, wx.ID_ANY) self .displayLbl = wx.StaticText(panel, label= "Amount of time since thread started goes here" ) self .btn = btn = wx.Button(panel, label= "Start Thread" ) btn.Bind(wx.EVT_BUTTON, self . onButton ) sizer = wx.BoxSizer(wx.VERTICAL) sizer.Add( self .displayLbl, 0 , wx.ALL|wx.CENTER, 5 ) sizer.Add(btn, 0 , wx.ALL|wx.CENTER, 5 ) panel.SetSizer(sizer) # create a pubsub receiver Publisher().subscribe( self . updateDisplay , "update" ) #---------------------------------------------------------------------- def onButton (self, event): """ <br/> Runs the thread <br/> """ TestThread () self .displayLbl.SetLabel( "Thread started!" ) btn = event.GetEventObject() btn.Disable() #---------------------------------------------------------------------- def updateDisplay (self, msg): """ <br/> Receives data from thread and updates the display <br/> """ t = msg.data if isinstance (t, int): self .displayLbl.SetLabel( "Time since thread started: %s seconds" % t) else : self .displayLbl.SetLabel( "%s" % t) self .btn.Enable() #---------------------------------------------------------------------- # Run the program if __name__ == "__main__" : app = wx.PySimpleApp() frame = MyForm ().Show() app.MainLoop()
Copy Source | Copy HTML import time import wx from threading import Thread from wx.lib.pubsub import Publisher ######################################################################## class TestThread (Thread): """Test Worker Thread Class.""" #---------------------------------------------------------------------- def __init__ (self): """Init Worker Thread Class.""" Thread. __init__ (self) self .start() # start the thread #---------------------------------------------------------------------- def run (self): """Run Worker Thread.""" # This is the code executing in the new thread. for i in range ( 6 ): time .sleep( 10 ) wx.CallAfter( self . postTime , i) time .sleep( 5 ) wx.CallAfter(Publisher().sendMessage, "update" , "Thread finished!" ) #---------------------------------------------------------------------- def postTime (self, amt): """ <br/> Send time to GUI <br/> """ amtOfTime = (amt + 1 ) * 10 Publisher().sendMessage( "update" , amtOfTime) ######################################################################## class MyForm (wx.Frame): #---------------------------------------------------------------------- def __init__ (self): wx.Frame. __init__ (self, None, wx.ID_ANY, "Tutorial" ) # Add a panel so it looks the correct on all platforms panel = wx.Panel(self, wx.ID_ANY) self .displayLbl = wx.StaticText(panel, label= "Amount of time since thread started goes here" ) self .btn = btn = wx.Button(panel, label= "Start Thread" ) btn.Bind(wx.EVT_BUTTON, self . onButton ) sizer = wx.BoxSizer(wx.VERTICAL) sizer.Add( self .displayLbl, 0 , wx.ALL|wx.CENTER, 5 ) sizer.Add(btn, 0 , wx.ALL|wx.CENTER, 5 ) panel.SetSizer(sizer) # create a pubsub receiver Publisher().subscribe( self . updateDisplay , "update" ) #---------------------------------------------------------------------- def onButton (self, event): """ <br/> Runs the thread <br/> """ TestThread () self .displayLbl.SetLabel( "Thread started!" ) btn = event.GetEventObject() btn.Disable() #---------------------------------------------------------------------- def updateDisplay (self, msg): """ <br/> Receives data from thread and updates the display <br/> """ t = msg.data if isinstance (t, int): self .displayLbl.SetLabel( "Time since thread started: %s seconds" % t) else : self .displayLbl.SetLabel( "%s" % t) self .btn.Enable() #---------------------------------------------------------------------- # Run the program if __name__ == "__main__" : app = wx.PySimpleApp() frame = MyForm ().Show() app.MainLoop()
Copy Source | Copy HTML import time import wx from threading import Thread from wx.lib.pubsub import Publisher ######################################################################## class TestThread (Thread): """Test Worker Thread Class.""" #---------------------------------------------------------------------- def __init__ (self): """Init Worker Thread Class.""" Thread. __init__ (self) self .start() # start the thread #---------------------------------------------------------------------- def run (self): """Run Worker Thread.""" # This is the code executing in the new thread. for i in range ( 6 ): time .sleep( 10 ) wx.CallAfter( self . postTime , i) time .sleep( 5 ) wx.CallAfter(Publisher().sendMessage, "update" , "Thread finished!" ) #---------------------------------------------------------------------- def postTime (self, amt): """ <br/> Send time to GUI <br/> """ amtOfTime = (amt + 1 ) * 10 Publisher().sendMessage( "update" , amtOfTime) ######################################################################## class MyForm (wx.Frame): #---------------------------------------------------------------------- def __init__ (self): wx.Frame. __init__ (self, None, wx.ID_ANY, "Tutorial" ) # Add a panel so it looks the correct on all platforms panel = wx.Panel(self, wx.ID_ANY) self .displayLbl = wx.StaticText(panel, label= "Amount of time since thread started goes here" ) self .btn = btn = wx.Button(panel, label= "Start Thread" ) btn.Bind(wx.EVT_BUTTON, self . onButton ) sizer = wx.BoxSizer(wx.VERTICAL) sizer.Add( self .displayLbl, 0 , wx.ALL|wx.CENTER, 5 ) sizer.Add(btn, 0 , wx.ALL|wx.CENTER, 5 ) panel.SetSizer(sizer) # create a pubsub receiver Publisher().subscribe( self . updateDisplay , "update" ) #---------------------------------------------------------------------- def onButton (self, event): """ <br/> Runs the thread <br/> """ TestThread () self .displayLbl.SetLabel( "Thread started!" ) btn = event.GetEventObject() btn.Disable() #---------------------------------------------------------------------- def updateDisplay (self, msg): """ <br/> Receives data from thread and updates the display <br/> """ t = msg.data if isinstance (t, int): self .displayLbl.SetLabel( "Time since thread started: %s seconds" % t) else : self .displayLbl.SetLabel( "%s" % t) self .btn.Enable() #---------------------------------------------------------------------- # Run the program if __name__ == "__main__" : app = wx.PySimpleApp() frame = MyForm ().Show() app.MainLoop()
Copy Source | Copy HTML import time import wx from threading import Thread from wx.lib.pubsub import Publisher ######################################################################## class TestThread (Thread): """Test Worker Thread Class.""" #---------------------------------------------------------------------- def __init__ (self): """Init Worker Thread Class.""" Thread. __init__ (self) self .start() # start the thread #---------------------------------------------------------------------- def run (self): """Run Worker Thread.""" # This is the code executing in the new thread. for i in range ( 6 ): time .sleep( 10 ) wx.CallAfter( self . postTime , i) time .sleep( 5 ) wx.CallAfter(Publisher().sendMessage, "update" , "Thread finished!" ) #---------------------------------------------------------------------- def postTime (self, amt): """ <br/> Send time to GUI <br/> """ amtOfTime = (amt + 1 ) * 10 Publisher().sendMessage( "update" , amtOfTime) ######################################################################## class MyForm (wx.Frame): #---------------------------------------------------------------------- def __init__ (self): wx.Frame. __init__ (self, None, wx.ID_ANY, "Tutorial" ) # Add a panel so it looks the correct on all platforms panel = wx.Panel(self, wx.ID_ANY) self .displayLbl = wx.StaticText(panel, label= "Amount of time since thread started goes here" ) self .btn = btn = wx.Button(panel, label= "Start Thread" ) btn.Bind(wx.EVT_BUTTON, self . onButton ) sizer = wx.BoxSizer(wx.VERTICAL) sizer.Add( self .displayLbl, 0 , wx.ALL|wx.CENTER, 5 ) sizer.Add(btn, 0 , wx.ALL|wx.CENTER, 5 ) panel.SetSizer(sizer) # create a pubsub receiver Publisher().subscribe( self . updateDisplay , "update" ) #---------------------------------------------------------------------- def onButton (self, event): """ <br/> Runs the thread <br/> """ TestThread () self .displayLbl.SetLabel( "Thread started!" ) btn = event.GetEventObject() btn.Disable() #---------------------------------------------------------------------- def updateDisplay (self, msg): """ <br/> Receives data from thread and updates the display <br/> """ t = msg.data if isinstance (t, int): self .displayLbl.SetLabel( "Time since thread started: %s seconds" % t) else : self .displayLbl.SetLabel( "%s" % t) self .btn.Enable() #---------------------------------------------------------------------- # Run the program if __name__ == "__main__" : app = wx.PySimpleApp() frame = MyForm ().Show() app.MainLoop()
Copy Source | Copy HTML import time import wx from threading import Thread from wx.lib.pubsub import Publisher ######################################################################## class TestThread (Thread): """Test Worker Thread Class.""" #---------------------------------------------------------------------- def __init__ (self): """Init Worker Thread Class.""" Thread. __init__ (self) self .start() # start the thread #---------------------------------------------------------------------- def run (self): """Run Worker Thread.""" # This is the code executing in the new thread. for i in range ( 6 ): time .sleep( 10 ) wx.CallAfter( self . postTime , i) time .sleep( 5 ) wx.CallAfter(Publisher().sendMessage, "update" , "Thread finished!" ) #---------------------------------------------------------------------- def postTime (self, amt): """ <br/> Send time to GUI <br/> """ amtOfTime = (amt + 1 ) * 10 Publisher().sendMessage( "update" , amtOfTime) ######################################################################## class MyForm (wx.Frame): #---------------------------------------------------------------------- def __init__ (self): wx.Frame. __init__ (self, None, wx.ID_ANY, "Tutorial" ) # Add a panel so it looks the correct on all platforms panel = wx.Panel(self, wx.ID_ANY) self .displayLbl = wx.StaticText(panel, label= "Amount of time since thread started goes here" ) self .btn = btn = wx.Button(panel, label= "Start Thread" ) btn.Bind(wx.EVT_BUTTON, self . onButton ) sizer = wx.BoxSizer(wx.VERTICAL) sizer.Add( self .displayLbl, 0 , wx.ALL|wx.CENTER, 5 ) sizer.Add(btn, 0 , wx.ALL|wx.CENTER, 5 ) panel.SetSizer(sizer) # create a pubsub receiver Publisher().subscribe( self . updateDisplay , "update" ) #---------------------------------------------------------------------- def onButton (self, event): """ <br/> Runs the thread <br/> """ TestThread () self .displayLbl.SetLabel( "Thread started!" ) btn = event.GetEventObject() btn.Disable() #---------------------------------------------------------------------- def updateDisplay (self, msg): """ <br/> Receives data from thread and updates the display <br/> """ t = msg.data if isinstance (t, int): self .displayLbl.SetLabel( "Time since thread started: %s seconds" % t) else : self .displayLbl.SetLabel( "%s" % t) self .btn.Enable() #---------------------------------------------------------------------- # Run the program if __name__ == "__main__" : app = wx.PySimpleApp() frame = MyForm ().Show() app.MainLoop()
Copy Source | Copy HTML import time import wx from threading import Thread from wx.lib.pubsub import Publisher ######################################################################## class TestThread (Thread): """Test Worker Thread Class.""" #---------------------------------------------------------------------- def __init__ (self): """Init Worker Thread Class.""" Thread. __init__ (self) self .start() # start the thread #---------------------------------------------------------------------- def run (self): """Run Worker Thread.""" # This is the code executing in the new thread. for i in range ( 6 ): time .sleep( 10 ) wx.CallAfter( self . postTime , i) time .sleep( 5 ) wx.CallAfter(Publisher().sendMessage, "update" , "Thread finished!" ) #---------------------------------------------------------------------- def postTime (self, amt): """ <br/> Send time to GUI <br/> """ amtOfTime = (amt + 1 ) * 10 Publisher().sendMessage( "update" , amtOfTime) ######################################################################## class MyForm (wx.Frame): #---------------------------------------------------------------------- def __init__ (self): wx.Frame. __init__ (self, None, wx.ID_ANY, "Tutorial" ) # Add a panel so it looks the correct on all platforms panel = wx.Panel(self, wx.ID_ANY) self .displayLbl = wx.StaticText(panel, label= "Amount of time since thread started goes here" ) self .btn = btn = wx.Button(panel, label= "Start Thread" ) btn.Bind(wx.EVT_BUTTON, self . onButton ) sizer = wx.BoxSizer(wx.VERTICAL) sizer.Add( self .displayLbl, 0 , wx.ALL|wx.CENTER, 5 ) sizer.Add(btn, 0 , wx.ALL|wx.CENTER, 5 ) panel.SetSizer(sizer) # create a pubsub receiver Publisher().subscribe( self . updateDisplay , "update" ) #---------------------------------------------------------------------- def onButton (self, event): """ <br/> Runs the thread <br/> """ TestThread () self .displayLbl.SetLabel( "Thread started!" ) btn = event.GetEventObject() btn.Disable() #---------------------------------------------------------------------- def updateDisplay (self, msg): """ <br/> Receives data from thread and updates the display <br/> """ t = msg.data if isinstance (t, int): self .displayLbl.SetLabel( "Time since thread started: %s seconds" % t) else : self .displayLbl.SetLabel( "%s" % t) self .btn.Enable() #---------------------------------------------------------------------- # Run the program if __name__ == "__main__" : app = wx.PySimpleApp() frame = MyForm ().Show() app.MainLoop()
Copy Source | Copy HTML import time import wx from threading import Thread from wx.lib.pubsub import Publisher ######################################################################## class TestThread (Thread): """Test Worker Thread Class.""" #---------------------------------------------------------------------- def __init__ (self): """Init Worker Thread Class.""" Thread. __init__ (self) self .start() # start the thread #---------------------------------------------------------------------- def run (self): """Run Worker Thread.""" # This is the code executing in the new thread. for i in range ( 6 ): time .sleep( 10 ) wx.CallAfter( self . postTime , i) time .sleep( 5 ) wx.CallAfter(Publisher().sendMessage, "update" , "Thread finished!" ) #---------------------------------------------------------------------- def postTime (self, amt): """ <br/> Send time to GUI <br/> """ amtOfTime = (amt + 1 ) * 10 Publisher().sendMessage( "update" , amtOfTime) ######################################################################## class MyForm (wx.Frame): #---------------------------------------------------------------------- def __init__ (self): wx.Frame. __init__ (self, None, wx.ID_ANY, "Tutorial" ) # Add a panel so it looks the correct on all platforms panel = wx.Panel(self, wx.ID_ANY) self .displayLbl = wx.StaticText(panel, label= "Amount of time since thread started goes here" ) self .btn = btn = wx.Button(panel, label= "Start Thread" ) btn.Bind(wx.EVT_BUTTON, self . onButton ) sizer = wx.BoxSizer(wx.VERTICAL) sizer.Add( self .displayLbl, 0 , wx.ALL|wx.CENTER, 5 ) sizer.Add(btn, 0 , wx.ALL|wx.CENTER, 5 ) panel.SetSizer(sizer) # create a pubsub receiver Publisher().subscribe( self . updateDisplay , "update" ) #---------------------------------------------------------------------- def onButton (self, event): """ <br/> Runs the thread <br/> """ TestThread () self .displayLbl.SetLabel( "Thread started!" ) btn = event.GetEventObject() btn.Disable() #---------------------------------------------------------------------- def updateDisplay (self, msg): """ <br/> Receives data from thread and updates the display <br/> """ t = msg.data if isinstance (t, int): self .displayLbl.SetLabel( "Time since thread started: %s seconds" % t) else : self .displayLbl.SetLabel( "%s" % t) self .btn.Enable() #---------------------------------------------------------------------- # Run the program if __name__ == "__main__" : app = wx.PySimpleApp() frame = MyForm ().Show() app.MainLoop()
Copy Source | Copy HTML import time import wx from threading import Thread from wx.lib.pubsub import Publisher ######################################################################## class TestThread (Thread): """Test Worker Thread Class.""" #---------------------------------------------------------------------- def __init__ (self): """Init Worker Thread Class.""" Thread. __init__ (self) self .start() # start the thread #---------------------------------------------------------------------- def run (self): """Run Worker Thread.""" # This is the code executing in the new thread. for i in range ( 6 ): time .sleep( 10 ) wx.CallAfter( self . postTime , i) time .sleep( 5 ) wx.CallAfter(Publisher().sendMessage, "update" , "Thread finished!" ) #---------------------------------------------------------------------- def postTime (self, amt): """ <br/> Send time to GUI <br/> """ amtOfTime = (amt + 1 ) * 10 Publisher().sendMessage( "update" , amtOfTime) ######################################################################## class MyForm (wx.Frame): #---------------------------------------------------------------------- def __init__ (self): wx.Frame. __init__ (self, None, wx.ID_ANY, "Tutorial" ) # Add a panel so it looks the correct on all platforms panel = wx.Panel(self, wx.ID_ANY) self .displayLbl = wx.StaticText(panel, label= "Amount of time since thread started goes here" ) self .btn = btn = wx.Button(panel, label= "Start Thread" ) btn.Bind(wx.EVT_BUTTON, self . onButton ) sizer = wx.BoxSizer(wx.VERTICAL) sizer.Add( self .displayLbl, 0 , wx.ALL|wx.CENTER, 5 ) sizer.Add(btn, 0 , wx.ALL|wx.CENTER, 5 ) panel.SetSizer(sizer) # create a pubsub receiver Publisher().subscribe( self . updateDisplay , "update" ) #---------------------------------------------------------------------- def onButton (self, event): """ <br/> Runs the thread <br/> """ TestThread () self .displayLbl.SetLabel( "Thread started!" ) btn = event.GetEventObject() btn.Disable() #---------------------------------------------------------------------- def updateDisplay (self, msg): """ <br/> Receives data from thread and updates the display <br/> """ t = msg.data if isinstance (t, int): self .displayLbl.SetLabel( "Time since thread started: %s seconds" % t) else : self .displayLbl.SetLabel( "%s" % t) self .btn.Enable() #---------------------------------------------------------------------- # Run the program if __name__ == "__main__" : app = wx.PySimpleApp() frame = MyForm ().Show() app.MainLoop()
Copy Source | Copy HTML import time import wx from threading import Thread from wx.lib.pubsub import Publisher ######################################################################## class TestThread (Thread): """Test Worker Thread Class.""" #---------------------------------------------------------------------- def __init__ (self): """Init Worker Thread Class.""" Thread. __init__ (self) self .start() # start the thread #---------------------------------------------------------------------- def run (self): """Run Worker Thread.""" # This is the code executing in the new thread. for i in range ( 6 ): time .sleep( 10 ) wx.CallAfter( self . postTime , i) time .sleep( 5 ) wx.CallAfter(Publisher().sendMessage, "update" , "Thread finished!" ) #---------------------------------------------------------------------- def postTime (self, amt): """ <br/> Send time to GUI <br/> """ amtOfTime = (amt + 1 ) * 10 Publisher().sendMessage( "update" , amtOfTime) ######################################################################## class MyForm (wx.Frame): #---------------------------------------------------------------------- def __init__ (self): wx.Frame. __init__ (self, None, wx.ID_ANY, "Tutorial" ) # Add a panel so it looks the correct on all platforms panel = wx.Panel(self, wx.ID_ANY) self .displayLbl = wx.StaticText(panel, label= "Amount of time since thread started goes here" ) self .btn = btn = wx.Button(panel, label= "Start Thread" ) btn.Bind(wx.EVT_BUTTON, self . onButton ) sizer = wx.BoxSizer(wx.VERTICAL) sizer.Add( self .displayLbl, 0 , wx.ALL|wx.CENTER, 5 ) sizer.Add(btn, 0 , wx.ALL|wx.CENTER, 5 ) panel.SetSizer(sizer) # create a pubsub receiver Publisher().subscribe( self . updateDisplay , "update" ) #---------------------------------------------------------------------- def onButton (self, event): """ <br/> Runs the thread <br/> """ TestThread () self .displayLbl.SetLabel( "Thread started!" ) btn = event.GetEventObject() btn.Disable() #---------------------------------------------------------------------- def updateDisplay (self, msg): """ <br/> Receives data from thread and updates the display <br/> """ t = msg.data if isinstance (t, int): self .displayLbl.SetLabel( "Time since thread started: %s seconds" % t) else : self .displayLbl.SetLabel( "%s" % t) self .btn.Enable() #---------------------------------------------------------------------- # Run the program if __name__ == "__main__" : app = wx.PySimpleApp() frame = MyForm ().Show() app.MainLoop()
Copy Source | Copy HTML import time import wx from threading import Thread from wx.lib.pubsub import Publisher ######################################################################## class TestThread (Thread): """Test Worker Thread Class.""" #---------------------------------------------------------------------- def __init__ (self): """Init Worker Thread Class.""" Thread. __init__ (self) self .start() # start the thread #---------------------------------------------------------------------- def run (self): """Run Worker Thread.""" # This is the code executing in the new thread. for i in range ( 6 ): time .sleep( 10 ) wx.CallAfter( self . postTime , i) time .sleep( 5 ) wx.CallAfter(Publisher().sendMessage, "update" , "Thread finished!" ) #---------------------------------------------------------------------- def postTime (self, amt): """ <br/> Send time to GUI <br/> """ amtOfTime = (amt + 1 ) * 10 Publisher().sendMessage( "update" , amtOfTime) ######################################################################## class MyForm (wx.Frame): #---------------------------------------------------------------------- def __init__ (self): wx.Frame. __init__ (self, None, wx.ID_ANY, "Tutorial" ) # Add a panel so it looks the correct on all platforms panel = wx.Panel(self, wx.ID_ANY) self .displayLbl = wx.StaticText(panel, label= "Amount of time since thread started goes here" ) self .btn = btn = wx.Button(panel, label= "Start Thread" ) btn.Bind(wx.EVT_BUTTON, self . onButton ) sizer = wx.BoxSizer(wx.VERTICAL) sizer.Add( self .displayLbl, 0 , wx.ALL|wx.CENTER, 5 ) sizer.Add(btn, 0 , wx.ALL|wx.CENTER, 5 ) panel.SetSizer(sizer) # create a pubsub receiver Publisher().subscribe( self . updateDisplay , "update" ) #---------------------------------------------------------------------- def onButton (self, event): """ <br/> Runs the thread <br/> """ TestThread () self .displayLbl.SetLabel( "Thread started!" ) btn = event.GetEventObject() btn.Disable() #---------------------------------------------------------------------- def updateDisplay (self, msg): """ <br/> Receives data from thread and updates the display <br/> """ t = msg.data if isinstance (t, int): self .displayLbl.SetLabel( "Time since thread started: %s seconds" % t) else : self .displayLbl.SetLabel( "%s" % t) self .btn.Enable() #---------------------------------------------------------------------- # Run the program if __name__ == "__main__" : app = wx.PySimpleApp() frame = MyForm ().Show() app.MainLoop()
Copy Source | Copy HTML import time import wx from threading import Thread from wx.lib.pubsub import Publisher ######################################################################## class TestThread (Thread): """Test Worker Thread Class.""" #---------------------------------------------------------------------- def __init__ (self): """Init Worker Thread Class.""" Thread. __init__ (self) self .start() # start the thread #---------------------------------------------------------------------- def run (self): """Run Worker Thread.""" # This is the code executing in the new thread. for i in range ( 6 ): time .sleep( 10 ) wx.CallAfter( self . postTime , i) time .sleep( 5 ) wx.CallAfter(Publisher().sendMessage, "update" , "Thread finished!" ) #---------------------------------------------------------------------- def postTime (self, amt): """ <br/> Send time to GUI <br/> """ amtOfTime = (amt + 1 ) * 10 Publisher().sendMessage( "update" , amtOfTime) ######################################################################## class MyForm (wx.Frame): #---------------------------------------------------------------------- def __init__ (self): wx.Frame. __init__ (self, None, wx.ID_ANY, "Tutorial" ) # Add a panel so it looks the correct on all platforms panel = wx.Panel(self, wx.ID_ANY) self .displayLbl = wx.StaticText(panel, label= "Amount of time since thread started goes here" ) self .btn = btn = wx.Button(panel, label= "Start Thread" ) btn.Bind(wx.EVT_BUTTON, self . onButton ) sizer = wx.BoxSizer(wx.VERTICAL) sizer.Add( self .displayLbl, 0 , wx.ALL|wx.CENTER, 5 ) sizer.Add(btn, 0 , wx.ALL|wx.CENTER, 5 ) panel.SetSizer(sizer) # create a pubsub receiver Publisher().subscribe( self . updateDisplay , "update" ) #---------------------------------------------------------------------- def onButton (self, event): """ <br/> Runs the thread <br/> """ TestThread () self .displayLbl.SetLabel( "Thread started!" ) btn = event.GetEventObject() btn.Disable() #---------------------------------------------------------------------- def updateDisplay (self, msg): """ <br/> Receives data from thread and updates the display <br/> """ t = msg.data if isinstance (t, int): self .displayLbl.SetLabel( "Time since thread started: %s seconds" % t) else : self .displayLbl.SetLabel( "%s" % t) self .btn.Enable() #---------------------------------------------------------------------- # Run the program if __name__ == "__main__" : app = wx.PySimpleApp() frame = MyForm ().Show() app.MainLoop()
Copy Source | Copy HTML import time import wx from threading import Thread from wx.lib.pubsub import Publisher ######################################################################## class TestThread (Thread): """Test Worker Thread Class.""" #---------------------------------------------------------------------- def __init__ (self): """Init Worker Thread Class.""" Thread. __init__ (self) self .start() # start the thread #---------------------------------------------------------------------- def run (self): """Run Worker Thread.""" # This is the code executing in the new thread. for i in range ( 6 ): time .sleep( 10 ) wx.CallAfter( self . postTime , i) time .sleep( 5 ) wx.CallAfter(Publisher().sendMessage, "update" , "Thread finished!" ) #---------------------------------------------------------------------- def postTime (self, amt): """ <br/> Send time to GUI <br/> """ amtOfTime = (amt + 1 ) * 10 Publisher().sendMessage( "update" , amtOfTime) ######################################################################## class MyForm (wx.Frame): #---------------------------------------------------------------------- def __init__ (self): wx.Frame. __init__ (self, None, wx.ID_ANY, "Tutorial" ) # Add a panel so it looks the correct on all platforms panel = wx.Panel(self, wx.ID_ANY) self .displayLbl = wx.StaticText(panel, label= "Amount of time since thread started goes here" ) self .btn = btn = wx.Button(panel, label= "Start Thread" ) btn.Bind(wx.EVT_BUTTON, self . onButton ) sizer = wx.BoxSizer(wx.VERTICAL) sizer.Add( self .displayLbl, 0 , wx.ALL|wx.CENTER, 5 ) sizer.Add(btn, 0 , wx.ALL|wx.CENTER, 5 ) panel.SetSizer(sizer) # create a pubsub receiver Publisher().subscribe( self . updateDisplay , "update" ) #---------------------------------------------------------------------- def onButton (self, event): """ <br/> Runs the thread <br/> """ TestThread () self .displayLbl.SetLabel( "Thread started!" ) btn = event.GetEventObject() btn.Disable() #---------------------------------------------------------------------- def updateDisplay (self, msg): """ <br/> Receives data from thread and updates the display <br/> """ t = msg.data if isinstance (t, int): self .displayLbl.SetLabel( "Time since thread started: %s seconds" % t) else : self .displayLbl.SetLabel( "%s" % t) self .btn.Enable() #---------------------------------------------------------------------- # Run the program if __name__ == "__main__" : app = wx.PySimpleApp() frame = MyForm ().Show() app.MainLoop()
Copy Source | Copy HTML import time import wx from threading import Thread from wx.lib.pubsub import Publisher ######################################################################## class TestThread (Thread): """Test Worker Thread Class.""" #---------------------------------------------------------------------- def __init__ (self): """Init Worker Thread Class.""" Thread. __init__ (self) self .start() # start the thread #---------------------------------------------------------------------- def run (self): """Run Worker Thread.""" # This is the code executing in the new thread. for i in range ( 6 ): time .sleep( 10 ) wx.CallAfter( self . postTime , i) time .sleep( 5 ) wx.CallAfter(Publisher().sendMessage, "update" , "Thread finished!" ) #---------------------------------------------------------------------- def postTime (self, amt): """ <br/> Send time to GUI <br/> """ amtOfTime = (amt + 1 ) * 10 Publisher().sendMessage( "update" , amtOfTime) ######################################################################## class MyForm (wx.Frame): #---------------------------------------------------------------------- def __init__ (self): wx.Frame. __init__ (self, None, wx.ID_ANY, "Tutorial" ) # Add a panel so it looks the correct on all platforms panel = wx.Panel(self, wx.ID_ANY) self .displayLbl = wx.StaticText(panel, label= "Amount of time since thread started goes here" ) self .btn = btn = wx.Button(panel, label= "Start Thread" ) btn.Bind(wx.EVT_BUTTON, self . onButton ) sizer = wx.BoxSizer(wx.VERTICAL) sizer.Add( self .displayLbl, 0 , wx.ALL|wx.CENTER, 5 ) sizer.Add(btn, 0 , wx.ALL|wx.CENTER, 5 ) panel.SetSizer(sizer) # create a pubsub receiver Publisher().subscribe( self . updateDisplay , "update" ) #---------------------------------------------------------------------- def onButton (self, event): """ <br/> Runs the thread <br/> """ TestThread () self .displayLbl.SetLabel( "Thread started!" ) btn = event.GetEventObject() btn.Disable() #---------------------------------------------------------------------- def updateDisplay (self, msg): """ <br/> Receives data from thread and updates the display <br/> """ t = msg.data if isinstance (t, int): self .displayLbl.SetLabel( "Time since thread started: %s seconds" % t) else : self .displayLbl.SetLabel( "%s" % t) self .btn.Enable() #---------------------------------------------------------------------- # Run the program if __name__ == "__main__" : app = wx.PySimpleApp() frame = MyForm ().Show() app.MainLoop()
Copy Source | Copy HTML import time import wx from threading import Thread from wx.lib.pubsub import Publisher ######################################################################## class TestThread (Thread): """Test Worker Thread Class.""" #---------------------------------------------------------------------- def __init__ (self): """Init Worker Thread Class.""" Thread. __init__ (self) self .start() # start the thread #---------------------------------------------------------------------- def run (self): """Run Worker Thread.""" # This is the code executing in the new thread. for i in range ( 6 ): time .sleep( 10 ) wx.CallAfter( self . postTime , i) time .sleep( 5 ) wx.CallAfter(Publisher().sendMessage, "update" , "Thread finished!" ) #---------------------------------------------------------------------- def postTime (self, amt): """ <br/> Send time to GUI <br/> """ amtOfTime = (amt + 1 ) * 10 Publisher().sendMessage( "update" , amtOfTime) ######################################################################## class MyForm (wx.Frame): #---------------------------------------------------------------------- def __init__ (self): wx.Frame. __init__ (self, None, wx.ID_ANY, "Tutorial" ) # Add a panel so it looks the correct on all platforms panel = wx.Panel(self, wx.ID_ANY) self .displayLbl = wx.StaticText(panel, label= "Amount of time since thread started goes here" ) self .btn = btn = wx.Button(panel, label= "Start Thread" ) btn.Bind(wx.EVT_BUTTON, self . onButton ) sizer = wx.BoxSizer(wx.VERTICAL) sizer.Add( self .displayLbl, 0 , wx.ALL|wx.CENTER, 5 ) sizer.Add(btn, 0 , wx.ALL|wx.CENTER, 5 ) panel.SetSizer(sizer) # create a pubsub receiver Publisher().subscribe( self . updateDisplay , "update" ) #---------------------------------------------------------------------- def onButton (self, event): """ <br/> Runs the thread <br/> """ TestThread () self .displayLbl.SetLabel( "Thread started!" ) btn = event.GetEventObject() btn.Disable() #---------------------------------------------------------------------- def updateDisplay (self, msg): """ <br/> Receives data from thread and updates the display <br/> """ t = msg.data if isinstance (t, int): self .displayLbl.SetLabel( "Time since thread started: %s seconds" % t) else : self .displayLbl.SetLabel( "%s" % t) self .btn.Enable() #---------------------------------------------------------------------- # Run the program if __name__ == "__main__" : app = wx.PySimpleApp() frame = MyForm ().Show() app.MainLoop()
Copy Source | Copy HTML import time import wx from threading import Thread from wx.lib.pubsub import Publisher ######################################################################## class TestThread (Thread): """Test Worker Thread Class.""" #---------------------------------------------------------------------- def __init__ (self): """Init Worker Thread Class.""" Thread. __init__ (self) self .start() # start the thread #---------------------------------------------------------------------- def run (self): """Run Worker Thread.""" # This is the code executing in the new thread. for i in range ( 6 ): time .sleep( 10 ) wx.CallAfter( self . postTime , i) time .sleep( 5 ) wx.CallAfter(Publisher().sendMessage, "update" , "Thread finished!" ) #---------------------------------------------------------------------- def postTime (self, amt): """ <br/> Send time to GUI <br/> """ amtOfTime = (amt + 1 ) * 10 Publisher().sendMessage( "update" , amtOfTime) ######################################################################## class MyForm (wx.Frame): #---------------------------------------------------------------------- def __init__ (self): wx.Frame. __init__ (self, None, wx.ID_ANY, "Tutorial" ) # Add a panel so it looks the correct on all platforms panel = wx.Panel(self, wx.ID_ANY) self .displayLbl = wx.StaticText(panel, label= "Amount of time since thread started goes here" ) self .btn = btn = wx.Button(panel, label= "Start Thread" ) btn.Bind(wx.EVT_BUTTON, self . onButton ) sizer = wx.BoxSizer(wx.VERTICAL) sizer.Add( self .displayLbl, 0 , wx.ALL|wx.CENTER, 5 ) sizer.Add(btn, 0 , wx.ALL|wx.CENTER, 5 ) panel.SetSizer(sizer) # create a pubsub receiver Publisher().subscribe( self . updateDisplay , "update" ) #---------------------------------------------------------------------- def onButton (self, event): """ <br/> Runs the thread <br/> """ TestThread () self .displayLbl.SetLabel( "Thread started!" ) btn = event.GetEventObject() btn.Disable() #---------------------------------------------------------------------- def updateDisplay (self, msg): """ <br/> Receives data from thread and updates the display <br/> """ t = msg.data if isinstance (t, int): self .displayLbl.SetLabel( "Time since thread started: %s seconds" % t) else : self .displayLbl.SetLabel( "%s" % t) self .btn.Enable() #---------------------------------------------------------------------- # Run the program if __name__ == "__main__" : app = wx.PySimpleApp() frame = MyForm ().Show() app.MainLoop()
Copy Source | Copy HTML import time import wx from threading import Thread from wx.lib.pubsub import Publisher ######################################################################## class TestThread (Thread): """Test Worker Thread Class.""" #---------------------------------------------------------------------- def __init__ (self): """Init Worker Thread Class.""" Thread. __init__ (self) self .start() # start the thread #---------------------------------------------------------------------- def run (self): """Run Worker Thread.""" # This is the code executing in the new thread. for i in range ( 6 ): time .sleep( 10 ) wx.CallAfter( self . postTime , i) time .sleep( 5 ) wx.CallAfter(Publisher().sendMessage, "update" , "Thread finished!" ) #---------------------------------------------------------------------- def postTime (self, amt): """ <br/> Send time to GUI <br/> """ amtOfTime = (amt + 1 ) * 10 Publisher().sendMessage( "update" , amtOfTime) ######################################################################## class MyForm (wx.Frame): #---------------------------------------------------------------------- def __init__ (self): wx.Frame. __init__ (self, None, wx.ID_ANY, "Tutorial" ) # Add a panel so it looks the correct on all platforms panel = wx.Panel(self, wx.ID_ANY) self .displayLbl = wx.StaticText(panel, label= "Amount of time since thread started goes here" ) self .btn = btn = wx.Button(panel, label= "Start Thread" ) btn.Bind(wx.EVT_BUTTON, self . onButton ) sizer = wx.BoxSizer(wx.VERTICAL) sizer.Add( self .displayLbl, 0 , wx.ALL|wx.CENTER, 5 ) sizer.Add(btn, 0 , wx.ALL|wx.CENTER, 5 ) panel.SetSizer(sizer) # create a pubsub receiver Publisher().subscribe( self . updateDisplay , "update" ) #---------------------------------------------------------------------- def onButton (self, event): """ <br/> Runs the thread <br/> """ TestThread () self .displayLbl.SetLabel( "Thread started!" ) btn = event.GetEventObject() btn.Disable() #---------------------------------------------------------------------- def updateDisplay (self, msg): """ <br/> Receives data from thread and updates the display <br/> """ t = msg.data if isinstance (t, int): self .displayLbl.SetLabel( "Time since thread started: %s seconds" % t) else : self .displayLbl.SetLabel( "%s" % t) self .btn.Enable() #---------------------------------------------------------------------- # Run the program if __name__ == "__main__" : app = wx.PySimpleApp() frame = MyForm ().Show() app.MainLoop()
Copy Source | Copy HTML import time import wx from threading import Thread from wx.lib.pubsub import Publisher ######################################################################## class TestThread (Thread): """Test Worker Thread Class.""" #---------------------------------------------------------------------- def __init__ (self): """Init Worker Thread Class.""" Thread. __init__ (self) self .start() # start the thread #---------------------------------------------------------------------- def run (self): """Run Worker Thread.""" # This is the code executing in the new thread. for i in range ( 6 ): time .sleep( 10 ) wx.CallAfter( self . postTime , i) time .sleep( 5 ) wx.CallAfter(Publisher().sendMessage, "update" , "Thread finished!" ) #---------------------------------------------------------------------- def postTime (self, amt): """ <br/> Send time to GUI <br/> """ amtOfTime = (amt + 1 ) * 10 Publisher().sendMessage( "update" , amtOfTime) ######################################################################## class MyForm (wx.Frame): #---------------------------------------------------------------------- def __init__ (self): wx.Frame. __init__ (self, None, wx.ID_ANY, "Tutorial" ) # Add a panel so it looks the correct on all platforms panel = wx.Panel(self, wx.ID_ANY) self .displayLbl = wx.StaticText(panel, label= "Amount of time since thread started goes here" ) self .btn = btn = wx.Button(panel, label= "Start Thread" ) btn.Bind(wx.EVT_BUTTON, self . onButton ) sizer = wx.BoxSizer(wx.VERTICAL) sizer.Add( self .displayLbl, 0 , wx.ALL|wx.CENTER, 5 ) sizer.Add(btn, 0 , wx.ALL|wx.CENTER, 5 ) panel.SetSizer(sizer) # create a pubsub receiver Publisher().subscribe( self . updateDisplay , "update" ) #---------------------------------------------------------------------- def onButton (self, event): """ <br/> Runs the thread <br/> """ TestThread () self .displayLbl.SetLabel( "Thread started!" ) btn = event.GetEventObject() btn.Disable() #---------------------------------------------------------------------- def updateDisplay (self, msg): """ <br/> Receives data from thread and updates the display <br/> """ t = msg.data if isinstance (t, int): self .displayLbl.SetLabel( "Time since thread started: %s seconds" % t) else : self .displayLbl.SetLabel( "%s" % t) self .btn.Enable() #---------------------------------------------------------------------- # Run the program if __name__ == "__main__" : app = wx.PySimpleApp() frame = MyForm ().Show() app.MainLoop()
Copy Source | Copy HTML import time import wx from threading import Thread from wx.lib.pubsub import Publisher ######################################################################## class TestThread (Thread): """Test Worker Thread Class.""" #---------------------------------------------------------------------- def __init__ (self): """Init Worker Thread Class.""" Thread. __init__ (self) self .start() # start the thread #---------------------------------------------------------------------- def run (self): """Run Worker Thread.""" # This is the code executing in the new thread. for i in range ( 6 ): time .sleep( 10 ) wx.CallAfter( self . postTime , i) time .sleep( 5 ) wx.CallAfter(Publisher().sendMessage, "update" , "Thread finished!" ) #---------------------------------------------------------------------- def postTime (self, amt): """ <br/> Send time to GUI <br/> """ amtOfTime = (amt + 1 ) * 10 Publisher().sendMessage( "update" , amtOfTime) ######################################################################## class MyForm (wx.Frame): #---------------------------------------------------------------------- def __init__ (self): wx.Frame. __init__ (self, None, wx.ID_ANY, "Tutorial" ) # Add a panel so it looks the correct on all platforms panel = wx.Panel(self, wx.ID_ANY) self .displayLbl = wx.StaticText(panel, label= "Amount of time since thread started goes here" ) self .btn = btn = wx.Button(panel, label= "Start Thread" ) btn.Bind(wx.EVT_BUTTON, self . onButton ) sizer = wx.BoxSizer(wx.VERTICAL) sizer.Add( self .displayLbl, 0 , wx.ALL|wx.CENTER, 5 ) sizer.Add(btn, 0 , wx.ALL|wx.CENTER, 5 ) panel.SetSizer(sizer) # create a pubsub receiver Publisher().subscribe( self . updateDisplay , "update" ) #---------------------------------------------------------------------- def onButton (self, event): """ <br/> Runs the thread <br/> """ TestThread () self .displayLbl.SetLabel( "Thread started!" ) btn = event.GetEventObject() btn.Disable() #---------------------------------------------------------------------- def updateDisplay (self, msg): """ <br/> Receives data from thread and updates the display <br/> """ t = msg.data if isinstance (t, int): self .displayLbl.SetLabel( "Time since thread started: %s seconds" % t) else : self .displayLbl.SetLabel( "%s" % t) self .btn.Enable() #---------------------------------------------------------------------- # Run the program if __name__ == "__main__" : app = wx.PySimpleApp() frame = MyForm ().Show() app.MainLoop()
Copy Source | Copy HTML import time import wx from threading import Thread from wx.lib.pubsub import Publisher ######################################################################## class TestThread (Thread): """Test Worker Thread Class.""" #---------------------------------------------------------------------- def __init__ (self): """Init Worker Thread Class.""" Thread. __init__ (self) self .start() # start the thread #---------------------------------------------------------------------- def run (self): """Run Worker Thread.""" # This is the code executing in the new thread. for i in range ( 6 ): time .sleep( 10 ) wx.CallAfter( self . postTime , i) time .sleep( 5 ) wx.CallAfter(Publisher().sendMessage, "update" , "Thread finished!" ) #---------------------------------------------------------------------- def postTime (self, amt): """ <br/> Send time to GUI <br/> """ amtOfTime = (amt + 1 ) * 10 Publisher().sendMessage( "update" , amtOfTime) ######################################################################## class MyForm (wx.Frame): #---------------------------------------------------------------------- def __init__ (self): wx.Frame. __init__ (self, None, wx.ID_ANY, "Tutorial" ) # Add a panel so it looks the correct on all platforms panel = wx.Panel(self, wx.ID_ANY) self .displayLbl = wx.StaticText(panel, label= "Amount of time since thread started goes here" ) self .btn = btn = wx.Button(panel, label= "Start Thread" ) btn.Bind(wx.EVT_BUTTON, self . onButton ) sizer = wx.BoxSizer(wx.VERTICAL) sizer.Add( self .displayLbl, 0 , wx.ALL|wx.CENTER, 5 ) sizer.Add(btn, 0 , wx.ALL|wx.CENTER, 5 ) panel.SetSizer(sizer) # create a pubsub receiver Publisher().subscribe( self . updateDisplay , "update" ) #---------------------------------------------------------------------- def onButton (self, event): """ <br/> Runs the thread <br/> """ TestThread () self .displayLbl.SetLabel( "Thread started!" ) btn = event.GetEventObject() btn.Disable() #---------------------------------------------------------------------- def updateDisplay (self, msg): """ <br/> Receives data from thread and updates the display <br/> """ t = msg.data if isinstance (t, int): self .displayLbl.SetLabel( "Time since thread started: %s seconds" % t) else : self .displayLbl.SetLabel( "%s" % t) self .btn.Enable() #---------------------------------------------------------------------- # Run the program if __name__ == "__main__" : app = wx.PySimpleApp() frame = MyForm ().Show() app.MainLoop()
Copy Source | Copy HTML import time import wx from threading import Thread from wx.lib.pubsub import Publisher ######################################################################## class TestThread (Thread): """Test Worker Thread Class.""" #---------------------------------------------------------------------- def __init__ (self): """Init Worker Thread Class.""" Thread. __init__ (self) self .start() # start the thread #---------------------------------------------------------------------- def run (self): """Run Worker Thread.""" # This is the code executing in the new thread. for i in range ( 6 ): time .sleep( 10 ) wx.CallAfter( self . postTime , i) time .sleep( 5 ) wx.CallAfter(Publisher().sendMessage, "update" , "Thread finished!" ) #---------------------------------------------------------------------- def postTime (self, amt): """ <br/> Send time to GUI <br/> """ amtOfTime = (amt + 1 ) * 10 Publisher().sendMessage( "update" , amtOfTime) ######################################################################## class MyForm (wx.Frame): #---------------------------------------------------------------------- def __init__ (self): wx.Frame. __init__ (self, None, wx.ID_ANY, "Tutorial" ) # Add a panel so it looks the correct on all platforms panel = wx.Panel(self, wx.ID_ANY) self .displayLbl = wx.StaticText(panel, label= "Amount of time since thread started goes here" ) self .btn = btn = wx.Button(panel, label= "Start Thread" ) btn.Bind(wx.EVT_BUTTON, self . onButton ) sizer = wx.BoxSizer(wx.VERTICAL) sizer.Add( self .displayLbl, 0 , wx.ALL|wx.CENTER, 5 ) sizer.Add(btn, 0 , wx.ALL|wx.CENTER, 5 ) panel.SetSizer(sizer) # create a pubsub receiver Publisher().subscribe( self . updateDisplay , "update" ) #---------------------------------------------------------------------- def onButton (self, event): """ <br/> Runs the thread <br/> """ TestThread () self .displayLbl.SetLabel( "Thread started!" ) btn = event.GetEventObject() btn.Disable() #---------------------------------------------------------------------- def updateDisplay (self, msg): """ <br/> Receives data from thread and updates the display <br/> """ t = msg.data if isinstance (t, int): self .displayLbl.SetLabel( "Time since thread started: %s seconds" % t) else : self .displayLbl.SetLabel( "%s" % t) self .btn.Enable() #---------------------------------------------------------------------- # Run the program if __name__ == "__main__" : app = wx.PySimpleApp() frame = MyForm ().Show() app.MainLoop()
Copy Source | Copy HTML import time import wx from threading import Thread from wx.lib.pubsub import Publisher ######################################################################## class TestThread (Thread): """Test Worker Thread Class.""" #---------------------------------------------------------------------- def __init__ (self): """Init Worker Thread Class.""" Thread. __init__ (self) self .start() # start the thread #---------------------------------------------------------------------- def run (self): """Run Worker Thread.""" # This is the code executing in the new thread. for i in range ( 6 ): time .sleep( 10 ) wx.CallAfter( self . postTime , i) time .sleep( 5 ) wx.CallAfter(Publisher().sendMessage, "update" , "Thread finished!" ) #---------------------------------------------------------------------- def postTime (self, amt): """ <br/> Send time to GUI <br/> """ amtOfTime = (amt + 1 ) * 10 Publisher().sendMessage( "update" , amtOfTime) ######################################################################## class MyForm (wx.Frame): #---------------------------------------------------------------------- def __init__ (self): wx.Frame. __init__ (self, None, wx.ID_ANY, "Tutorial" ) # Add a panel so it looks the correct on all platforms panel = wx.Panel(self, wx.ID_ANY) self .displayLbl = wx.StaticText(panel, label= "Amount of time since thread started goes here" ) self .btn = btn = wx.Button(panel, label= "Start Thread" ) btn.Bind(wx.EVT_BUTTON, self . onButton ) sizer = wx.BoxSizer(wx.VERTICAL) sizer.Add( self .displayLbl, 0 , wx.ALL|wx.CENTER, 5 ) sizer.Add(btn, 0 , wx.ALL|wx.CENTER, 5 ) panel.SetSizer(sizer) # create a pubsub receiver Publisher().subscribe( self . updateDisplay , "update" ) #---------------------------------------------------------------------- def onButton (self, event): """ <br/> Runs the thread <br/> """ TestThread () self .displayLbl.SetLabel( "Thread started!" ) btn = event.GetEventObject() btn.Disable() #---------------------------------------------------------------------- def updateDisplay (self, msg): """ <br/> Receives data from thread and updates the display <br/> """ t = msg.data if isinstance (t, int): self .displayLbl.SetLabel( "Time since thread started: %s seconds" % t) else : self .displayLbl.SetLabel( "%s" % t) self .btn.Enable() #---------------------------------------------------------------------- # Run the program if __name__ == "__main__" : app = wx.PySimpleApp() frame = MyForm ().Show() app.MainLoop()
Copy Source | Copy HTML import time import wx from threading import Thread from wx.lib.pubsub import Publisher ######################################################################## class TestThread (Thread): """Test Worker Thread Class.""" #---------------------------------------------------------------------- def __init__ (self): """Init Worker Thread Class.""" Thread. __init__ (self) self .start() # start the thread #---------------------------------------------------------------------- def run (self): """Run Worker Thread.""" # This is the code executing in the new thread. for i in range ( 6 ): time .sleep( 10 ) wx.CallAfter( self . postTime , i) time .sleep( 5 ) wx.CallAfter(Publisher().sendMessage, "update" , "Thread finished!" ) #---------------------------------------------------------------------- def postTime (self, amt): """ <br/> Send time to GUI <br/> """ amtOfTime = (amt + 1 ) * 10 Publisher().sendMessage( "update" , amtOfTime) ######################################################################## class MyForm (wx.Frame): #---------------------------------------------------------------------- def __init__ (self): wx.Frame. __init__ (self, None, wx.ID_ANY, "Tutorial" ) # Add a panel so it looks the correct on all platforms panel = wx.Panel(self, wx.ID_ANY) self .displayLbl = wx.StaticText(panel, label= "Amount of time since thread started goes here" ) self .btn = btn = wx.Button(panel, label= "Start Thread" ) btn.Bind(wx.EVT_BUTTON, self . onButton ) sizer = wx.BoxSizer(wx.VERTICAL) sizer.Add( self .displayLbl, 0 , wx.ALL|wx.CENTER, 5 ) sizer.Add(btn, 0 , wx.ALL|wx.CENTER, 5 ) panel.SetSizer(sizer) # create a pubsub receiver Publisher().subscribe( self . updateDisplay , "update" ) #---------------------------------------------------------------------- def onButton (self, event): """ <br/> Runs the thread <br/> """ TestThread () self .displayLbl.SetLabel( "Thread started!" ) btn = event.GetEventObject() btn.Disable() #---------------------------------------------------------------------- def updateDisplay (self, msg): """ <br/> Receives data from thread and updates the display <br/> """ t = msg.data if isinstance (t, int): self .displayLbl.SetLabel( "Time since thread started: %s seconds" % t) else : self .displayLbl.SetLabel( "%s" % t) self .btn.Enable() #---------------------------------------------------------------------- # Run the program if __name__ == "__main__" : app = wx.PySimpleApp() frame = MyForm ().Show() app.MainLoop()
Copy Source | Copy HTML import time import wx from threading import Thread from wx.lib.pubsub import Publisher ######################################################################## class TestThread (Thread): """Test Worker Thread Class.""" #---------------------------------------------------------------------- def __init__ (self): """Init Worker Thread Class.""" Thread. __init__ (self) self .start() # start the thread #---------------------------------------------------------------------- def run (self): """Run Worker Thread.""" # This is the code executing in the new thread. for i in range ( 6 ): time .sleep( 10 ) wx.CallAfter( self . postTime , i) time .sleep( 5 ) wx.CallAfter(Publisher().sendMessage, "update" , "Thread finished!" ) #---------------------------------------------------------------------- def postTime (self, amt): """ <br/> Send time to GUI <br/> """ amtOfTime = (amt + 1 ) * 10 Publisher().sendMessage( "update" , amtOfTime) ######################################################################## class MyForm (wx.Frame): #---------------------------------------------------------------------- def __init__ (self): wx.Frame. __init__ (self, None, wx.ID_ANY, "Tutorial" ) # Add a panel so it looks the correct on all platforms panel = wx.Panel(self, wx.ID_ANY) self .displayLbl = wx.StaticText(panel, label= "Amount of time since thread started goes here" ) self .btn = btn = wx.Button(panel, label= "Start Thread" ) btn.Bind(wx.EVT_BUTTON, self . onButton ) sizer = wx.BoxSizer(wx.VERTICAL) sizer.Add( self .displayLbl, 0 , wx.ALL|wx.CENTER, 5 ) sizer.Add(btn, 0 , wx.ALL|wx.CENTER, 5 ) panel.SetSizer(sizer) # create a pubsub receiver Publisher().subscribe( self . updateDisplay , "update" ) #---------------------------------------------------------------------- def onButton (self, event): """ <br/> Runs the thread <br/> """ TestThread () self .displayLbl.SetLabel( "Thread started!" ) btn = event.GetEventObject() btn.Disable() #---------------------------------------------------------------------- def updateDisplay (self, msg): """ <br/> Receives data from thread and updates the display <br/> """ t = msg.data if isinstance (t, int): self .displayLbl.SetLabel( "Time since thread started: %s seconds" % t) else : self .displayLbl.SetLabel( "%s" % t) self .btn.Enable() #---------------------------------------------------------------------- # Run the program if __name__ == "__main__" : app = wx.PySimpleApp() frame = MyForm ().Show() app.MainLoop()
Copy Source | Copy HTML import time import wx from threading import Thread from wx.lib.pubsub import Publisher ######################################################################## class TestThread (Thread): """Test Worker Thread Class.""" #---------------------------------------------------------------------- def __init__ (self): """Init Worker Thread Class.""" Thread. __init__ (self) self .start() # start the thread #---------------------------------------------------------------------- def run (self): """Run Worker Thread.""" # This is the code executing in the new thread. for i in range ( 6 ): time .sleep( 10 ) wx.CallAfter( self . postTime , i) time .sleep( 5 ) wx.CallAfter(Publisher().sendMessage, "update" , "Thread finished!" ) #---------------------------------------------------------------------- def postTime (self, amt): """ <br/> Send time to GUI <br/> """ amtOfTime = (amt + 1 ) * 10 Publisher().sendMessage( "update" , amtOfTime) ######################################################################## class MyForm (wx.Frame): #---------------------------------------------------------------------- def __init__ (self): wx.Frame. __init__ (self, None, wx.ID_ANY, "Tutorial" ) # Add a panel so it looks the correct on all platforms panel = wx.Panel(self, wx.ID_ANY) self .displayLbl = wx.StaticText(panel, label= "Amount of time since thread started goes here" ) self .btn = btn = wx.Button(panel, label= "Start Thread" ) btn.Bind(wx.EVT_BUTTON, self . onButton ) sizer = wx.BoxSizer(wx.VERTICAL) sizer.Add( self .displayLbl, 0 , wx.ALL|wx.CENTER, 5 ) sizer.Add(btn, 0 , wx.ALL|wx.CENTER, 5 ) panel.SetSizer(sizer) # create a pubsub receiver Publisher().subscribe( self . updateDisplay , "update" ) #---------------------------------------------------------------------- def onButton (self, event): """ <br/> Runs the thread <br/> """ TestThread () self .displayLbl.SetLabel( "Thread started!" ) btn = event.GetEventObject() btn.Disable() #---------------------------------------------------------------------- def updateDisplay (self, msg): """ <br/> Receives data from thread and updates the display <br/> """ t = msg.data if isinstance (t, int): self .displayLbl.SetLabel( "Time since thread started: %s seconds" % t) else : self .displayLbl.SetLabel( "%s" % t) self .btn.Enable() #---------------------------------------------------------------------- # Run the program if __name__ == "__main__" : app = wx.PySimpleApp() frame = MyForm ().Show() app.MainLoop()
Copy Source | Copy HTML import time import wx from threading import Thread from wx.lib.pubsub import Publisher ######################################################################## class TestThread (Thread): """Test Worker Thread Class.""" #---------------------------------------------------------------------- def __init__ (self): """Init Worker Thread Class.""" Thread. __init__ (self) self .start() # start the thread #---------------------------------------------------------------------- def run (self): """Run Worker Thread.""" # This is the code executing in the new thread. for i in range ( 6 ): time .sleep( 10 ) wx.CallAfter( self . postTime , i) time .sleep( 5 ) wx.CallAfter(Publisher().sendMessage, "update" , "Thread finished!" ) #---------------------------------------------------------------------- def postTime (self, amt): """ <br/> Send time to GUI <br/> """ amtOfTime = (amt + 1 ) * 10 Publisher().sendMessage( "update" , amtOfTime) ######################################################################## class MyForm (wx.Frame): #---------------------------------------------------------------------- def __init__ (self): wx.Frame. __init__ (self, None, wx.ID_ANY, "Tutorial" ) # Add a panel so it looks the correct on all platforms panel = wx.Panel(self, wx.ID_ANY) self .displayLbl = wx.StaticText(panel, label= "Amount of time since thread started goes here" ) self .btn = btn = wx.Button(panel, label= "Start Thread" ) btn.Bind(wx.EVT_BUTTON, self . onButton ) sizer = wx.BoxSizer(wx.VERTICAL) sizer.Add( self .displayLbl, 0 , wx.ALL|wx.CENTER, 5 ) sizer.Add(btn, 0 , wx.ALL|wx.CENTER, 5 ) panel.SetSizer(sizer) # create a pubsub receiver Publisher().subscribe( self . updateDisplay , "update" ) #---------------------------------------------------------------------- def onButton (self, event): """ <br/> Runs the thread <br/> """ TestThread () self .displayLbl.SetLabel( "Thread started!" ) btn = event.GetEventObject() btn.Disable() #---------------------------------------------------------------------- def updateDisplay (self, msg): """ <br/> Receives data from thread and updates the display <br/> """ t = msg.data if isinstance (t, int): self .displayLbl.SetLabel( "Time since thread started: %s seconds" % t) else : self .displayLbl.SetLabel( "%s" % t) self .btn.Enable() #---------------------------------------------------------------------- # Run the program if __name__ == "__main__" : app = wx.PySimpleApp() frame = MyForm ().Show() app.MainLoop()
Copy Source | Copy HTML import time import wx from threading import Thread from wx.lib.pubsub import Publisher ######################################################################## class TestThread (Thread): """Test Worker Thread Class.""" #---------------------------------------------------------------------- def __init__ (self): """Init Worker Thread Class.""" Thread. __init__ (self) self .start() # start the thread #---------------------------------------------------------------------- def run (self): """Run Worker Thread.""" # This is the code executing in the new thread. for i in range ( 6 ): time .sleep( 10 ) wx.CallAfter( self . postTime , i) time .sleep( 5 ) wx.CallAfter(Publisher().sendMessage, "update" , "Thread finished!" ) #---------------------------------------------------------------------- def postTime (self, amt): """ <br/> Send time to GUI <br/> """ amtOfTime = (amt + 1 ) * 10 Publisher().sendMessage( "update" , amtOfTime) ######################################################################## class MyForm (wx.Frame): #---------------------------------------------------------------------- def __init__ (self): wx.Frame. __init__ (self, None, wx.ID_ANY, "Tutorial" ) # Add a panel so it looks the correct on all platforms panel = wx.Panel(self, wx.ID_ANY) self .displayLbl = wx.StaticText(panel, label= "Amount of time since thread started goes here" ) self .btn = btn = wx.Button(panel, label= "Start Thread" ) btn.Bind(wx.EVT_BUTTON, self . onButton ) sizer = wx.BoxSizer(wx.VERTICAL) sizer.Add( self .displayLbl, 0 , wx.ALL|wx.CENTER, 5 ) sizer.Add(btn, 0 , wx.ALL|wx.CENTER, 5 ) panel.SetSizer(sizer) # create a pubsub receiver Publisher().subscribe( self . updateDisplay , "update" ) #---------------------------------------------------------------------- def onButton (self, event): """ <br/> Runs the thread <br/> """ TestThread () self .displayLbl.SetLabel( "Thread started!" ) btn = event.GetEventObject() btn.Disable() #---------------------------------------------------------------------- def updateDisplay (self, msg): """ <br/> Receives data from thread and updates the display <br/> """ t = msg.data if isinstance (t, int): self .displayLbl.SetLabel( "Time since thread started: %s seconds" % t) else : self .displayLbl.SetLabel( "%s" % t) self .btn.Enable() #---------------------------------------------------------------------- # Run the program if __name__ == "__main__" : app = wx.PySimpleApp() frame = MyForm ().Show() app.MainLoop()
Copy Source | Copy HTML import time import wx from threading import Thread from wx.lib.pubsub import Publisher ######################################################################## class TestThread (Thread): """Test Worker Thread Class.""" #---------------------------------------------------------------------- def __init__ (self): """Init Worker Thread Class.""" Thread. __init__ (self) self .start() # start the thread #---------------------------------------------------------------------- def run (self): """Run Worker Thread.""" # This is the code executing in the new thread. for i in range ( 6 ): time .sleep( 10 ) wx.CallAfter( self . postTime , i) time .sleep( 5 ) wx.CallAfter(Publisher().sendMessage, "update" , "Thread finished!" ) #---------------------------------------------------------------------- def postTime (self, amt): """ <br/> Send time to GUI <br/> """ amtOfTime = (amt + 1 ) * 10 Publisher().sendMessage( "update" , amtOfTime) ######################################################################## class MyForm (wx.Frame): #---------------------------------------------------------------------- def __init__ (self): wx.Frame. __init__ (self, None, wx.ID_ANY, "Tutorial" ) # Add a panel so it looks the correct on all platforms panel = wx.Panel(self, wx.ID_ANY) self .displayLbl = wx.StaticText(panel, label= "Amount of time since thread started goes here" ) self .btn = btn = wx.Button(panel, label= "Start Thread" ) btn.Bind(wx.EVT_BUTTON, self . onButton ) sizer = wx.BoxSizer(wx.VERTICAL) sizer.Add( self .displayLbl, 0 , wx.ALL|wx.CENTER, 5 ) sizer.Add(btn, 0 , wx.ALL|wx.CENTER, 5 ) panel.SetSizer(sizer) # create a pubsub receiver Publisher().subscribe( self . updateDisplay , "update" ) #---------------------------------------------------------------------- def onButton (self, event): """ <br/> Runs the thread <br/> """ TestThread () self .displayLbl.SetLabel( "Thread started!" ) btn = event.GetEventObject() btn.Disable() #---------------------------------------------------------------------- def updateDisplay (self, msg): """ <br/> Receives data from thread and updates the display <br/> """ t = msg.data if isinstance (t, int): self .displayLbl.SetLabel( "Time since thread started: %s seconds" % t) else : self .displayLbl.SetLabel( "%s" % t) self .btn.Enable() #---------------------------------------------------------------------- # Run the program if __name__ == "__main__" : app = wx.PySimpleApp() frame = MyForm ().Show() app.MainLoop()
Copy Source | Copy HTML import time import wx from threading import Thread from wx.lib.pubsub import Publisher ######################################################################## class TestThread (Thread): """Test Worker Thread Class.""" #---------------------------------------------------------------------- def __init__ (self): """Init Worker Thread Class.""" Thread. __init__ (self) self .start() # start the thread #---------------------------------------------------------------------- def run (self): """Run Worker Thread.""" # This is the code executing in the new thread. for i in range ( 6 ): time .sleep( 10 ) wx.CallAfter( self . postTime , i) time .sleep( 5 ) wx.CallAfter(Publisher().sendMessage, "update" , "Thread finished!" ) #---------------------------------------------------------------------- def postTime (self, amt): """ <br/> Send time to GUI <br/> """ amtOfTime = (amt + 1 ) * 10 Publisher().sendMessage( "update" , amtOfTime) ######################################################################## class MyForm (wx.Frame): #---------------------------------------------------------------------- def __init__ (self): wx.Frame. __init__ (self, None, wx.ID_ANY, "Tutorial" ) # Add a panel so it looks the correct on all platforms panel = wx.Panel(self, wx.ID_ANY) self .displayLbl = wx.StaticText(panel, label= "Amount of time since thread started goes here" ) self .btn = btn = wx.Button(panel, label= "Start Thread" ) btn.Bind(wx.EVT_BUTTON, self . onButton ) sizer = wx.BoxSizer(wx.VERTICAL) sizer.Add( self .displayLbl, 0 , wx.ALL|wx.CENTER, 5 ) sizer.Add(btn, 0 , wx.ALL|wx.CENTER, 5 ) panel.SetSizer(sizer) # create a pubsub receiver Publisher().subscribe( self . updateDisplay , "update" ) #---------------------------------------------------------------------- def onButton (self, event): """ <br/> Runs the thread <br/> """ TestThread () self .displayLbl.SetLabel( "Thread started!" ) btn = event.GetEventObject() btn.Disable() #---------------------------------------------------------------------- def updateDisplay (self, msg): """ <br/> Receives data from thread and updates the display <br/> """ t = msg.data if isinstance (t, int): self .displayLbl.SetLabel( "Time since thread started: %s seconds" % t) else : self .displayLbl.SetLabel( "%s" % t) self .btn.Enable() #---------------------------------------------------------------------- # Run the program if __name__ == "__main__" : app = wx.PySimpleApp() frame = MyForm ().Show() app.MainLoop()
Copy Source | Copy HTML import time import wx from threading import Thread from wx.lib.pubsub import Publisher ######################################################################## class TestThread (Thread): """Test Worker Thread Class.""" #---------------------------------------------------------------------- def __init__ (self): """Init Worker Thread Class.""" Thread. __init__ (self) self .start() # start the thread #---------------------------------------------------------------------- def run (self): """Run Worker Thread.""" # This is the code executing in the new thread. for i in range ( 6 ): time .sleep( 10 ) wx.CallAfter( self . postTime , i) time .sleep( 5 ) wx.CallAfter(Publisher().sendMessage, "update" , "Thread finished!" ) #---------------------------------------------------------------------- def postTime (self, amt): """ <br/> Send time to GUI <br/> """ amtOfTime = (amt + 1 ) * 10 Publisher().sendMessage( "update" , amtOfTime) ######################################################################## class MyForm (wx.Frame): #---------------------------------------------------------------------- def __init__ (self): wx.Frame. __init__ (self, None, wx.ID_ANY, "Tutorial" ) # Add a panel so it looks the correct on all platforms panel = wx.Panel(self, wx.ID_ANY) self .displayLbl = wx.StaticText(panel, label= "Amount of time since thread started goes here" ) self .btn = btn = wx.Button(panel, label= "Start Thread" ) btn.Bind(wx.EVT_BUTTON, self . onButton ) sizer = wx.BoxSizer(wx.VERTICAL) sizer.Add( self .displayLbl, 0 , wx.ALL|wx.CENTER, 5 ) sizer.Add(btn, 0 , wx.ALL|wx.CENTER, 5 ) panel.SetSizer(sizer) # create a pubsub receiver Publisher().subscribe( self . updateDisplay , "update" ) #---------------------------------------------------------------------- def onButton (self, event): """ <br/> Runs the thread <br/> """ TestThread () self .displayLbl.SetLabel( "Thread started!" ) btn = event.GetEventObject() btn.Disable() #---------------------------------------------------------------------- def updateDisplay (self, msg): """ <br/> Receives data from thread and updates the display <br/> """ t = msg.data if isinstance (t, int): self .displayLbl.SetLabel( "Time since thread started: %s seconds" % t) else : self .displayLbl.SetLabel( "%s" % t) self .btn.Enable() #---------------------------------------------------------------------- # Run the program if __name__ == "__main__" : app = wx.PySimpleApp() frame = MyForm ().Show() app.MainLoop()
Copy Source | Copy HTML import time import wx from threading import Thread from wx.lib.pubsub import Publisher ######################################################################## class TestThread (Thread): """Test Worker Thread Class.""" #---------------------------------------------------------------------- def __init__ (self): """Init Worker Thread Class.""" Thread. __init__ (self) self .start() # start the thread #---------------------------------------------------------------------- def run (self): """Run Worker Thread.""" # This is the code executing in the new thread. for i in range ( 6 ): time .sleep( 10 ) wx.CallAfter( self . postTime , i) time .sleep( 5 ) wx.CallAfter(Publisher().sendMessage, "update" , "Thread finished!" ) #---------------------------------------------------------------------- def postTime (self, amt): """ <br/> Send time to GUI <br/> """ amtOfTime = (amt + 1 ) * 10 Publisher().sendMessage( "update" , amtOfTime) ######################################################################## class MyForm (wx.Frame): #---------------------------------------------------------------------- def __init__ (self): wx.Frame. __init__ (self, None, wx.ID_ANY, "Tutorial" ) # Add a panel so it looks the correct on all platforms panel = wx.Panel(self, wx.ID_ANY) self .displayLbl = wx.StaticText(panel, label= "Amount of time since thread started goes here" ) self .btn = btn = wx.Button(panel, label= "Start Thread" ) btn.Bind(wx.EVT_BUTTON, self . onButton ) sizer = wx.BoxSizer(wx.VERTICAL) sizer.Add( self .displayLbl, 0 , wx.ALL|wx.CENTER, 5 ) sizer.Add(btn, 0 , wx.ALL|wx.CENTER, 5 ) panel.SetSizer(sizer) # create a pubsub receiver Publisher().subscribe( self . updateDisplay , "update" ) #---------------------------------------------------------------------- def onButton (self, event): """ <br/> Runs the thread <br/> """ TestThread () self .displayLbl.SetLabel( "Thread started!" ) btn = event.GetEventObject() btn.Disable() #---------------------------------------------------------------------- def updateDisplay (self, msg): """ <br/> Receives data from thread and updates the display <br/> """ t = msg.data if isinstance (t, int): self .displayLbl.SetLabel( "Time since thread started: %s seconds" % t) else : self .displayLbl.SetLabel( "%s" % t) self .btn.Enable() #---------------------------------------------------------------------- # Run the program if __name__ == "__main__" : app = wx.PySimpleApp() frame = MyForm ().Show() app.MainLoop()
Copy Source | Copy HTML import time import wx from threading import Thread from wx.lib.pubsub import Publisher ######################################################################## class TestThread (Thread): """Test Worker Thread Class.""" #---------------------------------------------------------------------- def __init__ (self): """Init Worker Thread Class.""" Thread. __init__ (self) self .start() # start the thread #---------------------------------------------------------------------- def run (self): """Run Worker Thread.""" # This is the code executing in the new thread. for i in range ( 6 ): time .sleep( 10 ) wx.CallAfter( self . postTime , i) time .sleep( 5 ) wx.CallAfter(Publisher().sendMessage, "update" , "Thread finished!" ) #---------------------------------------------------------------------- def postTime (self, amt): """ <br/> Send time to GUI <br/> """ amtOfTime = (amt + 1 ) * 10 Publisher().sendMessage( "update" , amtOfTime) ######################################################################## class MyForm (wx.Frame): #---------------------------------------------------------------------- def __init__ (self): wx.Frame. __init__ (self, None, wx.ID_ANY, "Tutorial" ) # Add a panel so it looks the correct on all platforms panel = wx.Panel(self, wx.ID_ANY) self .displayLbl = wx.StaticText(panel, label= "Amount of time since thread started goes here" ) self .btn = btn = wx.Button(panel, label= "Start Thread" ) btn.Bind(wx.EVT_BUTTON, self . onButton ) sizer = wx.BoxSizer(wx.VERTICAL) sizer.Add( self .displayLbl, 0 , wx.ALL|wx.CENTER, 5 ) sizer.Add(btn, 0 , wx.ALL|wx.CENTER, 5 ) panel.SetSizer(sizer) # create a pubsub receiver Publisher().subscribe( self . updateDisplay , "update" ) #---------------------------------------------------------------------- def onButton (self, event): """ <br/> Runs the thread <br/> """ TestThread () self .displayLbl.SetLabel( "Thread started!" ) btn = event.GetEventObject() btn.Disable() #---------------------------------------------------------------------- def updateDisplay (self, msg): """ <br/> Receives data from thread and updates the display <br/> """ t = msg.data if isinstance (t, int): self .displayLbl.SetLabel( "Time since thread started: %s seconds" % t) else : self .displayLbl.SetLabel( "%s" % t) self .btn.Enable() #---------------------------------------------------------------------- # Run the program if __name__ == "__main__" : app = wx.PySimpleApp() frame = MyForm ().Show() app.MainLoop()
Copy Source | Copy HTML import time import wx from threading import Thread from wx.lib.pubsub import Publisher ######################################################################## class TestThread (Thread): """Test Worker Thread Class.""" #---------------------------------------------------------------------- def __init__ (self): """Init Worker Thread Class.""" Thread. __init__ (self) self .start() # start the thread #---------------------------------------------------------------------- def run (self): """Run Worker Thread.""" # This is the code executing in the new thread. for i in range ( 6 ): time .sleep( 10 ) wx.CallAfter( self . postTime , i) time .sleep( 5 ) wx.CallAfter(Publisher().sendMessage, "update" , "Thread finished!" ) #---------------------------------------------------------------------- def postTime (self, amt): """ <br/> Send time to GUI <br/> """ amtOfTime = (amt + 1 ) * 10 Publisher().sendMessage( "update" , amtOfTime) ######################################################################## class MyForm (wx.Frame): #---------------------------------------------------------------------- def __init__ (self): wx.Frame. __init__ (self, None, wx.ID_ANY, "Tutorial" ) # Add a panel so it looks the correct on all platforms panel = wx.Panel(self, wx.ID_ANY) self .displayLbl = wx.StaticText(panel, label= "Amount of time since thread started goes here" ) self .btn = btn = wx.Button(panel, label= "Start Thread" ) btn.Bind(wx.EVT_BUTTON, self . onButton ) sizer = wx.BoxSizer(wx.VERTICAL) sizer.Add( self .displayLbl, 0 , wx.ALL|wx.CENTER, 5 ) sizer.Add(btn, 0 , wx.ALL|wx.CENTER, 5 ) panel.SetSizer(sizer) # create a pubsub receiver Publisher().subscribe( self . updateDisplay , "update" ) #---------------------------------------------------------------------- def onButton (self, event): """ <br/> Runs the thread <br/> """ TestThread () self .displayLbl.SetLabel( "Thread started!" ) btn = event.GetEventObject() btn.Disable() #---------------------------------------------------------------------- def updateDisplay (self, msg): """ <br/> Receives data from thread and updates the display <br/> """ t = msg.data if isinstance (t, int): self .displayLbl.SetLabel( "Time since thread started: %s seconds" % t) else : self .displayLbl.SetLabel( "%s" % t) self .btn.Enable() #---------------------------------------------------------------------- # Run the program if __name__ == "__main__" : app = wx.PySimpleApp() frame = MyForm ().Show() app.MainLoop()
Copy Source | Copy HTML import time import wx from threading import Thread from wx.lib.pubsub import Publisher ######################################################################## class TestThread (Thread): """Test Worker Thread Class.""" #---------------------------------------------------------------------- def __init__ (self): """Init Worker Thread Class.""" Thread. __init__ (self) self .start() # start the thread #---------------------------------------------------------------------- def run (self): """Run Worker Thread.""" # This is the code executing in the new thread. for i in range ( 6 ): time .sleep( 10 ) wx.CallAfter( self . postTime , i) time .sleep( 5 ) wx.CallAfter(Publisher().sendMessage, "update" , "Thread finished!" ) #---------------------------------------------------------------------- def postTime (self, amt): """ <br/> Send time to GUI <br/> """ amtOfTime = (amt + 1 ) * 10 Publisher().sendMessage( "update" , amtOfTime) ######################################################################## class MyForm (wx.Frame): #---------------------------------------------------------------------- def __init__ (self): wx.Frame. __init__ (self, None, wx.ID_ANY, "Tutorial" ) # Add a panel so it looks the correct on all platforms panel = wx.Panel(self, wx.ID_ANY) self .displayLbl = wx.StaticText(panel, label= "Amount of time since thread started goes here" ) self .btn = btn = wx.Button(panel, label= "Start Thread" ) btn.Bind(wx.EVT_BUTTON, self . onButton ) sizer = wx.BoxSizer(wx.VERTICAL) sizer.Add( self .displayLbl, 0 , wx.ALL|wx.CENTER, 5 ) sizer.Add(btn, 0 , wx.ALL|wx.CENTER, 5 ) panel.SetSizer(sizer) # create a pubsub receiver Publisher().subscribe( self . updateDisplay , "update" ) #---------------------------------------------------------------------- def onButton (self, event): """ <br/> Runs the thread <br/> """ TestThread () self .displayLbl.SetLabel( "Thread started!" ) btn = event.GetEventObject() btn.Disable() #---------------------------------------------------------------------- def updateDisplay (self, msg): """ <br/> Receives data from thread and updates the display <br/> """ t = msg.data if isinstance (t, int): self .displayLbl.SetLabel( "Time since thread started: %s seconds" % t) else : self .displayLbl.SetLabel( "%s" % t) self .btn.Enable() #---------------------------------------------------------------------- # Run the program if __name__ == "__main__" : app = wx.PySimpleApp() frame = MyForm ().Show() app.MainLoop()
Copy Source | Copy HTML import time import wx from threading import Thread from wx.lib.pubsub import Publisher ######################################################################## class TestThread (Thread): """Test Worker Thread Class.""" #---------------------------------------------------------------------- def __init__ (self): """Init Worker Thread Class.""" Thread. __init__ (self) self .start() # start the thread #---------------------------------------------------------------------- def run (self): """Run Worker Thread.""" # This is the code executing in the new thread. for i in range ( 6 ): time .sleep( 10 ) wx.CallAfter( self . postTime , i) time .sleep( 5 ) wx.CallAfter(Publisher().sendMessage, "update" , "Thread finished!" ) #---------------------------------------------------------------------- def postTime (self, amt): """ <br/> Send time to GUI <br/> """ amtOfTime = (amt + 1 ) * 10 Publisher().sendMessage( "update" , amtOfTime) ######################################################################## class MyForm (wx.Frame): #---------------------------------------------------------------------- def __init__ (self): wx.Frame. __init__ (self, None, wx.ID_ANY, "Tutorial" ) # Add a panel so it looks the correct on all platforms panel = wx.Panel(self, wx.ID_ANY) self .displayLbl = wx.StaticText(panel, label= "Amount of time since thread started goes here" ) self .btn = btn = wx.Button(panel, label= "Start Thread" ) btn.Bind(wx.EVT_BUTTON, self . onButton ) sizer = wx.BoxSizer(wx.VERTICAL) sizer.Add( self .displayLbl, 0 , wx.ALL|wx.CENTER, 5 ) sizer.Add(btn, 0 , wx.ALL|wx.CENTER, 5 ) panel.SetSizer(sizer) # create a pubsub receiver Publisher().subscribe( self . updateDisplay , "update" ) #---------------------------------------------------------------------- def onButton (self, event): """ <br/> Runs the thread <br/> """ TestThread () self .displayLbl.SetLabel( "Thread started!" ) btn = event.GetEventObject() btn.Disable() #---------------------------------------------------------------------- def updateDisplay (self, msg): """ <br/> Receives data from thread and updates the display <br/> """ t = msg.data if isinstance (t, int): self .displayLbl.SetLabel( "Time since thread started: %s seconds" % t) else : self .displayLbl.SetLabel( "%s" % t) self .btn.Enable() #---------------------------------------------------------------------- # Run the program if __name__ == "__main__" : app = wx.PySimpleApp() frame = MyForm ().Show() app.MainLoop()
Copy Source | Copy HTML import time import wx from threading import Thread from wx.lib.pubsub import Publisher ######################################################################## class TestThread (Thread): """Test Worker Thread Class.""" #---------------------------------------------------------------------- def __init__ (self): """Init Worker Thread Class.""" Thread. __init__ (self) self .start() # start the thread #---------------------------------------------------------------------- def run (self): """Run Worker Thread.""" # This is the code executing in the new thread. for i in range ( 6 ): time .sleep( 10 ) wx.CallAfter( self . postTime , i) time .sleep( 5 ) wx.CallAfter(Publisher().sendMessage, "update" , "Thread finished!" ) #---------------------------------------------------------------------- def postTime (self, amt): """ <br/> Send time to GUI <br/> """ amtOfTime = (amt + 1 ) * 10 Publisher().sendMessage( "update" , amtOfTime) ######################################################################## class MyForm (wx.Frame): #---------------------------------------------------------------------- def __init__ (self): wx.Frame. __init__ (self, None, wx.ID_ANY, "Tutorial" ) # Add a panel so it looks the correct on all platforms panel = wx.Panel(self, wx.ID_ANY) self .displayLbl = wx.StaticText(panel, label= "Amount of time since thread started goes here" ) self .btn = btn = wx.Button(panel, label= "Start Thread" ) btn.Bind(wx.EVT_BUTTON, self . onButton ) sizer = wx.BoxSizer(wx.VERTICAL) sizer.Add( self .displayLbl, 0 , wx.ALL|wx.CENTER, 5 ) sizer.Add(btn, 0 , wx.ALL|wx.CENTER, 5 ) panel.SetSizer(sizer) # create a pubsub receiver Publisher().subscribe( self . updateDisplay , "update" ) #---------------------------------------------------------------------- def onButton (self, event): """ <br/> Runs the thread <br/> """ TestThread () self .displayLbl.SetLabel( "Thread started!" ) btn = event.GetEventObject() btn.Disable() #---------------------------------------------------------------------- def updateDisplay (self, msg): """ <br/> Receives data from thread and updates the display <br/> """ t = msg.data if isinstance (t, int): self .displayLbl.SetLabel( "Time since thread started: %s seconds" % t) else : self .displayLbl.SetLabel( "%s" % t) self .btn.Enable() #---------------------------------------------------------------------- # Run the program if __name__ == "__main__" : app = wx.PySimpleApp() frame = MyForm ().Show() app.MainLoop()
Copy Source | Copy HTML import time import wx from threading import Thread from wx.lib.pubsub import Publisher ######################################################################## class TestThread (Thread): """Test Worker Thread Class.""" #---------------------------------------------------------------------- def __init__ (self): """Init Worker Thread Class.""" Thread. __init__ (self) self .start() # start the thread #---------------------------------------------------------------------- def run (self): """Run Worker Thread.""" # This is the code executing in the new thread. for i in range ( 6 ): time .sleep( 10 ) wx.CallAfter( self . postTime , i) time .sleep( 5 ) wx.CallAfter(Publisher().sendMessage, "update" , "Thread finished!" ) #---------------------------------------------------------------------- def postTime (self, amt): """ <br/> Send time to GUI <br/> """ amtOfTime = (amt + 1 ) * 10 Publisher().sendMessage( "update" , amtOfTime) ######################################################################## class MyForm (wx.Frame): #---------------------------------------------------------------------- def __init__ (self): wx.Frame. __init__ (self, None, wx.ID_ANY, "Tutorial" ) # Add a panel so it looks the correct on all platforms panel = wx.Panel(self, wx.ID_ANY) self .displayLbl = wx.StaticText(panel, label= "Amount of time since thread started goes here" ) self .btn = btn = wx.Button(panel, label= "Start Thread" ) btn.Bind(wx.EVT_BUTTON, self . onButton ) sizer = wx.BoxSizer(wx.VERTICAL) sizer.Add( self .displayLbl, 0 , wx.ALL|wx.CENTER, 5 ) sizer.Add(btn, 0 , wx.ALL|wx.CENTER, 5 ) panel.SetSizer(sizer) # create a pubsub receiver Publisher().subscribe( self . updateDisplay , "update" ) #---------------------------------------------------------------------- def onButton (self, event): """ <br/> Runs the thread <br/> """ TestThread () self .displayLbl.SetLabel( "Thread started!" ) btn = event.GetEventObject() btn.Disable() #---------------------------------------------------------------------- def updateDisplay (self, msg): """ <br/> Receives data from thread and updates the display <br/> """ t = msg.data if isinstance (t, int): self .displayLbl.SetLabel( "Time since thread started: %s seconds" % t) else : self .displayLbl.SetLabel( "%s" % t) self .btn.Enable() #---------------------------------------------------------------------- # Run the program if __name__ == "__main__" : app = wx.PySimpleApp() frame = MyForm ().Show() app.MainLoop()
Copy Source | Copy HTML import time import wx from threading import Thread from wx.lib.pubsub import Publisher ######################################################################## class TestThread (Thread): """Test Worker Thread Class.""" #---------------------------------------------------------------------- def __init__ (self): """Init Worker Thread Class.""" Thread. __init__ (self) self .start() # start the thread #---------------------------------------------------------------------- def run (self): """Run Worker Thread.""" # This is the code executing in the new thread. for i in range ( 6 ): time .sleep( 10 ) wx.CallAfter( self . postTime , i) time .sleep( 5 ) wx.CallAfter(Publisher().sendMessage, "update" , "Thread finished!" ) #---------------------------------------------------------------------- def postTime (self, amt): """ <br/> Send time to GUI <br/> """ amtOfTime = (amt + 1 ) * 10 Publisher().sendMessage( "update" , amtOfTime) ######################################################################## class MyForm (wx.Frame): #---------------------------------------------------------------------- def __init__ (self): wx.Frame. __init__ (self, None, wx.ID_ANY, "Tutorial" ) # Add a panel so it looks the correct on all platforms panel = wx.Panel(self, wx.ID_ANY) self .displayLbl = wx.StaticText(panel, label= "Amount of time since thread started goes here" ) self .btn = btn = wx.Button(panel, label= "Start Thread" ) btn.Bind(wx.EVT_BUTTON, self . onButton ) sizer = wx.BoxSizer(wx.VERTICAL) sizer.Add( self .displayLbl, 0 , wx.ALL|wx.CENTER, 5 ) sizer.Add(btn, 0 , wx.ALL|wx.CENTER, 5 ) panel.SetSizer(sizer) # create a pubsub receiver Publisher().subscribe( self . updateDisplay , "update" ) #---------------------------------------------------------------------- def onButton (self, event): """ <br/> Runs the thread <br/> """ TestThread () self .displayLbl.SetLabel( "Thread started!" ) btn = event.GetEventObject() btn.Disable() #---------------------------------------------------------------------- def updateDisplay (self, msg): """ <br/> Receives data from thread and updates the display <br/> """ t = msg.data if isinstance (t, int): self .displayLbl.SetLabel( "Time since thread started: %s seconds" % t) else : self .displayLbl.SetLabel( "%s" % t) self .btn.Enable() #---------------------------------------------------------------------- # Run the program if __name__ == "__main__" : app = wx.PySimpleApp() frame = MyForm ().Show() app.MainLoop()
Copy Source | Copy HTML import time import wx from threading import Thread from wx.lib.pubsub import Publisher ######################################################################## class TestThread (Thread): """Test Worker Thread Class.""" #---------------------------------------------------------------------- def __init__ (self): """Init Worker Thread Class.""" Thread. __init__ (self) self .start() # start the thread #---------------------------------------------------------------------- def run (self): """Run Worker Thread.""" # This is the code executing in the new thread. for i in range ( 6 ): time .sleep( 10 ) wx.CallAfter( self . postTime , i) time .sleep( 5 ) wx.CallAfter(Publisher().sendMessage, "update" , "Thread finished!" ) #---------------------------------------------------------------------- def postTime (self, amt): """ <br/> Send time to GUI <br/> """ amtOfTime = (amt + 1 ) * 10 Publisher().sendMessage( "update" , amtOfTime) ######################################################################## class MyForm (wx.Frame): #---------------------------------------------------------------------- def __init__ (self): wx.Frame. __init__ (self, None, wx.ID_ANY, "Tutorial" ) # Add a panel so it looks the correct on all platforms panel = wx.Panel(self, wx.ID_ANY) self .displayLbl = wx.StaticText(panel, label= "Amount of time since thread started goes here" ) self .btn = btn = wx.Button(panel, label= "Start Thread" ) btn.Bind(wx.EVT_BUTTON, self . onButton ) sizer = wx.BoxSizer(wx.VERTICAL) sizer.Add( self .displayLbl, 0 , wx.ALL|wx.CENTER, 5 ) sizer.Add(btn, 0 , wx.ALL|wx.CENTER, 5 ) panel.SetSizer(sizer) # create a pubsub receiver Publisher().subscribe( self . updateDisplay , "update" ) #---------------------------------------------------------------------- def onButton (self, event): """ <br/> Runs the thread <br/> """ TestThread () self .displayLbl.SetLabel( "Thread started!" ) btn = event.GetEventObject() btn.Disable() #---------------------------------------------------------------------- def updateDisplay (self, msg): """ <br/> Receives data from thread and updates the display <br/> """ t = msg.data if isinstance (t, int): self .displayLbl.SetLabel( "Time since thread started: %s seconds" % t) else : self .displayLbl.SetLabel( "%s" % t) self .btn.Enable() #---------------------------------------------------------------------- # Run the program if __name__ == "__main__" : app = wx.PySimpleApp() frame = MyForm ().Show() app.MainLoop()
Copy Source | Copy HTML import time import wx from threading import Thread from wx.lib.pubsub import Publisher ######################################################################## class TestThread (Thread): """Test Worker Thread Class.""" #---------------------------------------------------------------------- def __init__ (self): """Init Worker Thread Class.""" Thread. __init__ (self) self .start() # start the thread #---------------------------------------------------------------------- def run (self): """Run Worker Thread.""" # This is the code executing in the new thread. for i in range ( 6 ): time .sleep( 10 ) wx.CallAfter( self . postTime , i) time .sleep( 5 ) wx.CallAfter(Publisher().sendMessage, "update" , "Thread finished!" ) #---------------------------------------------------------------------- def postTime (self, amt): """ <br/> Send time to GUI <br/> """ amtOfTime = (amt + 1 ) * 10 Publisher().sendMessage( "update" , amtOfTime) ######################################################################## class MyForm (wx.Frame): #---------------------------------------------------------------------- def __init__ (self): wx.Frame. __init__ (self, None, wx.ID_ANY, "Tutorial" ) # Add a panel so it looks the correct on all platforms panel = wx.Panel(self, wx.ID_ANY) self .displayLbl = wx.StaticText(panel, label= "Amount of time since thread started goes here" ) self .btn = btn = wx.Button(panel, label= "Start Thread" ) btn.Bind(wx.EVT_BUTTON, self . onButton ) sizer = wx.BoxSizer(wx.VERTICAL) sizer.Add( self .displayLbl, 0 , wx.ALL|wx.CENTER, 5 ) sizer.Add(btn, 0 , wx.ALL|wx.CENTER, 5 ) panel.SetSizer(sizer) # create a pubsub receiver Publisher().subscribe( self . updateDisplay , "update" ) #---------------------------------------------------------------------- def onButton (self, event): """ <br/> Runs the thread <br/> """ TestThread () self .displayLbl.SetLabel( "Thread started!" ) btn = event.GetEventObject() btn.Disable() #---------------------------------------------------------------------- def updateDisplay (self, msg): """ <br/> Receives data from thread and updates the display <br/> """ t = msg.data if isinstance (t, int): self .displayLbl.SetLabel( "Time since thread started: %s seconds" % t) else : self .displayLbl.SetLabel( "%s" % t) self .btn.Enable() #---------------------------------------------------------------------- # Run the program if __name__ == "__main__" : app = wx.PySimpleApp() frame = MyForm ().Show() app.MainLoop()
Copy Source | Copy HTML import time import wx from threading import Thread from wx.lib.pubsub import Publisher ######################################################################## class TestThread (Thread): """Test Worker Thread Class.""" #---------------------------------------------------------------------- def __init__ (self): """Init Worker Thread Class.""" Thread. __init__ (self) self .start() # start the thread #---------------------------------------------------------------------- def run (self): """Run Worker Thread.""" # This is the code executing in the new thread. for i in range ( 6 ): time .sleep( 10 ) wx.CallAfter( self . postTime , i) time .sleep( 5 ) wx.CallAfter(Publisher().sendMessage, "update" , "Thread finished!" ) #---------------------------------------------------------------------- def postTime (self, amt): """ <br/> Send time to GUI <br/> """ amtOfTime = (amt + 1 ) * 10 Publisher().sendMessage( "update" , amtOfTime) ######################################################################## class MyForm (wx.Frame): #---------------------------------------------------------------------- def __init__ (self): wx.Frame. __init__ (self, None, wx.ID_ANY, "Tutorial" ) # Add a panel so it looks the correct on all platforms panel = wx.Panel(self, wx.ID_ANY) self .displayLbl = wx.StaticText(panel, label= "Amount of time since thread started goes here" ) self .btn = btn = wx.Button(panel, label= "Start Thread" ) btn.Bind(wx.EVT_BUTTON, self . onButton ) sizer = wx.BoxSizer(wx.VERTICAL) sizer.Add( self .displayLbl, 0 , wx.ALL|wx.CENTER, 5 ) sizer.Add(btn, 0 , wx.ALL|wx.CENTER, 5 ) panel.SetSizer(sizer) # create a pubsub receiver Publisher().subscribe( self . updateDisplay , "update" ) #---------------------------------------------------------------------- def onButton (self, event): """ <br/> Runs the thread <br/> """ TestThread () self .displayLbl.SetLabel( "Thread started!" ) btn = event.GetEventObject() btn.Disable() #---------------------------------------------------------------------- def updateDisplay (self, msg): """ <br/> Receives data from thread and updates the display <br/> """ t = msg.data if isinstance (t, int): self .displayLbl.SetLabel( "Time since thread started: %s seconds" % t) else : self .displayLbl.SetLabel( "%s" % t) self .btn.Enable() #---------------------------------------------------------------------- # Run the program if __name__ == "__main__" : app = wx.PySimpleApp() frame = MyForm ().Show() app.MainLoop()
Copy Source | Copy HTML import time import wx from threading import Thread from wx.lib.pubsub import Publisher ######################################################################## class TestThread (Thread): """Test Worker Thread Class.""" #---------------------------------------------------------------------- def __init__ (self): """Init Worker Thread Class.""" Thread. __init__ (self) self .start() # start the thread #---------------------------------------------------------------------- def run (self): """Run Worker Thread.""" # This is the code executing in the new thread. for i in range ( 6 ): time .sleep( 10 ) wx.CallAfter( self . postTime , i) time .sleep( 5 ) wx.CallAfter(Publisher().sendMessage, "update" , "Thread finished!" ) #---------------------------------------------------------------------- def postTime (self, amt): """ <br/> Send time to GUI <br/> """ amtOfTime = (amt + 1 ) * 10 Publisher().sendMessage( "update" , amtOfTime) ######################################################################## class MyForm (wx.Frame): #---------------------------------------------------------------------- def __init__ (self): wx.Frame. __init__ (self, None, wx.ID_ANY, "Tutorial" ) # Add a panel so it looks the correct on all platforms panel = wx.Panel(self, wx.ID_ANY) self .displayLbl = wx.StaticText(panel, label= "Amount of time since thread started goes here" ) self .btn = btn = wx.Button(panel, label= "Start Thread" ) btn.Bind(wx.EVT_BUTTON, self . onButton ) sizer = wx.BoxSizer(wx.VERTICAL) sizer.Add( self .displayLbl, 0 , wx.ALL|wx.CENTER, 5 ) sizer.Add(btn, 0 , wx.ALL|wx.CENTER, 5 ) panel.SetSizer(sizer) # create a pubsub receiver Publisher().subscribe( self . updateDisplay , "update" ) #---------------------------------------------------------------------- def onButton (self, event): """ <br/> Runs the thread <br/> """ TestThread () self .displayLbl.SetLabel( "Thread started!" ) btn = event.GetEventObject() btn.Disable() #---------------------------------------------------------------------- def updateDisplay (self, msg): """ <br/> Receives data from thread and updates the display <br/> """ t = msg.data if isinstance (t, int): self .displayLbl.SetLabel( "Time since thread started: %s seconds" % t) else : self .displayLbl.SetLabel( "%s" % t) self .btn.Enable() #---------------------------------------------------------------------- # Run the program if __name__ == "__main__" : app = wx.PySimpleApp() frame = MyForm ().Show() app.MainLoop()
Copy Source | Copy HTML import time import wx from threading import Thread from wx.lib.pubsub import Publisher ######################################################################## class TestThread (Thread): """Test Worker Thread Class.""" #---------------------------------------------------------------------- def __init__ (self): """Init Worker Thread Class.""" Thread. __init__ (self) self .start() # start the thread #---------------------------------------------------------------------- def run (self): """Run Worker Thread.""" # This is the code executing in the new thread. for i in range ( 6 ): time .sleep( 10 ) wx.CallAfter( self . postTime , i) time .sleep( 5 ) wx.CallAfter(Publisher().sendMessage, "update" , "Thread finished!" ) #---------------------------------------------------------------------- def postTime (self, amt): """ <br/> Send time to GUI <br/> """ amtOfTime = (amt + 1 ) * 10 Publisher().sendMessage( "update" , amtOfTime) ######################################################################## class MyForm (wx.Frame): #---------------------------------------------------------------------- def __init__ (self): wx.Frame. __init__ (self, None, wx.ID_ANY, "Tutorial" ) # Add a panel so it looks the correct on all platforms panel = wx.Panel(self, wx.ID_ANY) self .displayLbl = wx.StaticText(panel, label= "Amount of time since thread started goes here" ) self .btn = btn = wx.Button(panel, label= "Start Thread" ) btn.Bind(wx.EVT_BUTTON, self . onButton ) sizer = wx.BoxSizer(wx.VERTICAL) sizer.Add( self .displayLbl, 0 , wx.ALL|wx.CENTER, 5 ) sizer.Add(btn, 0 , wx.ALL|wx.CENTER, 5 ) panel.SetSizer(sizer) # create a pubsub receiver Publisher().subscribe( self . updateDisplay , "update" ) #---------------------------------------------------------------------- def onButton (self, event): """ <br/> Runs the thread <br/> """ TestThread () self .displayLbl.SetLabel( "Thread started!" ) btn = event.GetEventObject() btn.Disable() #---------------------------------------------------------------------- def updateDisplay (self, msg): """ <br/> Receives data from thread and updates the display <br/> """ t = msg.data if isinstance (t, int): self .displayLbl.SetLabel( "Time since thread started: %s seconds" % t) else : self .displayLbl.SetLabel( "%s" % t) self .btn.Enable() #---------------------------------------------------------------------- # Run the program if __name__ == "__main__" : app = wx.PySimpleApp() frame = MyForm ().Show() app.MainLoop()
Copy Source | Copy HTML import time import wx from threading import Thread from wx.lib.pubsub import Publisher ######################################################################## class TestThread (Thread): """Test Worker Thread Class.""" #---------------------------------------------------------------------- def __init__ (self): """Init Worker Thread Class.""" Thread. __init__ (self) self .start() # start the thread #---------------------------------------------------------------------- def run (self): """Run Worker Thread.""" # This is the code executing in the new thread. for i in range ( 6 ): time .sleep( 10 ) wx.CallAfter( self . postTime , i) time .sleep( 5 ) wx.CallAfter(Publisher().sendMessage, "update" , "Thread finished!" ) #---------------------------------------------------------------------- def postTime (self, amt): """ <br/> Send time to GUI <br/> """ amtOfTime = (amt + 1 ) * 10 Publisher().sendMessage( "update" , amtOfTime) ######################################################################## class MyForm (wx.Frame): #---------------------------------------------------------------------- def __init__ (self): wx.Frame. __init__ (self, None, wx.ID_ANY, "Tutorial" ) # Add a panel so it looks the correct on all platforms panel = wx.Panel(self, wx.ID_ANY) self .displayLbl = wx.StaticText(panel, label= "Amount of time since thread started goes here" ) self .btn = btn = wx.Button(panel, label= "Start Thread" ) btn.Bind(wx.EVT_BUTTON, self . onButton ) sizer = wx.BoxSizer(wx.VERTICAL) sizer.Add( self .displayLbl, 0 , wx.ALL|wx.CENTER, 5 ) sizer.Add(btn, 0 , wx.ALL|wx.CENTER, 5 ) panel.SetSizer(sizer) # create a pubsub receiver Publisher().subscribe( self . updateDisplay , "update" ) #---------------------------------------------------------------------- def onButton (self, event): """ <br/> Runs the thread <br/> """ TestThread () self .displayLbl.SetLabel( "Thread started!" ) btn = event.GetEventObject() btn.Disable() #---------------------------------------------------------------------- def updateDisplay (self, msg): """ <br/> Receives data from thread and updates the display <br/> """ t = msg.data if isinstance (t, int): self .displayLbl.SetLabel( "Time since thread started: %s seconds" % t) else : self .displayLbl.SetLabel( "%s" % t) self .btn.Enable() #---------------------------------------------------------------------- # Run the program if __name__ == "__main__" : app = wx.PySimpleApp() frame = MyForm ().Show() app.MainLoop()
Copy Source | Copy HTML import time import wx from threading import Thread from wx.lib.pubsub import Publisher ######################################################################## class TestThread (Thread): """Test Worker Thread Class.""" #---------------------------------------------------------------------- def __init__ (self): """Init Worker Thread Class.""" Thread. __init__ (self) self .start() # start the thread #---------------------------------------------------------------------- def run (self): """Run Worker Thread.""" # This is the code executing in the new thread. for i in range ( 6 ): time .sleep( 10 ) wx.CallAfter( self . postTime , i) time .sleep( 5 ) wx.CallAfter(Publisher().sendMessage, "update" , "Thread finished!" ) #---------------------------------------------------------------------- def postTime (self, amt): """ <br/> Send time to GUI <br/> """ amtOfTime = (amt + 1 ) * 10 Publisher().sendMessage( "update" , amtOfTime) ######################################################################## class MyForm (wx.Frame): #---------------------------------------------------------------------- def __init__ (self): wx.Frame. __init__ (self, None, wx.ID_ANY, "Tutorial" ) # Add a panel so it looks the correct on all platforms panel = wx.Panel(self, wx.ID_ANY) self .displayLbl = wx.StaticText(panel, label= "Amount of time since thread started goes here" ) self .btn = btn = wx.Button(panel, label= "Start Thread" ) btn.Bind(wx.EVT_BUTTON, self . onButton ) sizer = wx.BoxSizer(wx.VERTICAL) sizer.Add( self .displayLbl, 0 , wx.ALL|wx.CENTER, 5 ) sizer.Add(btn, 0 , wx.ALL|wx.CENTER, 5 ) panel.SetSizer(sizer) # create a pubsub receiver Publisher().subscribe( self . updateDisplay , "update" ) #---------------------------------------------------------------------- def onButton (self, event): """ <br/> Runs the thread <br/> """ TestThread () self .displayLbl.SetLabel( "Thread started!" ) btn = event.GetEventObject() btn.Disable() #---------------------------------------------------------------------- def updateDisplay (self, msg): """ <br/> Receives data from thread and updates the display <br/> """ t = msg.data if isinstance (t, int): self .displayLbl.SetLabel( "Time since thread started: %s seconds" % t) else : self .displayLbl.SetLabel( "%s" % t) self .btn.Enable() #---------------------------------------------------------------------- # Run the program if __name__ == "__main__" : app = wx.PySimpleApp() frame = MyForm ().Show() app.MainLoop()
Copy Source | Copy HTML import time import wx from threading import Thread from wx.lib.pubsub import Publisher ######################################################################## class TestThread (Thread): """Test Worker Thread Class.""" #---------------------------------------------------------------------- def __init__ (self): """Init Worker Thread Class.""" Thread. __init__ (self) self .start() # start the thread #---------------------------------------------------------------------- def run (self): """Run Worker Thread.""" # This is the code executing in the new thread. for i in range ( 6 ): time .sleep( 10 ) wx.CallAfter( self . postTime , i) time .sleep( 5 ) wx.CallAfter(Publisher().sendMessage, "update" , "Thread finished!" ) #---------------------------------------------------------------------- def postTime (self, amt): """ <br/> Send time to GUI <br/> """ amtOfTime = (amt + 1 ) * 10 Publisher().sendMessage( "update" , amtOfTime) ######################################################################## class MyForm (wx.Frame): #---------------------------------------------------------------------- def __init__ (self): wx.Frame. __init__ (self, None, wx.ID_ANY, "Tutorial" ) # Add a panel so it looks the correct on all platforms panel = wx.Panel(self, wx.ID_ANY) self .displayLbl = wx.StaticText(panel, label= "Amount of time since thread started goes here" ) self .btn = btn = wx.Button(panel, label= "Start Thread" ) btn.Bind(wx.EVT_BUTTON, self . onButton ) sizer = wx.BoxSizer(wx.VERTICAL) sizer.Add( self .displayLbl, 0 , wx.ALL|wx.CENTER, 5 ) sizer.Add(btn, 0 , wx.ALL|wx.CENTER, 5 ) panel.SetSizer(sizer) # create a pubsub receiver Publisher().subscribe( self . updateDisplay , "update" ) #---------------------------------------------------------------------- def onButton (self, event): """ <br/> Runs the thread <br/> """ TestThread () self .displayLbl.SetLabel( "Thread started!" ) btn = event.GetEventObject() btn.Disable() #---------------------------------------------------------------------- def updateDisplay (self, msg): """ <br/> Receives data from thread and updates the display <br/> """ t = msg.data if isinstance (t, int): self .displayLbl.SetLabel( "Time since thread started: %s seconds" % t) else : self .displayLbl.SetLabel( "%s" % t) self .btn.Enable() #---------------------------------------------------------------------- # Run the program if __name__ == "__main__" : app = wx.PySimpleApp() frame = MyForm ().Show() app.MainLoop()
Copy Source | Copy HTML import time import wx from threading import Thread from wx.lib.pubsub import Publisher ######################################################################## class TestThread (Thread): """Test Worker Thread Class.""" #---------------------------------------------------------------------- def __init__ (self): """Init Worker Thread Class.""" Thread. __init__ (self) self .start() # start the thread #---------------------------------------------------------------------- def run (self): """Run Worker Thread.""" # This is the code executing in the new thread. for i in range ( 6 ): time .sleep( 10 ) wx.CallAfter( self . postTime , i) time .sleep( 5 ) wx.CallAfter(Publisher().sendMessage, "update" , "Thread finished!" ) #---------------------------------------------------------------------- def postTime (self, amt): """ <br/> Send time to GUI <br/> """ amtOfTime = (amt + 1 ) * 10 Publisher().sendMessage( "update" , amtOfTime) ######################################################################## class MyForm (wx.Frame): #---------------------------------------------------------------------- def __init__ (self): wx.Frame. __init__ (self, None, wx.ID_ANY, "Tutorial" ) # Add a panel so it looks the correct on all platforms panel = wx.Panel(self, wx.ID_ANY) self .displayLbl = wx.StaticText(panel, label= "Amount of time since thread started goes here" ) self .btn = btn = wx.Button(panel, label= "Start Thread" ) btn.Bind(wx.EVT_BUTTON, self . onButton ) sizer = wx.BoxSizer(wx.VERTICAL) sizer.Add( self .displayLbl, 0 , wx.ALL|wx.CENTER, 5 ) sizer.Add(btn, 0 , wx.ALL|wx.CENTER, 5 ) panel.SetSizer(sizer) # create a pubsub receiver Publisher().subscribe( self . updateDisplay , "update" ) #---------------------------------------------------------------------- def onButton (self, event): """ <br/> Runs the thread <br/> """ TestThread () self .displayLbl.SetLabel( "Thread started!" ) btn = event.GetEventObject() btn.Disable() #---------------------------------------------------------------------- def updateDisplay (self, msg): """ <br/> Receives data from thread and updates the display <br/> """ t = msg.data if isinstance (t, int): self .displayLbl.SetLabel( "Time since thread started: %s seconds" % t) else : self .displayLbl.SetLabel( "%s" % t) self .btn.Enable() #---------------------------------------------------------------------- # Run the program if __name__ == "__main__" : app = wx.PySimpleApp() frame = MyForm ().Show() app.MainLoop()
Copy Source | Copy HTML import time import wx from threading import Thread from wx.lib.pubsub import Publisher ######################################################################## class TestThread (Thread): """Test Worker Thread Class.""" #---------------------------------------------------------------------- def __init__ (self): """Init Worker Thread Class.""" Thread. __init__ (self) self .start() # start the thread #---------------------------------------------------------------------- def run (self): """Run Worker Thread.""" # This is the code executing in the new thread. for i in range ( 6 ): time .sleep( 10 ) wx.CallAfter( self . postTime , i) time .sleep( 5 ) wx.CallAfter(Publisher().sendMessage, "update" , "Thread finished!" ) #---------------------------------------------------------------------- def postTime (self, amt): """ <br/> Send time to GUI <br/> """ amtOfTime = (amt + 1 ) * 10 Publisher().sendMessage( "update" , amtOfTime) ######################################################################## class MyForm (wx.Frame): #---------------------------------------------------------------------- def __init__ (self): wx.Frame. __init__ (self, None, wx.ID_ANY, "Tutorial" ) # Add a panel so it looks the correct on all platforms panel = wx.Panel(self, wx.ID_ANY) self .displayLbl = wx.StaticText(panel, label= "Amount of time since thread started goes here" ) self .btn = btn = wx.Button(panel, label= "Start Thread" ) btn.Bind(wx.EVT_BUTTON, self . onButton ) sizer = wx.BoxSizer(wx.VERTICAL) sizer.Add( self .displayLbl, 0 , wx.ALL|wx.CENTER, 5 ) sizer.Add(btn, 0 , wx.ALL|wx.CENTER, 5 ) panel.SetSizer(sizer) # create a pubsub receiver Publisher().subscribe( self . updateDisplay , "update" ) #---------------------------------------------------------------------- def onButton (self, event): """ <br/> Runs the thread <br/> """ TestThread () self .displayLbl.SetLabel( "Thread started!" ) btn = event.GetEventObject() btn.Disable() #---------------------------------------------------------------------- def updateDisplay (self, msg): """ <br/> Receives data from thread and updates the display <br/> """ t = msg.data if isinstance (t, int): self .displayLbl.SetLabel( "Time since thread started: %s seconds" % t) else : self .displayLbl.SetLabel( "%s" % t) self .btn.Enable() #---------------------------------------------------------------------- # Run the program if __name__ == "__main__" : app = wx.PySimpleApp() frame = MyForm ().Show() app.MainLoop()
Copy Source | Copy HTML import time import wx from threading import Thread from wx.lib.pubsub import Publisher ######################################################################## class TestThread (Thread): """Test Worker Thread Class.""" #---------------------------------------------------------------------- def __init__ (self): """Init Worker Thread Class.""" Thread. __init__ (self) self .start() # start the thread #---------------------------------------------------------------------- def run (self): """Run Worker Thread.""" # This is the code executing in the new thread. for i in range ( 6 ): time .sleep( 10 ) wx.CallAfter( self . postTime , i) time .sleep( 5 ) wx.CallAfter(Publisher().sendMessage, "update" , "Thread finished!" ) #---------------------------------------------------------------------- def postTime (self, amt): """ <br/> Send time to GUI <br/> """ amtOfTime = (amt + 1 ) * 10 Publisher().sendMessage( "update" , amtOfTime) ######################################################################## class MyForm (wx.Frame): #---------------------------------------------------------------------- def __init__ (self): wx.Frame. __init__ (self, None, wx.ID_ANY, "Tutorial" ) # Add a panel so it looks the correct on all platforms panel = wx.Panel(self, wx.ID_ANY) self .displayLbl = wx.StaticText(panel, label= "Amount of time since thread started goes here" ) self .btn = btn = wx.Button(panel, label= "Start Thread" ) btn.Bind(wx.EVT_BUTTON, self . onButton ) sizer = wx.BoxSizer(wx.VERTICAL) sizer.Add( self .displayLbl, 0 , wx.ALL|wx.CENTER, 5 ) sizer.Add(btn, 0 , wx.ALL|wx.CENTER, 5 ) panel.SetSizer(sizer) # create a pubsub receiver Publisher().subscribe( self . updateDisplay , "update" ) #---------------------------------------------------------------------- def onButton (self, event): """ <br/> Runs the thread <br/> """ TestThread () self .displayLbl.SetLabel( "Thread started!" ) btn = event.GetEventObject() btn.Disable() #---------------------------------------------------------------------- def updateDisplay (self, msg): """ <br/> Receives data from thread and updates the display <br/> """ t = msg.data if isinstance (t, int): self .displayLbl.SetLabel( "Time since thread started: %s seconds" % t) else : self .displayLbl.SetLabel( "%s" % t) self .btn.Enable() #---------------------------------------------------------------------- # Run the program if __name__ == "__main__" : app = wx.PySimpleApp() frame = MyForm ().Show() app.MainLoop()
Copy Source | Copy HTML import time import wx from threading import Thread from wx.lib.pubsub import Publisher ######################################################################## class TestThread (Thread): """Test Worker Thread Class.""" #---------------------------------------------------------------------- def __init__ (self): """Init Worker Thread Class.""" Thread. __init__ (self) self .start() # start the thread #---------------------------------------------------------------------- def run (self): """Run Worker Thread.""" # This is the code executing in the new thread. for i in range ( 6 ): time .sleep( 10 ) wx.CallAfter( self . postTime , i) time .sleep( 5 ) wx.CallAfter(Publisher().sendMessage, "update" , "Thread finished!" ) #---------------------------------------------------------------------- def postTime (self, amt): """ <br/> Send time to GUI <br/> """ amtOfTime = (amt + 1 ) * 10 Publisher().sendMessage( "update" , amtOfTime) ######################################################################## class MyForm (wx.Frame): #---------------------------------------------------------------------- def __init__ (self): wx.Frame. __init__ (self, None, wx.ID_ANY, "Tutorial" ) # Add a panel so it looks the correct on all platforms panel = wx.Panel(self, wx.ID_ANY) self .displayLbl = wx.StaticText(panel, label= "Amount of time since thread started goes here" ) self .btn = btn = wx.Button(panel, label= "Start Thread" ) btn.Bind(wx.EVT_BUTTON, self . onButton ) sizer = wx.BoxSizer(wx.VERTICAL) sizer.Add( self .displayLbl, 0 , wx.ALL|wx.CENTER, 5 ) sizer.Add(btn, 0 , wx.ALL|wx.CENTER, 5 ) panel.SetSizer(sizer) # create a pubsub receiver Publisher().subscribe( self . updateDisplay , "update" ) #---------------------------------------------------------------------- def onButton (self, event): """ <br/> Runs the thread <br/> """ TestThread () self .displayLbl.SetLabel( "Thread started!" ) btn = event.GetEventObject() btn.Disable() #---------------------------------------------------------------------- def updateDisplay (self, msg): """ <br/> Receives data from thread and updates the display <br/> """ t = msg.data if isinstance (t, int): self .displayLbl.SetLabel( "Time since thread started: %s seconds" % t) else : self .displayLbl.SetLabel( "%s" % t) self .btn.Enable() #---------------------------------------------------------------------- # Run the program if __name__ == "__main__" : app = wx.PySimpleApp() frame = MyForm ().Show() app.MainLoop()
Copy Source | Copy HTML import time import wx from threading import Thread from wx.lib.pubsub import Publisher ######################################################################## class TestThread (Thread): """Test Worker Thread Class.""" #---------------------------------------------------------------------- def __init__ (self): """Init Worker Thread Class.""" Thread. __init__ (self) self .start() # start the thread #---------------------------------------------------------------------- def run (self): """Run Worker Thread.""" # This is the code executing in the new thread. for i in range ( 6 ): time .sleep( 10 ) wx.CallAfter( self . postTime , i) time .sleep( 5 ) wx.CallAfter(Publisher().sendMessage, "update" , "Thread finished!" ) #---------------------------------------------------------------------- def postTime (self, amt): """ <br/> Send time to GUI <br/> """ amtOfTime = (amt + 1 ) * 10 Publisher().sendMessage( "update" , amtOfTime) ######################################################################## class MyForm (wx.Frame): #---------------------------------------------------------------------- def __init__ (self): wx.Frame. __init__ (self, None, wx.ID_ANY, "Tutorial" ) # Add a panel so it looks the correct on all platforms panel = wx.Panel(self, wx.ID_ANY) self .displayLbl = wx.StaticText(panel, label= "Amount of time since thread started goes here" ) self .btn = btn = wx.Button(panel, label= "Start Thread" ) btn.Bind(wx.EVT_BUTTON, self . onButton ) sizer = wx.BoxSizer(wx.VERTICAL) sizer.Add( self .displayLbl, 0 , wx.ALL|wx.CENTER, 5 ) sizer.Add(btn, 0 , wx.ALL|wx.CENTER, 5 ) panel.SetSizer(sizer) # create a pubsub receiver Publisher().subscribe( self . updateDisplay , "update" ) #---------------------------------------------------------------------- def onButton (self, event): """ <br/> Runs the thread <br/> """ TestThread () self .displayLbl.SetLabel( "Thread started!" ) btn = event.GetEventObject() btn.Disable() #---------------------------------------------------------------------- def updateDisplay (self, msg): """ <br/> Receives data from thread and updates the display <br/> """ t = msg.data if isinstance (t, int): self .displayLbl.SetLabel( "Time since thread started: %s seconds" % t) else : self .displayLbl.SetLabel( "%s" % t) self .btn.Enable() #---------------------------------------------------------------------- # Run the program if __name__ == "__main__" : app = wx.PySimpleApp() frame = MyForm ().Show() app.MainLoop()
Copy Source | Copy HTML import time import wx from threading import Thread from wx.lib.pubsub import Publisher ######################################################################## class TestThread (Thread): """Test Worker Thread Class.""" #---------------------------------------------------------------------- def __init__ (self): """Init Worker Thread Class.""" Thread. __init__ (self) self .start() # start the thread #---------------------------------------------------------------------- def run (self): """Run Worker Thread.""" # This is the code executing in the new thread. for i in range ( 6 ): time .sleep( 10 ) wx.CallAfter( self . postTime , i) time .sleep( 5 ) wx.CallAfter(Publisher().sendMessage, "update" , "Thread finished!" ) #---------------------------------------------------------------------- def postTime (self, amt): """ <br/> Send time to GUI <br/> """ amtOfTime = (amt + 1 ) * 10 Publisher().sendMessage( "update" , amtOfTime) ######################################################################## class MyForm (wx.Frame): #---------------------------------------------------------------------- def __init__ (self): wx.Frame. __init__ (self, None, wx.ID_ANY, "Tutorial" ) # Add a panel so it looks the correct on all platforms panel = wx.Panel(self, wx.ID_ANY) self .displayLbl = wx.StaticText(panel, label= "Amount of time since thread started goes here" ) self .btn = btn = wx.Button(panel, label= "Start Thread" ) btn.Bind(wx.EVT_BUTTON, self . onButton ) sizer = wx.BoxSizer(wx.VERTICAL) sizer.Add( self .displayLbl, 0 , wx.ALL|wx.CENTER, 5 ) sizer.Add(btn, 0 , wx.ALL|wx.CENTER, 5 ) panel.SetSizer(sizer) # create a pubsub receiver Publisher().subscribe( self . updateDisplay , "update" ) #---------------------------------------------------------------------- def onButton (self, event): """ <br/> Runs the thread <br/> """ TestThread () self .displayLbl.SetLabel( "Thread started!" ) btn = event.GetEventObject() btn.Disable() #---------------------------------------------------------------------- def updateDisplay (self, msg): """ <br/> Receives data from thread and updates the display <br/> """ t = msg.data if isinstance (t, int): self .displayLbl.SetLabel( "Time since thread started: %s seconds" % t) else : self .displayLbl.SetLabel( "%s" % t) self .btn.Enable() #---------------------------------------------------------------------- # Run the program if __name__ == "__main__" : app = wx.PySimpleApp() frame = MyForm ().Show() app.MainLoop()
рдпрд╣ рдЙрджрд╛рд╣рд░рдг рд▓рдВрдмреЗ рд╕рдордп рддрдХ рдЪрд▓рдиреЗ рд╡рд╛рд▓реА рдирдХрд▓реА рдкреНрд░рдХреНрд░рд┐рдпрд╛ рдмрдирд╛рдиреЗ рдХреЗ рд▓рд┐рдП рд╕рдордп рдореЙрдбреНрдпреВрд▓ рдХрд╛ рдЙрдкрдпреЛрдЧ рдХрд░рддрд╛ рд╣реИред рд╣рд╛рд▓рд╛рдБрдХрд┐, рдЖрдк рдЗрд╕рдХреЗ рдмрдЬрд╛рдп рдХреБрдЫ рдЕрдзрд┐рдХ рдЙрдкрдпреЛрдЧреА рдХрд╛ рдЙрдкрдпреЛрдЧ рдХрд░ рд╕рдХрддреЗ рд╣реИрдВред рдПрдХ рд╡рд╛рд╕реНрддрд╡рд┐рдХ рдЙрджрд╛рд╣рд░рдг рдореЗрдВ, рдореИрдВ рдПрдбреЛрдм рд░реАрдбрд░ рдЦреЛрд▓рдиреЗ рдФрд░ рдкреНрд░рд┐рдВрдЯ рдХрд░рдиреЗ рдХреЗ рд▓рд┐рдП рдПрдХ рдкреАрдбреАрдПрдл рднреЗрдЬрдиреЗ рдХреЗ рд▓рд┐рдП рдПрдХ рд╕реНрдЯреНрд░реАрдо рдХрд╛ рдЙрдкрдпреЛрдЧ рдХрд░рддрд╛ рд╣реВрдВред рдпрд╣ рдСрдкрд░реЗрд╢рди рдирд┐рд░рд░реНрдердХ рд▓рдЧ рд╕рдХрддрд╛ рд╣реИ, рд▓реЗрдХрд┐рди рдЬрдм рдореИрдВ рдереНрд░реЗрдбреНрд╕ рдХрд╛ рдЙрдкрдпреЛрдЧ рдирд╣реАрдВ рдХрд░рддрд╛ рд╣реВрдВ, рддреЛ рдореЗрд░реЗ рдЖрд╡реЗрджрди рдореЗрдВ рдкреНрд░рд┐рдВрдЯ рдмрдЯрди рджрдмрд╛рдпрд╛ рдЬрд╛рддрд╛ рд╣реИ рдЬрдм рддрдХ рдХрд┐ рджрд╕реНрддрд╛рд╡реЗрдЬрд╝ рдкреНрд░рд┐рдВрдЯрд░ рдкрд░ рдирд╣реАрдВ рднреЗрдЬрд╛ рдЬрд╛рддрд╛ рд╣реИ рдФрд░ рдХрд╛рд░реНрд░рд╡рд╛рдИ рдкреВрд░реА рд╣реЛрдиреЗ рддрдХ рдЗрдВрдЯрд░рдлрд╝реЗрд╕ рд╕реНрдерд┐рд░ рд░рд╣рддрд╛ рд╣реИред рдпрд╣рд╛рдВ рддрдХ тАЛтАЛрдХрд┐ рдПрдХ рдпрд╛ рджреЛ рдЙрдкрдпреЛрдЧрдХрд░реНрддрд╛ рдХреЗ рд▓рд┐рдП рдЙрд▓реНрд▓реЗрдЦрдиреАрдп рд╣реИрдВ!
рдПрдХ рддрд░реАрдХрд╛ рдпрд╛ рджреВрд╕рд░рд╛, рдЖрдЗрдП рджреЗрдЦреЗрдВ рдХрд┐ рдпрд╣ рдХреИрд╕реЗ рдХрд╛рдо рдХрд░рддрд╛ рд╣реИред рд╣рдорд╛рд░реЗ рдереНрд░реЗрдб рдХреНрд▓рд╛рд╕ (рдиреАрдЪреЗ рд╡рд░реНрдгрд┐рдд) рдореЗрдВ, рд╣рдордиреЗ рдЖрд╡рд╢реНрдпрдХрддрд╛рдиреБрд╕рд╛рд░ "рд░рди" рд╡рд┐рдзрд┐ рдХреЛ рдлрд┐рд░ рд╕реЗ рдкрд░рд┐рднрд╛рд╖рд┐рдд рдХрд┐рдпрд╛ред рдпрд╣ рдзрд╛рдЧрд╛ рддрдм рд╢реБрд░реВ рд╣реЛрддрд╛ рд╣реИ рдЬрдм рд╣рдо рдЗрд╕реЗ рдмрдирд╛рддреЗ рд╣реИрдВ рдХреНрдпреЛрдВрдХрд┐ рд╣рдорд╛рд░реЗ рдкрд╛рд╕ __init__ рд╡рд┐рдзрд┐ рдореЗрдВ "self.start ()" рд╣реИред "рд░рди" рд╡рд┐рдзрд┐ рдореЗрдВ, рд╣рдо рдкреНрд░рддреНрдпреЗрдХ 10 рд╕реЗрдХрдВрдб рдореЗрдВ рд▓реВрдк рдХрд░рддреЗ рд╣реИрдВ, 6 рдмрд╛рд░ wx.CallAfter рдФрд░ PubSub рдХрд╛ рдЙрдкрдпреЛрдЧ рдХрд░рдХреЗ рд╣рдорд╛рд░реЗ рдЗрдВрдЯрд░рдлрд╝реЗрд╕ рдХреЗ рд▓рд┐рдП рдПрдХ рдЕрдкрдбреЗрдЯ рд╣реЛрддрд╛ рд╣реИред рдЬрдм рдЪрдХреНрд░ рдкреВрд░рд╛ рд╣реЛ рдЬрд╛рддрд╛ рд╣реИ, рддреЛ рд╣рдо рдЙрдкрдпреЛрдЧрдХрд░реНрддрд╛ рдХреЛ рдЗрд╕рдХреЗ рдмрд╛рд░реЗ рдореЗрдВ рд╕реВрдЪрд┐рдд рдХрд░рдиреЗ рдХреЗ рд▓рд┐рдП рд╣рдорд╛рд░реЗ рдЖрд╡реЗрджрди рдХреЛ рдЕрдВрддрд┐рдо рд╕рдВрджреЗрд╢ рднреЗрдЬрддреЗ рд╣реИрдВред
Copy Source | Copy HTML
- ################################################## ######################
- рдХреНрд▓рд╛рд╕ рдЯреЗрд╕реНрдЯрд╣реНрд░реЗрдб (рдереНрд░реЗрдб):
- "" "рдЯреЗрд╕реНрдЯ рд╡рд░реНрдХрд░ рдереНрд░реЗрдб рдХреНрд▓рд╛рд╕ред" ""
- # ------------------------------------------------- ---------------------
- def __init__ (рд╕реНрд╡):
- "" рдЗрдирд┐рдЯ рд╡рд░реНрдХрд░ рдереНрд░реЗрдб рдХреНрд▓рд╛рд╕ред ""
- рдереНрд░реЗрдбред __in__ (рд╕реНрд╡)
- self .start () # рдереНрд░реЗрдб рдкреНрд░рд╛рд░рдВрдн рдХрд░реЗрдВ
- # ------------------------------------------------- ---------------------
- рдбреАрдИрдПрдл рд░рди (рд╕реНрд╡):
- "" "рд╡рд░реНрдХрд░ рдереНрд░реЗрдб рдЪрд▓рд╛рдПрдБред" "
- # рдпрд╣ рдирдП рдереНрд░реЗрдб рдореЗрдВ рдХреЛрдб рдирд┐рд╖реНрдкрд╛рджрд┐рдд рд╣реИред
- рдореИрдВ рд╕реАрдорд╛ рдореЗрдВ ( 6 ):
- рд╕рдордпред рд╕реЛ ( 10 )
- wx.CallAfter ( рд╕реНрд╡ ред рдкреЛрд╕реНрдЯрдЯрд╛рдЗрдо , i)
- рд╕рдордпред рд╕реНрд▓реАрдк ( 5 )
- wx.CallAfter (рдкреНрд░рдХрд╛рд╢рдХ) (ред sendMessage, "update" , "рдереНрд░реЗрдб рд╕рдорд╛рдкреНрдд!"
- # ------------------------------------------------- ---------------------
- рдбреАрдИрдЯреА рдкреЛрд╕реНрдЯрдЯрд╛рдЗрдо (рд╕реНрд╡рдпрдВ, рдПрдордЯреА ):
- "" " <br/> GUI рдХреЛ рд╕рдордп рднреЗрдЬреЗрдВ <br/> " "
- amtOfTime = (amt + 1 ) * резреж
- рдкреНрд░рдХрд╛рд╢рдХ ()ред SendMessage ( "рдЕрдкрдбреЗрдЯ" , amtOfTime)
рд╣рдорд╛рд░реЗ рдХреЛрдб рдореЗрдВ, рдПрдХ рдмрдЯрди рдХрд╛ рдЙрдкрдпреЛрдЧ рдХрд░рдХреЗ рдПрдХ рдереНрд░реЗрдб рд╢реБрд░реВ рдХрд┐рдпрд╛ рдЬрд╛рддрд╛ рд╣реИред рдЙрд╕реА рд╕рдордп, рд╣рдо рдЗрд╕реЗ рдирд┐рд╖реНрдХреНрд░рд┐рдп рдХрд░ рджреЗрддреЗ рд╣реИрдВ рддрд╛рдХрд┐ рдЧрд▓рддреА рд╕реЗ рдЕрддрд┐рд░рд┐рдХреНрдд рдзрд╛рдЧреЗ рд╢реБрд░реВ рди рдХрд░реЗрдВ, рдЕрдиреНрдпрдерд╛ рд╡рд┐рднрд┐рдиреНрди рдереНрд░реЗрдбреНрд╕ рд╕реЗ рд╡рд┐рднрд┐рдиреНрди рдЧрдВрджреЗ рд╕рдВрджреЗрд╢ рджрд┐рдЦрд╛рдИ рджреЗрдВрдЧреЗ рдФрд░ рдпрд╣ рдХреЗрд╡рд▓ рд╣рдореЗрдВ рднреНрд░рдорд┐рдд рдХрд░реЗрдЧрд╛ред рд╣рд╛рд▓рд╛рдВрдХрд┐ рдЗрд╕реЗ рдЕрдЪреНрдЫреЗ рдЙрдкрдпреЛрдЧ рдХреЗ рд▓рд┐рдП рдЗрд╕реНрддреЗрдорд╛рд▓ рдХрд┐рдпрд╛ рдЬрд╛ рд╕рдХрддрд╛ рд╣реИред рдЖрдк рд╕реНрдЯреНрд░реАрдо рдХреЗ рдкреАрдЖрдИрдбреА тАЛтАЛрдХреЛ рдпрд╣ рдЬрд╛рдирдиреЗ рдХреЗ рд▓рд┐рдП рджрд┐рдЦрд╛ рд╕рдХрддреЗ рд╣реИрдВ рдХрд┐ рдХреМрди рд╕рд╛ рд╣реИ рдФрд░ рдПрдХ рд╕реНрдХреНрд░реЙрд▓рд┐рдВрдЧ рд▓рд╛рдЗрди рдореЗрдВ рд╕реВрдЪрдирд╛ рдХреЛ рдПрдХ рд╕рд╛рде рдХрдИ рдзрд╛рд░рд╛рдУрдВ рдХреЗ рд╕рдВрдЪрд╛рд▓рди рдХреЗ рд▓рд┐рдП рдкреНрд░рджрд░реНрд╢рд┐рдд рдХрд░рддрд╛ рд╣реИред
рд╣рдорд╛рд░реЗ рдХреЛрдб рдХрд╛ рдЕрдВрддрд┐рдо рджрд┐рд▓рдЪрд╕реНрдк рд╣рд┐рд╕реНрд╕рд╛ PubSub рд╣реИ, рдЬреЛ рдИрд╡реЗрдВрдЯ рдФрд░ рдЗрд╡реЗрдВрдЯ рд╣реИрдВрдбрд▓рд░ рдХреЛ рд╕реНрд╡реАрдХрд╛рд░ рдХрд░рддрд╛ рд╣реИ:
Copy Source | Copy HTML
- рдбреАрдИрдПрдлрд╝ рдЕрдкрдбреЗрдЯ рдбрд┐рд╕реЗрдкреНрд▓реЗ (рд╕реНрд╡рдпрдВ, рд╕рдВрджреЗрд╢):
- "" " <br/> рдереНрд░реЗрдб рд╕реЗ рдбреЗрдЯрд╛ рдкреНрд░рд╛рдкреНрдд рдХрд░рддрд╛ рд╣реИ рдФрд░ рдбрд┐рд╕реНрдкреНрд▓реЗ рдХреЛ рдЕрдкрдбреЗрдЯ рдХрд░рддрд╛ рд╣реИ <br/> " "
- t = msg.data
- рдпрджрд┐ рдкреНрд░рддрд┐рдкреВрд░реНрддрд┐ (рдЯреА, рдЗрдВрдЯ):
- рд╕реНрд╡рдпрдВ .displayLbl.SetLabel ( "рдереНрд░реЗрдб рд╢реБрд░реВ рд╣реЛрдиреЗ рдХрд╛ рд╕рдордп:% s рд╕реЗрдХрдВрдб" % t)
- рдФрд░ :
- рд╕реНрд╡рдпрдВ .displayLbl.SetLabel ( "% s" % t)
- рд╕реНрд╡ .btn.Enable ()
рдЗрд╕рд▓рд┐рдП, рд╣рдо рд╕реНрдЯреНрд░реАрдо рд╕реЗ рд╕рдВрджреЗрд╢ рдирд┐рдХрд╛рд▓рддреЗ рд╣реИрдВ рдФрд░ рдЕрдкрдирд╛ рдЗрдВрдЯрд░рдлрд╝реЗрд╕ рдЕрдкрдбреЗрдЯ рдХрд░рддреЗ рд╣реИрдВред рдРрд╕рд╛ рдХрд░рдиреЗ рдореЗрдВ, рд╣рдо рдЙрдкрдпреЛрдЧрдХрд░реНрддрд╛ рдХреЛ рджрд┐рдЦрд╛рдиреЗ рдХреЗ рд▓рд┐рдП рдирд┐рд░реНрдзрд╛рд░рд┐рдд рдХрд░рдиреЗ рдХреЗ рд▓рд┐рдП рд╕рдВрджреЗрд╢ рдХреЗ рдбреЗрдЯрд╛ рдкреНрд░рдХрд╛рд░ рдХреА рдЬрд╛рдВрдЪ рдХрд░рддреЗ рд╣реИрдВред рдЕрдм рдПрдХ рд╕реНрддрд░ рдиреАрдЪреЗ рдЬрд╛рддреЗ рд╣реИрдВ рдФрд░ wx.PostEvent рдХреЗ рд╕рд╛рде рднреА рдРрд╕рд╛ рд╣реА рдХрд░рдиреЗ рдХреА рдХреЛрд╢рд┐рд╢ рдХрд░рддреЗ рд╣реИрдВред
рдзрд╛рд░рд╛рдПрдБ рдФрд░ wx.PostEvent
рдиреАрдЪреЗ рджрд┐рдпрд╛ рдЧрдпрд╛ рдХреЛрдб рдЗрд╕
wxPython wiki рдЙрджрд╛рд╣рд░рдг рдкрд░ рдЖрдзрд╛рд░рд┐рдд рд╣реИред рдпрд╣ рдХреЛрдб рдкрд╣рд▓реЗ рджрд┐рдП рдЧрдП рдХреА рддреБрд▓рдирд╛ рдореЗрдВ рдереЛрдбрд╝рд╛ рдЕрдзрд┐рдХ рдЬрдЯрд┐рд▓ рд╣реИ, рд▓реЗрдХрд┐рди рдореБрдЭреЗ рд▓рдЧрддрд╛ рд╣реИ рдХрд┐ рдЗрд╕реЗ рд╕рдордЭрдирд╛ рдореБрд╢реНрдХрд┐рд▓ рдирд╣реАрдВ рд╣реИред
Copy Source | Copy HTML
- рдЖрдпрд╛рдд рд╕рдордп
- рдЖрдпрд╛рдд wx
- рдЗрдореНрдкреЛрд░реНрдЯ рдереНрд░реЗрдбрд┐рдВрдЧ рд╕реЗ
- # рдзрд╛рдЧрд╛ рдкреВрд░рд╛ рд╣реЛрдиреЗ рдХреЗ рд▓рд┐рдП рдЕрдзрд┐рд╕реВрдЪрдирд╛ рдШрдЯрдирд╛ рдХреЛ рдкрд░рд┐рднрд╛рд╖рд┐рдд рдХрд░реЗрдВ
- EVT_RESULT_ID = wx.NewId ()
- EVT_RESULT рдХреЛ рд╣рд░рд╛рдпрд╛ (рдЬреАрдд, рджреБрд░реНрдЧрдВрдз ):
- "" "рдкрд░рд┐рдгрд╛рдо рдШрдЯрдирд╛ рдХреЛ рдкрд░рд┐рднрд╛рд╖рд┐рдд рдХрд░реЗрдВред" ""
- win.Connect (- 1 , - 1 , EVT_RESULT_ID, func)
- рд╡рд░реНрдЧ рдкрд░рд┐рдгрд╛рдо (wx.PyEvent):
- "" "рдордирдорд╛рдирд╛ рдкрд░рд┐рдгрд╛рдо рдбреЗрдЯрд╛ рд▓реЗ рдЬрд╛рдиреЗ рдХреЗ рд▓рд┐рдП рд╕рд░рд▓ рдШрдЯрдирд╛ред" "
- def __init__ (рд╕реНрд╡, рдбреЗрдЯрд╛):
- "" "Init Result Eventред" "
- wx.PyEventред __in__ (рд╕реНрд╡)
- рд╕реНрд╡рдпрдВ .SEEventType (EVT_RESULT_ID)
- рд╕реНрд╡ .рдбрд╛рдЯрд╛ = рдбреЗрдЯрд╛
- ################################################## ######################
- рдХреНрд▓рд╛рд╕ рдЯреЗрд╕реНрдЯрд╣реНрд░реЗрдб (рдереНрд░реЗрдб):
- "" "рдЯреЗрд╕реНрдЯ рд╡рд░реНрдХрд░ рдереНрд░реЗрдб рдХреНрд▓рд╛рд╕ред" ""
- # ------------------------------------------------- ---------------------
- def __init__ (рд╕реНрд╡, wxObject):
- "" рдЗрдирд┐рдЯ рд╡рд░реНрдХрд░ рдереНрд░реЗрдб рдХреНрд▓рд╛рд╕ред ""
- рдереНрд░реЗрдбред __in__ (рд╕реНрд╡)
- self .wxObject = wxObject
- self .start () # рдереНрд░реЗрдб рдкреНрд░рд╛рд░рдВрдн рдХрд░реЗрдВ
- # ------------------------------------------------- ---------------------
- рдбреАрдИрдПрдл рд░рди (рд╕реНрд╡):
- "" "рд╡рд░реНрдХрд░ рдереНрд░реЗрдб рдЪрд▓рд╛рдПрдБред" "
- # рдпрд╣ рдирдП рдереНрд░реЗрдб рдореЗрдВ рдХреЛрдб рдирд┐рд╖реНрдкрд╛рджрд┐рдд рд╣реИред
- рдореИрдВ рд╕реАрдорд╛ рдореЗрдВ ( 6 ):
- рд╕рдордпред рд╕реЛ ( 10 )
- amtOfTime = (i + 1 ) * 10
- wx.PostEvent ( рд╕реНрд╡рдпрдВ .wxObject, рдкрд░рд┐рдгрд╛рдо (amtOfTime))
- рд╕рдордпред рд╕реНрд▓реАрдк ( 5 )
- wx.PostEvent ( рдЖрддреНрдо .wxObject, рдкрд░рд┐рдгрд╛рдо) ( "рдереНрд░реЗрдб рд╕рдорд╛рдкреНрдд!" ) !
- ################################################## ######################
- рд╡рд░реНрдЧ MyForm (wx.Frame):
- # ------------------------------------------------- ---------------------
- def __init__ (рд╕реНрд╡):
- wx.Frameред __in__ (рд╕реНрд╡рдпрдВ, рдХреЛрдИ рдирд╣реАрдВ, wx.ID_ANY, "рдЯреНрдпреВрдЯреЛрд░рд┐рдпрд▓" )
- # рдПрдХ рдкреИрдирд▓ рдЬреЛрдбрд╝реЗрдВ рддрд╛рдХрд┐ рдпрд╣ рд╕рднреА рдкреНрд▓реЗрдЯрдлрд╛рд░реНрдореЛрдВ рдкрд░ рд╕рд╣реА рд▓рдЧреЗ
- рдкреИрдирд▓ = wx.Panel (рд╕реНрд╡рдпрдВ, wx.ID_ANY)
- рд╕реНрд╡ред displayLbl = wx.StaticText (рдкреИрдирд▓, рд▓реЗрдмрд▓ = "рдереНрд░реЗрдб рд╢реБрд░реВ рд╣реЛрдиреЗ рдХреЗ рдмрд╛рдж рдХреА рд╕рдордп рдХреА рдорд╛рддреНрд░рд╛ рдпрд╣рд╛рдБ" )
- рдЖрддреНрдо .btn = btn = wx.Button (рдкреИрдирд▓, рд▓реЗрдмрд▓ = "рдереНрд░реЗрдб рдкреНрд░рд╛рд░рдВрдн рдХрд░реЗрдВ" )
- btn.Bind (wx.EVT_BUTTON, рд╕реНрд╡ ред рдСрдирдмрдЯрди )
- sizer = wx.BoxSizer (wx.VERTICAL)
- sizer.Add ( рд╕реНрд╡рдпрдВ .displayLbl, 0 , wx.ALL | wx.CENTER, 5 )
- sizer.Add (btn, 0 , wx.ALL | wx.CENTER, 5 )
- рдкреИрдирд▓ред
- # рдХрд┐рд╕реА рднреА рд╡рд░реНрдХрд░ рдереНрд░реЗрдб рд░рд┐рдЬрд▓реНрдЯ рдХреЗ рд▓рд┐рдП рдЗрд╡реЗрдВрдЯ рд╣реИрдВрдбрд▓рд░ рд╕реЗрдЯ рдХрд░реЗрдВ
- EVT_RESULT (рд╕реНрд╡рдпрдВ, рд╕реНрд╡ ред рдЕрдкрдбреЗрдЯрдбрд┐рд╕рдкреНрд▓реЗ )
- # ------------------------------------------------- ---------------------
- рдмреАрдЯ рдСрдирдЯрди (рд╕реНрд╡рдпрдВ, рдШрдЯрдирд╛):
- "" " <br/> рдереНрд░реЗрдб рдЪрд▓рд╛рддрд╛ рд╣реИ <br/> " "
- рдЯреЗрд╕реНрдЯрдереНрд░реЗрдб (рд╕реНрд╡)
- рд╕реНрд╡рдпрдВ .displayLbl.SetLabel ( "рдереНрд░реЗрдб рдкреНрд░рд╛рд░рдВрдн!"
- btn = event.GetEventObject ()
- btn.Disable ()
- # ------------------------------------------------- ---------------------
- рдбреАрдИрдПрдлрд╝ рдЕрдкрдбреЗрдЯ рдбрд┐рд╕реЗрдкреНрд▓реЗ (рд╕реНрд╡рдпрдВ, рд╕рдВрджреЗрд╢):
- "" " <br/> рдереНрд░реЗрдб рд╕реЗ рдбреЗрдЯрд╛ рдкреНрд░рд╛рдкреНрдд рдХрд░рддрд╛ рд╣реИ рдФрд░ рдбрд┐рд╕реНрдкреНрд▓реЗ рдХреЛ рдЕрдкрдбреЗрдЯ рдХрд░рддрд╛ рд╣реИ <br/> " "
- t = msg.data
- рдпрджрд┐ рдкреНрд░рддрд┐рдкреВрд░реНрддрд┐ (рдЯреА, рдЗрдВрдЯ):
- рд╕реНрд╡рдпрдВ .displayLbl.SetLabel ( "рдереНрд░реЗрдб рд╢реБрд░реВ рд╣реЛрдиреЗ рдХрд╛ рд╕рдордп:% s рд╕реЗрдХрдВрдб" % t)
- рдФрд░ :
- рд╕реНрд╡рдпрдВ .displayLbl.SetLabel ( "% s" % t)
- рд╕реНрд╡ .btn.Enable ()
- # ------------------------------------------------- ---------------------
- # рдкреНрд░реЛрдЧреНрд░рд╛рдо рдЪрд▓рд╛рдПрдВ
- рдЕрдЧрд░ __name__ == "__main__" :
- app = wx.PySimpleApp ()
- рдлреНрд░реЗрдо = MyForm () .Show ()
- app.MainLoop ()
рдЪрд▓реЛ рдЗрд╕реЗ рдереЛрдбрд╝рд╛ рд▓реЗ рд▓реЛред рдореЗрд░реЗ рд▓рд┐рдП рдкрд╣рд▓реЗ рддреАрди рднрд╛рдЧ рд╕рдмрд╕реЗ рдЕрдзрд┐рдХ рднреНрд░рдорд┐рдд рдХрд░рдиреЗ рд╡рд╛рд▓реЗ рд╣реИрдВ:
Copy Source | Copy HTML
- # рдзрд╛рдЧрд╛ рдкреВрд░рд╛ рд╣реЛрдиреЗ рдХреЗ рд▓рд┐рдП рдЕрдзрд┐рд╕реВрдЪрдирд╛ рдШрдЯрдирд╛ рдХреЛ рдкрд░рд┐рднрд╛рд╖рд┐рдд рдХрд░реЗрдВ
- EVT_RESULT_ID = wx.NewId ()
- EVT_RESULT рдХреЛ рд╣рд░рд╛рдпрд╛ (рдЬреАрдд, рджреБрд░реНрдЧрдВрдз ):
- "" "рдкрд░рд┐рдгрд╛рдо рдШрдЯрдирд╛ рдХреЛ рдкрд░рд┐рднрд╛рд╖рд┐рдд рдХрд░реЗрдВред" ""
- win.Connect (- 1 , - 1 , EVT_RESULT_ID, func)
- рд╡рд░реНрдЧ рдкрд░рд┐рдгрд╛рдо (wx.PyEvent):
- "" "рдордирдорд╛рдирд╛ рдкрд░рд┐рдгрд╛рдо рдбреЗрдЯрд╛ рд▓реЗ рдЬрд╛рдиреЗ рдХреЗ рд▓рд┐рдП рд╕рд░рд▓ рдШрдЯрдирд╛ред" "
- def __init__ (рд╕реНрд╡, рдбреЗрдЯрд╛):
- "" "Init Result Eventред" "
- wx.PyEventред __in__ (рд╕реНрд╡)
- рд╕реНрд╡рдпрдВ .SEEventType (EVT_RESULT_ID)
- рд╕реНрд╡ .рдбрд╛рдЯрд╛ = рдбреЗрдЯрд╛
EVT_RESULT_ID рдпрд╣рд╛рдВ рдХреБрдВрдЬреА рд╣реИ, рдЬреЛ рдХрд┐ EVT_RESULT рдлрд╝рдВрдХреНрд╢рди рдХреЛ рдкрд░рд┐рдгрд╛рдо рд╡рд░реНрдЧ рдХреЗ рд╕рд╛рде рдЬреЛрдбрд╝рддреА рд╣реИред EVT_RESULT рдлрд╝рдВрдХреНрд╢рди рдХрд╛ рдЙрдкрдпреЛрдЧ рдХрд░рдХреЗ, рд╣рдо рдИрд╡реЗрдВрдЯ рд╣реИрдВрдбрд▓рд░ рд╕реЗрдЯ рдХрд░рддреЗ рд╣реИрдВ рдЬреЛ рд╣рдорд╛рд░реА рд╕реНрдЯреНрд░реАрдо рдЬреЗрдирд░реЗрдЯ рдХрд░рддрд╛ рд╣реИред Wx.PostEvent рдлрд╝рдВрдХреНрд╢рди рдкрд░рд┐рдгрд╛рдо рдХреЛ рд╕реНрдЯреНрд░реАрдо рд╕реЗ рдкрд░рд┐рдгрд╛рдо рдкрд░рд┐рдгрд╛рдо рд╡рд░реНрдЧ рддрдХ рд▓реЗ рдЬрд╛рддрд╛ рд╣реИ, рдЬреЛ рддрдм рдкрд╣рд▓реЗ рд╕реЗ рд╕реНрдерд╛рдкрд┐рдд рдИрд╡реЗрдВрдЯ рд╣реИрдВрдбрд▓рд░ рджреНрд╡рд╛рд░рд╛ рд╕рдВрд╕рд╛рдзрд┐рдд рдХрд┐рдпрд╛ рдЬрд╛рддрд╛ рд╣реИред
рд╣рдорд╛рд░реА рдЯреЗрд╕реНрдЯрдереНрд░реЗрдб рдХреНрд▓рд╛рд╕ рд▓рдЧрднрдЧ рд╡реИрд╕реА рд╣реА рдХрд╛рдо рдХрд░рддреА рд╣реИ рдЬреИрд╕реА рд╣рдордиреЗ рдкрд╣рд▓реЗ рдХреА рдереА, рд╕рд┐рд╡рд╛рдп рдЗрд╕рдХреЗ рдХрд┐ рд╣рдордиреЗ PubSub рдХреЗ рдмрдЬрд╛рдп wx.PostEvent рдХрд╛ рдЗрд╕реНрддреЗрдорд╛рд▓ рдХрд┐рдпрд╛ред рдЗрдВрдЯрд░рдлрд╝реЗрд╕ рдХреЛ рдЕрдкрдбреЗрдЯ рдХрд░рдиреЗ рд╡рд╛рд▓реЗ рд╣рдорд╛рд░реЗ рдИрд╡реЗрдВрдЯ рд╣реИрдВрдбрд▓рд░ рдХрд╛ рдХреЛрдб рдирд╣реАрдВ рдмрджрд▓рд╛ рд╣реИред
рдирд┐рд╖реНрдХрд░реНрд╖
рдореБрдЭреЗ рдЙрдореНрдореАрдж рд╣реИ рдХрд┐ рдЕрдм рдЖрдк рдЬрд╛рдирддреЗ рд╣реИрдВ рдХрд┐ рдЕрдкрдиреЗ wxPython рдХрд╛рд░реНрдпрдХреНрд░рдореЛрдВ рдореЗрдВ рдореВрд▓ рдкреНрд░рд╡рд╛рд╣ рд╡рд┐рдзрд┐рдпреЛрдВ рдХрд╛ рдЙрдкрдпреЛрдЧ рдХреИрд╕реЗ рдХрд░реЗрдВред рдзрд╛рдЧреЗ рдХреЗ рд╕рд╛рде рдХрд╛рдо рдХрд░рдиреЗ рдХреЗ рд▓рд┐рдП рдХрдИ рдЕрдиреНрдп рддрд░реАрдХреЗ рд╣реИрдВ, рд▓реЗрдХрд┐рди рд╡реЗ рдЗрд╕ рд▓реЗрдЦ рдореЗрдВ рдирд╣реАрдВ рдорд╛рдиреЗ рдЬрд╛рддреЗ рд╣реИрдВ, рдЙрджрд╛рд╣рд░рдг рдХреЗ рд▓рд┐рдП wx.Yield рдпрд╛ Queuesред рд╕реМрднрд╛рдЧреНрдп рд╕реЗ, wxPython рд╡рд┐рдХреА рдЗрди рд╡рд┐рд╖рдпреЛрдВ рдХреЛ рдЕрдЪреНрдЫреА рддрд░рд╣ рд╕реЗ рдХрд╡рд░ рдХрд░рддрд╛ рд╣реИ, рдЗрд╕рд▓рд┐рдП рдпрджрд┐ рдЖрдк рдЗрди рд╡рд┐рдзрд┐рдпреЛрдВ рдореЗрдВ рд░реБрдЪрд┐ рд░рдЦрддреЗ рд╣реИрдВ, рддреЛ рдиреАрдЪреЗ рджрд┐рдП рдЧрдП рд▓рд┐рдВрдХ рдХреА рдЬрд╛рдВрдЪ рдХрд░рдирд╛ рд╕реБрдирд┐рд╢реНрдЪрд┐рдд рдХрд░реЗрдВред
рдЕрддрд┐рд░рд┐рдХреНрдд рд╕рд╛рдордЧреНрд░реА