pu369com

python——tkinter图形化界面及threading多线程

# coding:utf-8
from tkinter import *
from tkinter.scrolledtext import ScrolledText  # 文本滚动条
import threading
import time


def count(i):
    for k in range(1, 100 + 1):
        text.insert(END, '第' + str(i) + '线程count:  ' + str(k) + '\n')
        time.sleep(1)


def fun():
    for i in range(1, 5 + 1):
        th = threading.Thread(target=count, args=(i,))
        th.daemon = True  # 守护线程
        th.start()

root = Tk()
root.title('九日王朝')  # 窗口标题
root.geometry('+600+100')  # 窗口呈现位置
text = ScrolledText(root, font=('微软雅黑', 10), fg='blue')
text.grid()
button = Button(root, text='屠龙宝刀 点击就送', font=('微软雅黑', 10), command=fun)
button.grid()
root.mainloop()

  

参考:https://www.cnblogs.com/monsteryang/p/6592380.html

posted on 2023-04-11 18:36  pu369com  阅读(162)  评论(0编辑  收藏  举报

导航