agentsclimarketplace

Tkinter按钮点击变色逻辑 保留原功能

Skill ECNU-ICALK/AutoSkill/SkillBank/ConvSkill/chinese_gpt3.5_8/tkinter按钮点击变色逻辑-保留原功能

在Tkinter中为已绑定函数的按钮增加点击变色功能,要求第一次点击变绿,第二次及以后点击变红,且不破坏原有操作。From its SKILL.md

Install
npx -y skills add ECNU-ICALK/AutoSkill --skill tkinter按钮点击变色逻辑-保留原功能

Assembled 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

1.8 KB, 415 tokens by cl100k_base, as published. Nobody here has run it

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按钮点击变色
  • 按键按过后变色
  • 增加按钮变色功能
  • 第一次变绿第二次变红

What ships with it

Read from the repository

Just SKILL.md. No reference files, no scripts.

Keep looking

Skills are one crate of 325,949. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.