import tkinter as tk
class Timer:
def __init__(self):
self.root = tk.Tk()
self.message = tk.StringVar()
self.message.set("Test")
label = tk.Label(textvariable=self.message, font=('Helvetica', 48))
label.pack()
self.count = 0
def update(self):
self.count += 1
self.message.set(str(self.count))
# self.label.configure(text=label_txt)
self.root.after(1000, self.update)
def main(self):
self.root.after(1000, self.update) # "Test"を描画させるために1秒後にupdateを呼ぶ
self.root.mainloop() # 描画処理が始まり、初期設定した"Test"が描画される
app = Timer() # インスタンス生成:速やかに終わらせる
app.main() # メインループ処理:描画やイベント処理を行う
More than 1 year has passed since last update.
Register as a new user and use Qiita more conveniently
- You get articles that match your needs
- You can efficiently read back useful information
- You can use dark theme