如何在python中的tkinter上应用多线程?

时间:2016-07-06 15:48:58

标签: python multithreading tkinter

您好我在python3上学习tkinter并且我试图在tkinter上使用多线程来打开一些基于tkinter的窗口,但它似乎只能打开第一个窗口而第二个窗口只在关闭之后出现第一个窗口。我使用多线程是为了避免被跟随的窗口被前一个阻塞,但它似乎仍然发生了。这是我的代码的一部分,如果发生了什么事情我用if语句替换: 来自tkinter import * #GUI窗口

import os
import _thread

top = Tk()
top.title("Test")

def pressbutton(count):
    if count <= 10:
        print(count)
        count += 1
        if count < 10:
            _thread.start_new_thread(pressbutton,(count,))
        if something happened:
            os.system("python t1.py")
        if something happened:
            os.system("python t2.py")

startButton =Button(top, text="Start", command=lambda: pressbutton(0))
startButton.grid(column=0, row=1)

t1.py和t2.py是两个也使用tkinter构建的python文件。我想要的是有几个t1和t2窗口,但只有一个出现。

0 个答案:

没有答案