我一直在尋找與python tkinter,因爲我對GUI的認真感興趣,並認爲這將是一個很好的起點。我經歷了一些很好的教程,比如新波士頓的設置和一兩個Theres來抓住基本的東西。現在我正試圖通過一個「論點」來傳遞一個「論點」,這樣我的程序就會轉向我的IF語句,而我沒有快樂。Tkinter按鈕命令參數
隨函附上代碼:
try:
from tkinter import *
except ImportError:
from Tkinter import *
eod = 'no'
selection = []
selection1 = 'nothing'
while eod != 'yes':
def beer():
selection.append('Beer')
selection1 = 'Beer'
def wine():
selection.append('Wine')
def whiskey():
selection.append('Whiskey')
welcomeGUI = Tk()
welcomeGUI.geometry('400x200+100+200')
welcomeGUI.title('Drinks Despenser')
welcomLabel1 = Label(welcomeGUI, text='Drinks-O-Matic', font='Times 22 bold').grid(row=0,column=2)
welcomLabel2 = Label(welcomeGUI, text='Please select drink', font='Times 16 bold').grid(row=1,column=2)
beerButton = Button(welcomeGUI, text='Beer', font='Times 16 bold',command=beer()).grid(row=6,column=1)
wineButton = Button(welcomeGUI, text='Wine', font='Times 16 bold').grid(row=6,column=2)
whiskeyButton = Button(welcomeGUI, text='Whiskey', font='Times 16 bold').grid(row=6,column=3)
if selection1 is 'Beer':
welcomeGUI.destroy()
beerGUI = Tk()
beerGUI.geometry('400x200+100+200')
beerGUI.title('Beer Despenser')
beerGUI.mainloop()
welcomeGUI.mainloop()
感謝上百萬的投入。 –