繁体   English   中英

为什么框架没有出现在Tkinter中?

[英]Why does the Frame not appear in 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()

由于使用place ,因此框架不会调整大小以适合其内容。 因此,您的帧只有一像素高和宽。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM