zoukankan      html  css  js  c++  java
  • wxpython 学习之 --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()

    然后在Frame里面
    def ButtonStart(self,event):
      self.job = Mythread(self)
      self.job.start() #会调用到Mythread里的run方法


    如果想打开程序就执行,可以将job写在main函数里
    if __name__ == '__main__':
      app = MyApp()
      frame = MyFrame(title='Log',size=(750,500))
      frame.Show()
      job=Mythread(frame)
      job.start()
      app.MainLoop()

  • 相关阅读:
    JSOI2010 满汉全席
    LNOI2014 LCA
    BZOJ3689 异或之
    Codeforces Round #553 div.2
    AHOI2013 差异
    SDOI2016 生成魔咒
    NOI2006 最大获利
    没有过的题QAQ
    NOI2014 动物园
    HDU4622 Reincarnation
  • 原文地址:https://www.cnblogs.com/xia-dong/p/11718036.html
Copyright © 2011-2022 走看看