当我转到其他框架并回到同一个时,Spinbox消失了

时间:2018-03-12 13:04:39

标签: python tkinter

我在frame1上创建了一个spinbox并通过单击NEXT转到frame2,从frame2返回到第1帧,单击BACK按钮。到旋转盒小部件消失时。可能是什么原因?

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()

1 个答案:

答案 0 :(得分:1)

将主人传递到Spinbox小部件。它当前默认为Tk窗口,它只是最初提升,因此当任何一个被抬起时它会被两个帧阻挡。替换:

Platform = Spinbox(values=(...), ...)

使用:

Platform = Spinbox(frame1, values=(...), ...)