文字を数秒おきに表示するGUIを組みたいです。RegularCheck()が数秒おきに呼び出されます。
1 ラベル定義
2 ラベル表示
3 1秒スリープ
4 ラベル消す
5 1に戻る
実行しても全く文字が表示されません。
何が原因なのでしょうか??解決方法も教えてほしいです。
よろしくお願いします
import time import tkinter as tk import tkinter root =tk.Tk() def RegularCheck(): label1 = tkinter.Label(root, text="Text on the screen", font=('Times New Roman', '80'), fg="black", bg="white") label1.place( x = 0, y = 0 ) time.sleep(1) label1.destroy() root.after(1000,RegularCheck) RegularCheck() root.mainloop()
質問返信1 追加コード
import tkinter as tk import tkinter import time def test(): label1 = tkinter.Label( root, text="Text on the screen", font=('Times New Roman', '80'), fg="black", bg="white") label1.place(x = 0, y = 0) time.sleep(2) print(label1.winfo_ismapped()) label1.pack_forget() time.sleep(2) if __name__ == '__main__': root =tk.Tk() def RegularCheck(): test() root.after(1000, RegularCheck) RegularCheck() root.mainloop()

回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2022/03/03 12:59
2022/03/03 13:02
2022/03/03 13:33
2022/03/03 14:02
2022/03/04 05:05