📜  将 ttk 组合框设置为只读 - Python 代码示例

📅  最后修改于: 2022-03-11 14:45:51.741000             🧑  作者: Mango

代码示例1
#A Combobox is a tkinter.ttk widget equivalent to OptionMenu of tkinter but better than it. But there is a text entry in it so here is the code to disable it :
from tkinter import *
from tkinter.ttk import *
root=Tk()
selected=StringVar()
cb=ttk.Combobox(root,textvariable=selected,values=["Car","Bike","Scooter"])
cb.pack()
root.mainloop()
#NOTE : It is necessary to write from tkinter import * and then in next line from tkinter.ttk import * to get both tkinter and tkinter.ttk widgets.