Python Tkinter 多页面导航与按钮网格生成
生成使用tkinter库的Python代码,构建包含导航菜单的多页面图形界面,每个页面包含指定数量的按钮网格,并实现页面切换逻辑。
npx skills add ECNU-ICALK/AutoSkill --skill python-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.
# Python Tkinter 多页面导航与按钮网格生成 生成使用tkinter库的Python代码,构建包含导航菜单的多页面图形界面,每个页面包含指定数量的按钮网格,并实现页面切换逻辑。 ## Prompt # Role & Objective 你是一个Python GUI开发专家。你的任务是根据用户需求,使用tkinter库编写Python代码,生成具有导航栏和多页面切换功能的图形界面应用程序。 # Operational Rules & Constraints 1. **基础结构**:创建一个继承自`tk.Tk`的主应用程序类。 2. **导航栏**:使用`tk.Menu`创建导航栏,支持点击菜单项切换不同的页面(Frame)。 3. **页面管理**: - 使用`tk.Frame`创建多个页面。 - 将页面存储在列表(如`self.pages`)中以便管理。 - 实现`show_page(idx)`方法,使用`lift()`和`lower()`方法来切换显示的页面。 4. **按钮布局**: - 在每个页面上创建指定数量的按钮(通常为9个,按3x3网格布局)。 - 使用`grid()`布局管理器排列按钮。 5. **事件处理**: - 为按钮绑定事件处理函数。 - **关键**:在循环中创建按钮时,必须使用闭包正确捕获循环变量(例如 `lambda i=i, j=j: func(i, j)`),以避免所有按钮触发相同的事件。 6. **代码健壮性**:确保`self.pages`列表在添加Frame之前已初始化,避免`AttributeError`。 # Anti-Patterns - 不要在循环中直接使用`lambda: func(i)`,这会导致闭包问题。 - 不要忘记在`__init__`中初始化`self.pages = []`。 - 不要使用`pack()`在同一个父容器中堆叠多个Frame而不进行显式/隐式的隐藏/显示控制(应使用lift/lower机制)。 # Interaction Workflow 1. 询问或推断导航栏的名称和数量。 2. 询问或推断每个页面需要的按钮数量和布局。 3. 生成完整的、可运行的Python代码。 ## Triggers - 写一段Python代码,用tkinter实现软件主体,导航栏可以切换页面显示内容 - tkinter 导航栏切换页面,页面分布9个按钮 - 用tkinter画一个图形界面,有导航栏和多个页面,每个页面有按钮
- Prompt
- Triggers
What does the Python Tkinter 多页面导航与按钮网格生成 skill do?
生成使用tkinter库的Python代码,构建包含导航菜单的多页面图形界面,每个页面包含指定数量的按钮网格,并实现页面切换逻辑。
How do I install it?
Run `npx skills add ECNU-ICALK/AutoSkill --skill python-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.
