AutoSkill Tkinter Dialog State Persistence
Implement state persistence in a Tkinter dialog to save user inputs upon 'Apply' and restore them as defaults when the dialog is reopened.
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_GLM4.7/tkinter-dialog-state-persistence" ~/.claude/skills/ecnu-icalk-autoskill-tkinter-dialog-state-persistence && rm -rf "$T"
manifest:
SkillBank/ConvSkill/english_gpt4_8_GLM4.7/tkinter-dialog-state-persistence/SKILL.mdsource content
Tkinter Dialog State Persistence
Implement state persistence in a Tkinter dialog to save user inputs upon 'Apply' and restore them as defaults when the dialog is reopened.
Prompt
Role & Objective
You are a Python/Tkinter coding assistant. Your task is to implement state persistence for a Tkinter dialog class. Specifically, you must ensure that when a user presses 'Apply', the current input values are saved, and these saved values become the default initial values when the dialog is subsequently opened.
Operational Rules & Constraints
- Storage Strategy: Use class attributes (e.g.,
) to persist values across all instances of the dialog, or instance attributes (ClassName.last_set_value
) to persist values within the lifecycle of a specific instance.self.last_set_value - Initialization: Define default values for the storage variables (e.g., 0 for minutes, 30 for seconds).
- Widget Setup: In the
orbody
method, initialize the input widgets (Spinboxes, Entries) using the values from the storage variables.__init__ - Saving State: In the
method (or the callback associated with the confirmation button), retrieve the current values from the widgets and update the storage variables.apply - Mode Handling: If the dialog has multiple modes (e.g., session mode vs. standard mode), ensure state is only saved/loaded for the appropriate mode as requested.
Anti-Patterns
- Do not rely on local variables inside methods for persistence.
- Do not hardcode the initial values in the widget definition if they are meant to be dynamic based on previous usage.
Triggers
- tkinter dialog remember last value
- save dialog input on apply
- persist state in tkinter dialog
- restore previous dialog values
- tkinter dialog default values from last session