首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >如何在tkinter下拉框(Combobox)选中的选项改变时执行操作?

如何在tkinter下拉框(Combobox)选中的选项改变时执行操作?

提问于 2022-07-19 11:23:25
回答 0关注 0查看 273

我想要在cb1下拉框选中选项为b时,把et1设置为不可编辑

要如何实时检测combobox选中选项的变化呢?

from tkinter import *

from tkinter import ttk

root = Tk()

root.geometry("500x500")

lf1 = LabelFrame(root,text="Text")

lf1.place(x=5,y=5,width=495,height=60)

et1 = Entry(lf1)

et1.place(x=5,y=0,width=480,height=30)

lf2 = LabelFrame(root,text="Ch")

lf2.place(x=5,y=70,width=240,height=60)

cb1 = ttk.Combobox(lf2)

cb1.place(x=5,y=0,width=225,height=30)

cb1["value"] = ("a","b")

cb1.current(0)

cb1["state"] = "readonly"

root.mainloop()

回答

和开发者交流更多问题细节吧,去 写回答
相关文章

相似问题

相关问答用户
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档