--threading wxpython learning

In order to avoid the program is running, you can not do anything, even moving a window or close the action will simply stuck, requiring the use of multi-threading.

class Mythread(threading.Thread):
  def __init__(self,window):
    super(Mythread,self).__init__()
    self.window = window
    #self.flag = threading.Event()
    #self.flag.clear() #set flag False

  def run(self):
    self.window.run()

  def stop(self):
    #os._exit(0)
    self.Close()

Then Frame inside
DEF ButtonStart (Self, Event):
  self.job = Mythread (Self)
  self.job.start () # calls to Mythread in the run method


If you want to open the program execution, the job can be written in the main function
IF __name__ == '__main__':
  App = MyApp ()
  Frame = MyFrame (title = 'the Log', size = (750,500))
  frame.Show ()
  job myThread = (Frame)
  job.start ()
  app.MainLoop ()

Guess you like

Origin www.cnblogs.com/xia-dong/p/11718036.html