像这样的东西应该让你对你的方式:
from Tkinter import *
## Define root and geometry
root = Tk()
root.geometry('200x200')
# Define Frames
win1, win2, win3 = Frame(root, bg='red'), Frame(root, bg='green'), Frame(root, bg='blue')
# Configure Rows
root.grid_rowconfigure(0, weight = 1)
root.grid_columnconfigure(0, weight = 1)
# Place Frames
for window in [win1, win2, win3]:
window.grid(row=0, column = 0, sticky = 'news')
# Raises first window 'To the top'
win1.tkraise()
# Function to raise 'window' to the top
def raise_frame(window):
window.tkraise()
# Page1 label/button
l1 = Label(win1, text = 'This is Page1').pack(side=TOP)
P1 = Button(win1, text = 'Next Page', command = lambda:raise_frame(win2)).pack(side=BOTTOM)
# Page2 label/button
l2 = Label(win2, text = 'This is Page2').pack(side=TOP)
p2 = Button(win2, text = 'Next Page', command = lambda:raise_frame(win3)).pack(side=BOTTOM)
# Page3 label/button
l3 = Label(win3, text = 'This is Page3').pack(side=TOP)
p3 = Button(win3, text = 'Next Page', command = lambda:raise_frame(win1)).pack(side=BOTTOM)
root.mainloop()
让我知道你在想什么!
谢谢!我没有一定数量的窗口,但使用另一个函数来提高帧,因为你修复了我遇到的问题! – user6763008