我在python tkinter中創建了一個雙窗格的窗格。它會打開它自己的罰款,但在一個if語句不再打開Tkinter panedwindow沒有打開
首先,我只是自己的panedwindow的代碼,但我想在另一段代碼中使用它。它不會在if語句中工作,它似乎被忽略。我哪裏錯了?
from tkinter import *
import time
ticketCost=6
username="Rob"
code = input("Enter code: ")
if code == "123":
year=str(time.localtime()[0])
month=str(time.localtime()[1])
day=str(time.localtime()[2])
hour=str(time.localtime()[3])
minute=str(time.localtime()[4])
ticketTime=str(hour+":"+minute)
ticketDate=str(day+"/"+month+"/"+year)
ticketInfo="Bus ticket\nSingle\nDate: "+ticketDate+"\nTime: "+ticketTime+"\nPassengers: "+
...str(int(ticketCost/3))+"\nPrice: "+str(ticketCost)+" credits"
ticketWindow = PanedWindow(orient=VERTICAL,bg="white")
ticketWindow.pack(fill=BOTH, expand=1)
top = Label(ticketWindow, text="top pane")
photo = PhotoImage(file='Coach 1.gif')
top.config(image=photo,bg="white")
top.image = photo
ticketWindow.add(top)
bottom = Label(ticketWindow, text="bottom pane")
bottom.config(text=ticketInfo)
bottom.config(bg="white")
ticketWindow.add(bottom)
print("\nThank you", username)
else:
print("no")
FWIW - 'year,month,day,hour,minute = map(str,time.localtime()[:5])'我認爲應該可以工作 – mgilson 2013-05-01 12:54:54
我的問題是panedwindow無法打開 – user2339371 2013-05-01 13:09:10
對不起,不要說這會導致你的程序工作。只需清理一下。我假設你確定你在'if'語句中選擇了正確的分支,但事情仍然沒有顯示出來? – mgilson 2013-05-01 13:11:41