python 菜单栏界面切换,如何在Tkinter中通过菜单栏方法更改页面?

这篇博客探讨了如何在Python的Tkinter GUI中利用菜单栏切换不同的页面。作者已经创建了下拉菜单和各自页面的类,但遇到的问题是菜单栏按钮无法改变页面,而独立的按钮则可以。解决方案是将`controller.show_frame`替换为`self.show_frame`,因为`MyApp`类本身就是控制器。
摘要由CSDN通过智能技术生成

Basically what I'm trying to figure out is, how do I make my menu bar "buttons" change the page?

I've already made the dropdown menu, and the classes with each page. The thing is it works if I create a separate button to change the page, but not when i'm trying to do it through the menu bar?

every tutorial I find is through the buttons, and only the buttons..

I am using python 3.6, with tkinter.

import tkinter as tk

class MyApp(tk.Tk):

def __init__(self, *args, **kwargs, ):

tk.Tk.__init__(self, *args, **kwargs)

container = tk.Frame(self)

container.pack(side="top", fill="both", expand=True)

container.grid_rowconfigure(0, weight=1)

container.grid_columnconfigure(0, weight=1)

self.frames = {}

menu = tk.Menu(container)

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值