我創建一個閃屏,這將是介紹我的計劃。我已經設法在屏幕上放置一個圖像,但一旦我添加一個按鈕,什麼都沒有出現,甚至沒有出現這個窗口。的Python 2.7.8 Tkinter的GUI,其中包括圖像,按鈕和文本
我試圖做的是對窗口頂部的圖像,其下一個文本框,我的名字「鮑勃約翰」,那麼另一個按鈕,上面寫着"Enter"
,這將用戶帶到另一節該程序(即啓動應用程序)。所有這些都與中心對齊。
這是我到目前爲止有:
from Tkinter import *
from PIL import ImageTk, Image
import os
#create the window
root = Tk()
#modify root window
root.title("Labeler")
root.geometry("500x500")#Width x Height
img = ImageTk.PhotoImage(Image.open("test.gif"))
panel = Label(root, image = img)
panel.pack(side = "bottom", fill = "both", expand = "yes")
#If i add this section the program goes awol--------------
app = Frame(root)
app.grid()
button1 = Button(app, text = "This is a button")
button1.grid()
#---------------------------------------------------------
#Start the event loop
root.mainloop()
[按下按鈕交換接口(可能重複http://stackoverflow.com/questions/26298591/swap-interface-on-button-press) – jonrsharpe 2014-10-12 13:44:30
*(** TL; DR **:請勿混合使用網格和包裝)* – jonrsharpe 2014-10-12 13:45:10