为什么Frame不会出现在Tkinter中?

时间:2015-10-10 15:57:04

标签: python tkinter

我正在尝试构建一个基于您输入的音符播放音乐的程序。一切都在游泳,直到我尝试添加不同的应用程序屏幕。我有两个框架songSelectmainMenu。我lift()那个我当时要展示的那个。唯一的问题是,什么都不会出现。

这是我的代码:

root = Tk()
root.title("Music Creator")
root.geometry("300x230")
root.iconbitmap(default='favicon.ico')
root.resizable(width=FALSE, height=FALSE)

mainMenu = Frame(root)
songSelect = Frame(root)

def raiseFrame(frame):
    frame.lift()

mainMenu.lift()

programName = Label(mainMenu, text="Music Creator", font=("Helvetica",20))

noteLabel = Label(mainMenu, text="Notes to play:")
tempoLabel = Label(mainMenu, text="Interval to play the notes at: (In seconds)")

noteEntry = Entry(mainMenu)
tempoEntry = Entry(mainMenu)

playButton = Button(mainMenu, text="Play", command=lambda: playNotes(noteEntry.get(),tempoEntry.get()))
loadButton = Button(mainMenu, text="Load", command=lambda: raiseFrame(songSelect))

programName.place(relx=0.5,y=25,anchor=CENTER)
noteLabel.place(relx=0.5,y=60,anchor=CENTER)
noteEntry.place(relx=0.5,y=90,anchor=CENTER)
tempoLabel.place(relx=0.5,y=130,anchor=CENTER)
tempoEntry.place(relx=0.5,y=160,anchor=CENTER)
playButton.place(relx=0.5,y=200,anchor=CENTER)
loadButton.place(x=10,y=40)

root.mainloop()
mainMenu.mainloop()

1 个答案:

答案 0 :(得分:0)

因为您使用place,所以框架不会调整大小以适应其内容。因此,您的框架只有一个像素高和宽。