非常新的与图形用户界面的工作,所以我想知道是否有人可以给我一些指导,如何链接多个帧,这样你就可以按一个按钮转到该帧。你知道吗
太好了!你知道吗from tkinter import *
class main(Frame):
def __init__(self, master=None):
super(main, self).__init__(master)
self.grid()
self.pack()
def buttons_dash():
# create first button
self.bttn1_dash = Button(self, text = "Student Login",)
self.bttn1_dash.grid()
self.bttn1_dash.config(height=3, width=30)
# create second button
self.bttn2_dash = Button(self)
self.bttn2_dash.grid()
self.bttn2_dash.configure(text = "Staff Login")
self.bttn2_dash.config(height=3, width=30)
# create third button
self.bttn3_dash = Button(self)
self.bttn3_dash.grid()
self.bttn3_dash["text"] = "Exit"
self.bttn3_dash.config(height=3, width=30)
self.bttn3_dash = Button(self, text= "Exit")
class student_dashboard(Frame):
def __init__(self, master=None):
super(main, self).__init__(master)
self.grid()
self.pack()
def buttons_student():
#create first button
self.bttn1_student = Button(self, text = "View Highscores")
self.bttn1_student.grid()
self.bttn1_student.config(height=3, width=30)
# create second button
self.bttn2_student = Button(self)
self.bttn2_student.grid()
self.bttn2_student.configure(text = "Save Score")
self.bttn2_student.config(height=3, width=30)
# main
root = Tk()
root.title("Dashboard")
app = main(root)
root.mainloop()
你可以在你的主类中创建一个按钮,用一个命令调用一个包含嵌套类和新tkinter框架的函数,然后你就有了一个嵌套的顶层。你知道吗
相关问题 更多 >
编程相关推荐