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()

  • 相关阅读:
    20150316--TP-01
    20150314--TP-02
    20150314--TP-01
    20150313+微信-全
    表单/iframe与video标签
    图像/超链接标签
    HTML列表与表格
    JAVA新的一天
    MySQL常用函数
    php基础--来自网页转载
  • 原文地址:https://www.cnblogs.com/xia-dong/p/11718036.html
Copyright © 2011-2022 走看看