简体   繁体   中英

Python threading, new thread gets stuck

I'm trying to write a python application with a gui, and I'm having trouble with python's threading package.

import pygtk
pygtk.require('2.0')
import gtk
import threading
import time

class gui:
    def main(self):
        print "starting gui"
        gtk.main()

class logic:
    def __call__(self):
        time.sleep(1)
        print "did logic"

if __name__ == "__main__":
    threading.Thread(None, logic()).start()
    gui().main()

Outputs:

starting gui

The logic never happens. Why? How can I fix this?

I dealt with this problem for the longest of times, here's where you'll find a solution:

http://faq.pygtk.org/index.py?req=show&file=faq20.006.htp

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM