|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
root = Tk()
listbox = Listbox(root)
listbox.pack(fill=BOTH, expand=True)
for i in range(10):
listbox.insert(END, str(i))
mainloop() #mainloop()会接管主程序,请问如何让mainloop()之后的程序接着跑?
print('窗口创建完成')
改造成多线程
- import tkinter as tk
- import threading
- def xiancheng1():
- root = tk.Tk()
- listbox = tk.Listbox(root)
- listbox.pack(fill=tk.BOTH, expand=True)
- for i in range(10):
- listbox.insert(tk.END, str(i))
- tk.mainloop() #mainloop()会接管主程序,请问如何让mainloop()之后的程序接着跑?
- def xiancheng2():
- print('窗口创建完成')
- if __name__ == '__main__':
- t1=threading.Thread(target=xiancheng1)
- t1.start()
- t2=threading.Thread(target=xiancheng2)
- t2.start()
复制代码
|
|