選項選單部件的建立及其選項
該部件為Menubutton與Menu兩部件在特定引數選項下所訂立的部件
import tkinter as tk
parent = tk.Tk()
message = tk.OptionMenu(parent, variable, choice1, choice2, ...)
範例視窗及程式碼
import tkinter as tk
root = tk.Tk()
root.wm_title("Message Demo")
items = ('Train', 'Plane', 'Boat')
select = tk.StringVar()
select.set(items[0])
font = ('Courier New', 20, 'bold')
option_menu = tk.OptionMenu(root, select, *items)
option_menu.config(font=font)
option_menu.grid()
root.mainloop()
本作品採用《CC 協議》,轉載必須註明作者和本文連結