我在 Linux 上使用 python2.7。我开始尝试 ttk 风格。 我想知道在哪里可以找到小部件的完整布局。例如 TreeView 。
当我运行时:
import ttk
from pprint import pprint
s = ttk.Style()
ttk.Treeview().pack()
layout = s.layout('Treeview')
pprint(layout)
我得到这个输出:
[('Treeview.field',
{'border': '1',
'children': [('Treeview.padding',
{'children': [('Treeview.treearea', {'sticky': 'nswe'})],
'sticky': 'nswe'})],
'sticky': 'nswe'})]
当我运行时:
s.configure('Treeview.Heading', background='red')
我得到了所需的红色标题:
我的问题是:
如何获取小部件的整体布局?
正如我在互联网上发现 Treeview.Heading
的存在一样。 为什么它没有出现在 s.layout
的输出中?
最佳答案
这解决了它:
import tkinter.ttk as ttk
from pprint import pprint
s = ttk.Style()
data = {}
for e in s.element_names():
data[e] = s.element_options(e)
pprint(data)
关于Python ttk.Style : How to find all possible options to configure?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44910927/