Run pyQT GUI main app in seperate Thread

前端 未结 1 1423
醉酒成梦
醉酒成梦 2020-12-10 08:51

I am trying to add a PyQt GUI console in my already established application. But the PyQt GUI blocks the whole application making it unable to do rest of the work. I tried u

相关标签:
1条回答
  • 2020-12-10 09:35

    One way of doing this is

    import threading
    
    def main()
          app = QtGui.QApplication(sys.argv)
          ex = Start_GUI()
          app.exec_()  #<---------- code blocks over here !
    
    #After running the GUI, continue the rest of the application task
    
    t = threading.Thread(target=main)
    t.daemon = True
    t.start()
    
    doThis = do_Thread("doThis")
    doThis.start()
    doThat = do_Thread("doThat")
    doThat.start()
    

    this will thread your main application to begin with, and let you carry on with all the other stuff you want to do after in the code below.

    0 讨论(0)
提交回复
热议问题