Tkinter按钮点击变色逻辑(保留原功能)
在Tkinter中为已绑定函数的按钮增加点击变色功能,要求第一次点击变绿,第二次及以后点击变红,且不破坏原有操作。
npx skills add ECNU-ICALK/AutoSkill --skill tkinter按钮点击变色逻辑-保留原功能 --agent claude-code
Same command for any agent — swap --agent for codex, cursor, copilot.
Weekly change comes from our own snapshots, not the repository page — it measures attention, not adoption.
# Tkinter按钮点击变色逻辑(保留原功能) 在Tkinter中为已绑定函数的按钮增加点击变色功能,要求第一次点击变绿,第二次及以后点击变红,且不破坏原有操作。 ## Prompt # Role & Objective 你是一个Python Tkinter编程助手。你的任务是在用户提供的现有按钮代码基础上,增加特定的点击变色功能。 # Operational Rules & Constraints 1. **保留原有功能**:必须保留按钮原有的操作函数(如 `do_something`),并在其执行后添加变色逻辑。 2. **变色逻辑**: - 第一次点击时,按钮背景色变为绿色。 - 第二次及以后点击时,按钮背景色变为红色。 3. **实现方式**:使用 `button.configure(bg='color')` 方法动态修改颜色。 4. **状态管理**:使用实例变量(如 `self.clicked` 或计数器)来跟踪点击次数或状态。 5. **代码规范**:确保Python代码缩进正确。 # Anti-Patterns - 不要删除或覆盖按钮原有的 `command` 绑定逻辑。 - 不要使用交替变化的逻辑(红->绿->红),必须遵循“一次绿,多次红”的规则。 ## Triggers - tkinter按钮点击变色 - 按键按过后变色 - 增加按钮变色功能 - 第一次变绿第二次变红
- Prompt
- Triggers
What does the Tkinter按钮点击变色逻辑(保留原功能) skill do?
在Tkinter中为已绑定函数的按钮增加点击变色功能,要求第一次点击变绿,第二次及以后点击变红,且不破坏原有操作。
How do I install it?
Run `npx skills add ECNU-ICALK/AutoSkill --skill tkinter按钮点击变色逻辑-保留原功能 --agent claude-code` — it drops the skill into your project so the agent can pick it up. Swap the --agent value for codex, cursor or copilot if you use one of those.
Where does this skill come from?
From ECNU-ICALK/AutoSkill, a repository with 539 stars. We read it straight from the repository tree rather than a submitted listing, so what you see here is what is actually published.
Is a popular skill a good skill?
Not necessarily. Stars measure attention, not adoption — a repository can trend for a week and be abandoned. That is why we show the weekly change from our own snapshots next to the total, instead of a single flattering number.
