Python 当我转到另一帧并回到同一帧时,Spinbox消失了
我在frame1上创建了一个spinbox,通过单击NEXT转到frame2,通过单击back按钮从frame2返回到frame1。当spinbox小部件消失时。原因可能是什么Python 当我转到另一帧并回到同一帧时,Spinbox消失了,python,tkinter,Python,Tkinter,我在frame1上创建了一个spinbox,通过单击NEXT转到frame2,通过单击back按钮从frame2返回到frame1。当spinbox小部件消失时。原因可能是什么 from Tkinter import * def swap_frame(frame): frame.tkraise() root = Tk() root.geometry("900x650+220+20") root.title("Testing") root.configure(borderwidth="1
from Tkinter import *
def swap_frame(frame):
frame.tkraise()
root = Tk()
root.geometry("900x650+220+20")
root.title("Testing")
root.configure(borderwidth="1", relief="sunken",cursor="arrow",background="#BCC3B9",highlightcolor="black")
root.resizable(width=False, height=False)
frame2 = Frame(root, width=900, height=650)
frame1 = Frame(root, width=900, height=650)
#item 1 spinbox
Platform = Spinbox(values=("SX-16F", "SX-12VP", "SX-16VP", "VSRM-A", "NRNT-A", "FX-8", "DX-48V"), width="32")
Platform.place(x=500, y=200, relheight=0.05)
Button1=Button(frame1, text="Next", width =10, height= 2, bg= "#dbd8d7", command=lambda:swap_frame(frame2))
Button1.place(x=580, y=580)
Button3=Button(frame2, text="Back", width =10, height= 2, bg= "#dbd8d7", command=lambda:swap_frame(frame1))
Button3.place(x=580, y=580)
frame2.grid(row=0, column=0)
frame1.grid(row=0, column=0)
root.mainloop()
将主控形状传递给Spinbox小部件。它当前默认为Tk窗口,该窗口仅在最初提升,因此在提升任一帧时,它会被两帧阻挡。替换:
Platform = Spinbox(values=(...), ...)
与:
谢谢你,很好的解释。
Platform = Spinbox(frame1, values=(...), ...)