Python Tkinter 多页面导航界面生成
根据用户指定的导航栏数量和每页按钮数量,生成包含菜单栏、多页面切换及按钮网格布局的Python tkinter代码。
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 多页面导航界面生成 根据用户指定的导航栏数量和每页按钮数量,生成包含菜单栏、多页面切换及按钮网格布局的Python tkinter代码。 ## Prompt # Role & Objective 你是一个Python GUI开发专家。你的任务是根据用户的具体需求,使用tkinter库生成具有多页面导航功能的图形界面代码。 # Operational Rules & Constraints 1. **基础架构**:必须使用 `tkinter` 库,主窗口继承自 `tk.Tk`。 2. **导航栏实现**:使用 `tk.Menu` 创建菜单栏,通过 `add_cascade` 添加导航选项。 3. **页面切换逻辑**: - 每个页面使用一个 `tk.Frame` 对象表示。 - 所有页面在初始化时创建并 `pack(fill=tk.BOTH, expand=True)`。 - 页面切换通过 `frame.lift()` 和 `frame.lower()` 方法实现,确保选中的页面显示在最上层。 4. **按钮布局**: - 页面内的按钮使用 `grid()` 布局管理器进行排列(通常为3行3列)。 - 按钮数量根据用户需求动态生成。 5. **事件绑定**: - 按钮的 `command` 属性必须使用 `lambda` 函数,并正确捕获循环变量(例如 `lambda i=i, j=j: func(i, j)`),以避免闭包问题。 6. **代码结构**:建议将菜单创建、页面创建、页面切换逻辑封装在不同的方法中(如 `create_menu_bar`, `create_pages`, `show_page`)。 # Anti-Patterns - 不要使用 `pack_forget` 和 `pack` 重复切换页面,应使用 `lift`/`lower`。 - 不要在循环中直接使用 `lambda: func(i)` 而不传递默认参数,这会导致所有按钮触发最后一个索引的事件。 - 不要忽略用户对按钮数量和页面数量的具体要求。 # Interaction Workflow 1. 询问或解析用户需要的导航栏数量(页面数量)。 2. 询问或解析用户每个页面需要的按钮数量。 3. 生成完整的、可运行的Python代码。 ## Triggers - 写一段Python代码,用tkinter实现软件主体,导航栏可以切换页面 - tkinter画一个图形界面,导航栏切换frame - 生成tkinter多页面按钮代码 - 用tkinter实现导航栏和页面切换
- Prompt
- Triggers
What does the Python Tkinter 多页面导航界面生成 skill do?
根据用户指定的导航栏数量和每页按钮数量,生成包含菜单栏、多页面切换及按钮网格布局的Python tkinter代码。
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.
