为了账号安全,请及时绑定邮箱和手机立即绑定

我的课程中的 tkinter 小部件没有显示

我的课程中的 tkinter 小部件没有显示

HUH函数 2021-09-25 13:21:22
我正在尝试编写一个包含多个页面并且可以在单击按钮时切换到的代码。它最初有效,但我的小部件没有显示,并且既没有警告也没有错误消息。其次,使用tk和tk.TK有什么区别?from tkinter import *import tkinter as tkclass moreTab(tk.Tk):    def __init__(self):        Tk.__init__(self)        self.geometry("1200x600")        container = Frame(self, bg='#c9e3c1')        container.pack(side = "top", fill = 'both', expand = True)        container.grid_rowconfigure(0, weight = 1)        container.grid_columnconfigure(0, weight = 1)        self.frames = {}        for q in (pageone, widget):            frame = q(container,self)            self.frames[q] = frame            frame.place(x= 0,y = 0)        self.raise_frame(pageone)    def raise_frame(self,cont):        frame = self.frames[cont]        frame.tkraise()class widget(Frame):    def __init__(self, master, control):        Frame.__init__(self, master)        lab = tk.Label(self, text="main page")        lab.place(x = 10, y = 40)        but = tk.Button(self, text='visit start page', command=lambda: control.raise_frame(pageone))        but.place(x = 10, y = 70)class pageone(Frame):    def __init__(self, master, control):        Frame.__init__(self,master)        lab = Label(self, text = 'welcome to Game Analysis')        lab.place(x = 10, y = 10)        but = Button(self, text = "Start", command  = lambda: control.raise_frame(widget))        but.place(x = 10, y = 20)app = moreTab()app.mainloop()
查看完整描述

1 回答

  • 1 回答
  • 0 关注
  • 185 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号