0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

自動 連続 ポモドーロタイマー Tkinter

Last updated at Posted at 2025-05-16
作れるもん
[TkinterやPyQt]
データ入力ツールボタンで面倒な処理を一発実行

家計簿アプリ支出を自動で整理

通知付きTodoアプリ 
import tkinter as tk
from threading import Thread
import time

class MultiTimer:
    def __init__(self, root):
        self.root = root
        self.root.title("連続タイマー")

        self.label = tk.Label(root, text="停止中", font=("Arial", 18))
        self.label.pack(pady=10)

        self.start_button = tk.Button(root, text="スタート", command=self.start)
        self.start_button.pack(pady=5)

        self.stop_button = tk.Button(root, text="ストップ", command=self.stop)
        self.stop_button.pack(pady=5)

        self.running = False

    def update(self, text):
        self.label.config(text=text)

    def countdown(self, minutes, label):
        for i in range(minutes * 60, -1, -1):
            if not self.running:
                return
            m, s = divmod(i, 60)
            self.update(f"{label}: {m:02d}:{s:02d}")
            time.sleep(1)

    def run_timers(self):
        for i in range(12):
            if not self.running: break
            self.countdown(30, f"作業({i+1}/12)")
            if not self.running: break
            self.countdown(15, f"休憩({i+1}/12)")

        for i in range(10):
            if not self.running: break
            self.countdown(5, f"短作業({i+1}/10)")
            if not self.running: break
            self.countdown(3, f"短休憩({i+1}/10)")

        self.update("終了!")

    def start(self):
        if not self.running:
            self.running = True
            Thread(target=self.run_timers).start()

    def stop(self):
        self.running = False
        self.update("停止中")

root = tk.Tk()
app = MultiTimer(root)
root.mainloop()
ボタンを押したら、calculate関数が処理されるようセット
feet_entry.focus()
root.bind("<Return>", calculate)

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?