#! python2
# coding: utf-8
import Tkinter as tk
import ttk
def clickOkButton():
print 'Select ' + str(numberChosen.current()) # 丟出選到的index number
win = tk.Tk()
win.title("Python Combobox example")
# Combobox
number = tk.StringVar()
numberChosen = ttk.Combobox(win, width=24, textvariable=number)
list = [0,1,2,3,4,5,6]
numberChosen['values'] = list # Set Combobox contents
numberChosen.grid(row=0, column=0)
numberChosen.current(0) # 預設選道的位置是index number 0
# Button
button1=ttk.Button(win, text="Select", command=clickOkButton)
button1.grid(row=0, column=1)
win.mainloop()
沒有留言:
張貼留言