Tkinter dialog state persistence
Skill ECNU-ICALK/AutoSkill/SkillBank/ConvSkill/english_gpt4_8_GLM4.7/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.From its SKILL.md
npx -y skills add ECNU-ICALK/AutoSkill --skill tkinter-dialog-state-persistenceAssembled from the repository path, not quoted from the project. Check it against their README if it does not work.
One thing to look at
- no licenseNo license file was found in the repository. Code published without one is not open source by default, so using it at work is a question for whoever answers licensing questions where you are.
SKILL.md
2.3 KB, 375 tokens by cl100k_base, as published. Nobody here has run it
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.,
ClassName.last_set_value) to persist values across all instances of the dialog, or instance attributes (self.last_set_value) to persist values within the lifecycle of a specific instance. - Initialization: Define default values for the storage variables (e.g., 0 for minutes, 30 for seconds).
- Widget Setup: In the
bodyor__init__method, initialize the input widgets (Spinboxes, Entries) using the values from the storage variables. - Saving State: In the
applymethod (or the callback associated with the confirmation button), retrieve the current values from the widgets and update the storage variables. - 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
What ships with it
Read from the repository
Just SKILL.md. No reference files, no scripts.