當前位置:首頁 » 編程語言 » 停止運行python腳本

停止運行python腳本

發布時間: 2025-07-22 15:06:48

1. python腳本如何添加啟動和停止按鈕

用tkinter的button組件。
設定好字體大小size(int類型),在循環內部(以while舉例)加組件:

xunhuan=1 # 控制循環的開始與結束
# 定義開始循環
def start():
global xunhuan

xunhuan = 1

# 結束
def end():
global xunhuan

xunhuan = 0

size=(字的大小)
# 現在導庫
inport tkinter as tk # 輸入方便
window = tk.Tk()
s = tk.Button(window, text = "開始" , command = start) # 開始按鈕
e = tk.Button(window , text = "停止" , command = end) # 結束按鈕
# 繪制按鈕
s.pack()
e.pack()
# 下面是循環
while True:
if xunhuan:

...(循環內部要做的事)

window.mainloop() # 在tkinter中,這行代碼一定要加

熱點內容
java返回this 發布:2025-10-20 08:28:16 瀏覽:588
製作腳本網站 發布:2025-10-20 08:17:34 瀏覽:883
python中的init方法 發布:2025-10-20 08:17:33 瀏覽:576
圖案密碼什麼意思 發布:2025-10-20 08:16:56 瀏覽:762
怎麼清理微信視頻緩存 發布:2025-10-20 08:12:37 瀏覽:679
c語言編譯器怎麼看執行過程 發布:2025-10-20 08:00:32 瀏覽:1008
郵箱如何填寫發信伺服器 發布:2025-10-20 07:45:27 瀏覽:252
shell腳本入門案例 發布:2025-10-20 07:44:45 瀏覽:110
怎麼上傳照片瀏覽上傳 發布:2025-10-20 07:44:03 瀏覽:801
python股票數據獲取 發布:2025-10-20 07:39:44 瀏覽:707