@
lyric 非常感谢,如你猜测,参考了官方的pygtk和 线程使用例子,修改了下,搞定
import threading
import time
import gobject
import gtk
gobject.threads_init()
class MyThread(threading.Thread):
def __init__(self, label):
super(MyThread, self).__init__()
self.label = label
self.quit = False
def update_label(self, counter):
import xmlrpclib
‘’‘
这里做 通过xmlrpc 获取数据
’‘’
return False
def run(self):
counter = 0
gobject.idle_add(self.update_label, counter)
w = gtk.Window()
l = gtk.Label()
w.add(l)
w.show_all()
w.connect("destroy", lambda _: gtk.main_quit())
t = MyThread(l)
t.start()
gtk.main()
t.quit = True