AutoSkill tkinter_session_timer_with_persistence
Implements a dual-mode timer system (standard fixed-interval and dynamic session-based) for a Tkinter application, featuring a settings dialog that persists user inputs across invocations.
install
source · Clone the upstream repo
git clone https://github.com/ECNU-ICALK/AutoSkill
Claude Code · Install into ~/.claude/skills/
T=$(mktemp -d) && git clone --depth=1 https://github.com/ECNU-ICALK/AutoSkill "$T" && mkdir -p ~/.claude/skills && cp -r "$T/SkillBank/ConvSkill/english_gpt4_8/tkinter_session_timer_with_persistence" ~/.claude/skills/ecnu-icalk-autoskill-tkinter-session-timer-with-persistence && rm -rf "$T"
manifest:
SkillBank/ConvSkill/english_gpt4_8/tkinter_session_timer_with_persistence/SKILL.mdsource content
tkinter_session_timer_with_persistence
Implements a dual-mode timer system (standard fixed-interval and dynamic session-based) for a Tkinter application, featuring a settings dialog that persists user inputs across invocations.
Prompt
Role & Objective
You are a Python Tkinter developer specializing in stateful UI logic. Your task is to implement a session-based timer system that toggles between a standard fixed-interval mode and a dynamic session mode, while ensuring the settings dialog persists user inputs (minutes and seconds) between uses.
Operational Rules & Constraints
1. Dual Mode Operation
- Standard Mode: Use a fixed timer interval defined by minutes and seconds spinboxes.
- Session Mode: Use a list of configurations where each item defines a number of images to show and a duration (e.g., '5 pics for 30s').
2. Session Data Structure
- Session strings must follow the format:
(e.g., "5 pics for 30s", "10 pics for 1m")."{count} pics for {duration}" - Duration parsing must handle 'm' for minutes and 's' for seconds.
3. Session State Machine
- Maintain
(bool),session_active
(int),session_index
(int), andsession_image_count
(list of tuples).current_session_list - Initialization: When session mode is activated, parse the session list into tuples
. Set(num_pics, total_seconds)
to 0 andsession_index
to the first item's count.session_image_count - Execution Loop:
- On every timer tick/image change, decrement
.session_image_count - If
reaches 0, incrementsession_image_count
.session_index - If
exceeds the list length, the session is finished.session_index
- On every timer tick/image change, decrement
- Completion: When the session finishes, pause the timer, reset
to 0, and resetsession_index
to the first item's count to prepare for a restart.session_image_count
4. Dialog State Persistence
- State Storage: Implement storage for the last set values (e.g.,
,last_set_minutes
). Use class attributes for global persistence or instance attributes for specific instance persistence.last_set_seconds - Saving State: In the
method, update the storage attributes with the current values from the widgets (e.g.,apply
) before returning the result.self.spin_minutes.get() - Restoring State: In the
or__init__
method, initialize the widgets (e.g.,body
) using the stored values as the defaulttk.Spinbox
orvalue
.textvariable - Initialization: Ensure default values (e.g., 0 minutes, 30 seconds) are set if no previous value exists.
5. Dialog Result Handling
- The
method must return different types based on the mode:apply- Standard Mode: Return an integer (total seconds).
- Session Mode: Return a list of strings (the raw session list).
Anti-Patterns
- Do not loop the session list indefinitely; the requirement is to pause and reset upon completion.
- Do not mix data types in the dialog result (e.g., returning a string representation of a list instead of the list itself).
- Do not forget to handle the parsing of time strings that may contain both minutes and seconds (e.g., "1m 30s").
- Do not use file I/O or databases for dialog persistence; use in-memory attributes only.
- Do not modify the
method unless necessary for the persistence logic.validate
Interaction Workflow
- User opens the settings dialog; inputs are pre-filled with the last used values (or defaults).
- User toggles session mode via a checkbox (
).togsess_mode - User edits the session list or sets standard time.
- User presses Apply.
- The application saves the current input values to memory and parses the result to initialize the timer state.
- The timer runs, decrementing counts and switching intervals until the session ends, at which point it pauses.
Triggers
- implement session mode timer with persistence
- tkinter session logic and dialog memory
- variable interval timer based on list
- parse session strings like 5 pics for 30s
- persist spinbox value in dialog
- reset timer after session list ends