[英]Why does the Frame not appear in Tkinter?
我正在嘗試構建一個基於您輸入的音符來播放音樂的程序。直到我嘗試添加該應用程序的不同屏幕之前,一切都進行得很順利。 我有兩個框架, songSelect
和mainMenu
。 我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.