首页 > 解决方案 > ttk.Spinbox 总是突出价值

问题描述

我意识到ttk.Spinbox似乎总是突出显示通过向上或向下按钮选择的新值。有没有办法避免这个功能?可以selectbackground=<background color>, selectforeground=<foreground color>在 Style 中设置,但这只是隐藏了问题。

可重现的例子:

from tkinter import Tk
from tkinter.ttk import Spinbox, Style

root = Tk()
spinbox = Spinbox(root, from_=0, to=10)
spinbox.pack(expand=True)

### How to hide it
style = Style(root)
style.configure('TSpinbox',
                selectbackground=style.configure('TSpinbox', 'background'), #set selectforeground to foreground
                selectforeground=style.configure('TSpinbox', 'foreground')) #set selectbackground to background
###

root.mainloop()

标签: python-3.xselecttkinterttkspinbox

解决方案


推荐阅读