如何def run ()在 tkinter 視窗中一一顯示列印陳述句(位于函式下)。我使用了 msgbox,但是用戶必須單擊“確定”才能讓其他VL2.py腳本執行,我不想要這個我只想在視窗上顯示列印陳述句并自動繼續執行。不與用戶互動。

from tkinter import *
import tkinter as tk
import os
def run():
print('Processing')
os.system('VL.py')
print("First Vlookup is done!")
os.system('VL2.py')
print("Second Vlookup is doen!")
print('Done!')
screen = tk.Tk()
screen.title("Generate weekly report")
screen.geometry("300x320")
instruction = Label(text='Click "Generate"', fg = 'black',)
instruction.pack()
click_me = Button(text = 'Generate', fg ='black', bg = 'light gray', command = run)
click_me.place(x=130, y= 280)
screen.mainloop()
uj5u.com熱心網友回復:
您可以更改標簽中的文本。
像這樣
def run(observer_label: tk.Label):
observer_label.config(text="Processing")
os.system('VL.py')
observer_label.config(text="First Vlookup is done!")
....
....
click_me = Button(text = 'Generate', fg ='black', bg = 'light gray', command = lambda *args: run(instruction))
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/425918.html
