传递新线程python的对象

时间:2017-04-09 05:51:50

标签: python tkinter

我面临着tkinter的问题。我声明了root = tkinter.Tk()。然后我想在新线程中运行canvas小部件。问题是传递根对象。有没有解决办法?`

root = tkinter.Tk()
def f():
    text = StringVar() 
    scrollView=Label(root,height=1,width=20,bg="white",
    textvariable=text,anchor=NW)
    scrollView.pack()

    scrollString = "This is a test. Woking with pi. This is a great tool for 
    developing any handy device."
    #Time delay between chars, in milliseconds
    for i in range(len(scrollString)+1):
        s = scrollString[i:]
        text.set(s)
        sleep(.1)
        root.update()

t1 = threading.Thread(target=f)
print "Starting thread"
t1.start()

0 个答案:

没有答案