Python- 找出哪些值可以/不能使用 ttk.Style 更改

Python- Finding out what values can/ can't be changed using ttk.Style

我在 Python 很新,所以也许这不是问题,虽然进行了深入的搜索,但让我空手而归。

我正在使用 ttk.Entry 的 table- 并且希望所有文本都居中。使用 style.configure('TEntry', foreground='green', justify=tk.CENTER) 时 - 文本未居中,

但是,将 justify=tk.CENTER 移动到小部件行 ent1 = ttk.Entry(root, textvariable=t, width=20, justify=tk.CENTER),它起作用了 OK

以类似的方式,font=('Helvetica', 18)ent=...

中注明时影响文本

寻找关于何时 can/can 我没有在 ttk.Style Python Documentation and in Using and customizing ttk styles 中使用某些配置值的答案,但我没有得到答案。

有线索吗?

尝试以下操作,注意特别是 ttky 条目小部件样式有一些不一致。我使用的经验法则是:如果 ttkentry.configure() returns 是配置选项(如本例中的 justify),则使用 ttkentry.configure(justify='center') 或您想要的任何有效选项。 Ttk 条目字体属于同一类别。您可以使用 ttkentry.configure(font='???') 方法在它们上设置字体。

所以在这种情况下,输入 ttkentry.configure 的响应如下:

from tkinter import *
from tkinter import ttk
root = Tk()
ttkentry = ttk.Entry(root)
ttkentry.insert(0, "my centered text")
ttkentry.pack()
ttkentry.configure()
# Partial output of ttkentry.configure()
{'foreground': ('foreground', 'textColor', 'TextColor', '', ''),..., 'justify': ('justify', 'justify', 'Justify', <index object: 'left'>, 'left'),...,'validate': ('validate', 'validate', 'Validate', <index object: 'none'>, 'none')}

# After this command, note that the text is centered.
ttkentry.configure(justify='center')