【发布时间】:2017-10-30 05:08:30
【问题描述】:
以下代码不适用于 python3.5 (RuntimeError: Calling Tcl from different appartment) 但它在 python 2.7 上运行良好 很难知道问题的原因以及如何解决。
import tkinter
import threading
class MyTkApp(threading.Thread):
def __init__(self):
self.root=tkinter.Tk()
self.s = tkinter.StringVar()
self.s.set('Foo')
l = tkinter.Label(self.root,textvariable=self.s)
l.pack()
threading.Thread.__init__(self)
def run(self):
self.root.mainloop()
app = MyTkApp()
app.start()
【问题讨论】:
标签: python-3.x tkinter tcl python-multithreading