- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
以下代码创建一个 ttk.Combobox 小部件:
import tkinter.ttk as ttk
default_values = ['Peter','Scotty','Walter','Scott','Mary','Sarah','Jane',
'Oscar','Walley','Faith','Bill','Egor','Heley']
s=ttk.Style()
s.configure( 'TCombobox', font=('Purisa', 20, 'bold'), background ='cyan',
fieldbackground='pink')
c=ttk.Combobox(values=default_values)
c.master.option_add( '*TCombobox*Listbox.background', 'yellow')
c.master.option_add( '*TCombobox*Listbox.selectbackground','red') #does not work
c.master.option_add( '*TCombobox*Listbox.selectforeground','grey') #does not work
c.master.option_add( '*TCombobox*Listbox.highlightbackground','blue') # does not work
c.master.option_add( '*TCombobox*Listbox.highlightforeground','green') #does not work
c.master.option_add( '*TCombobox*Listbox.activestyle', 'underline') #does not work
c.grid()
单击组合框向下箭头后,将出现一个包含默认值
的下拉菜单(这是一个tk.Listbox
小部件)。当鼠标悬停在下拉菜单上时,鼠标指针下方会出现事件背景。 我想改变这个灰色事件背景的颜色。我该怎么做?
作为dropdown menu isn't a ttk widget , 它不会响应 ttk.Style()
设置。我也尝试过 .option_add
方法,但只能更改列表框背景。
最佳答案
您正在尝试使用正确的选项来更改背景颜色:
c.master.option_add( '*TCombobox*Listbox.selectbackground','red')
但是你犯了一个小错误,即 selectbackground
。在selectbackground
中,background
的首字母要大写。*TCombobox*Listbox.selectbackground
变为 *TCombobox*Listbox.selectBackground
------------------------__^__-------------------- ------------------__^__--------
尝试:
c.master.option_add( '*TCombobox*Listbox.selectBackground','red')
类似地,foreground
变为 Foreground
。
关于python - 如何更改 ttk.Combobox 中下拉菜单(即 tk.Listbox)事件背景的颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52453471/
前文链接: Spring复杂的BeanFactory继承体系该如何理解? ----上 Spring复杂的BeanFactory继承体系该如何理解? ----中 Spring IoC容器 Applica
我正在努力实现这个目标 | Div | |Div nav wrapper| | logo | |con
我正在尝试从下拉菜单中的链接进行模式启动。模态似乎启动了(网站变灰),但看不到。来自不在下拉列表中的常规链接的模式工作得很好。我愚弄了 jquery,但由于我是 jquery 的新手,所以没有任何结果
我是一名优秀的程序员,十分优秀!