python - 您可以在单个应用程序中创建多个 ttk 树视图标题样式吗?
问题描述
我有一个用 python 3 编写的 tkinter 应用程序,它在不同的顶层框架中使用多个树视图小部件。我想为每个小部件定制不同的标题样式,但我只知道如何更改全局“Treeview.Heading”样式。以下是我当前定义树视图样式的方式:
self.xs_font = tkfont.Font(family='Arial', size=9)
self.treeview = ttk.Style()
def fixed_map(option):#bug fix to allow highlighted lines in a treeview
return [elm for elm in self.treeview.map('Treeview', query_opt=option) if elm[:2] != ('!disabled', '!selected')]
self.treeview.map('Treeview', foreground=fixed_map('foreground'),background=fixed_map('background'))#implement bug fix
self.treeview.configure('home_tree.Treeview',font=self.xs_font,rowheight=20)# style for homepage treeview
self.treeview.configure('toplevel_tree.Treeview',font=self.xs_font,rowheight=30)#style for toplevel treeview
self.treeview.configure('Treeview.Heading',font=self.xs_font,rowheight=20)#style for treeview headings (applies to all treeviews)
我想要为每个树视图标题创建自定义样式并应用它们,就像我为树视图的主体所做的那样。
解决方案
推荐阅读
- python - 在 Python 中取消转义 XML 属性
- testing - Skype bot 是否由 Botium 自动化?
- ios - Appium 1.10.0 和 IOS (12.1.2) 的 WDA 连接超时
- jupyter-notebook - Jupyter:如何仅在一条路径中搜索内核
- javascript - 从请求节点 HTTP 服务器获取源 URL
- javascript - Angular [innerHTML] 无法正常工作
- mysql - 如何从表消息和查看的消息中创建“读取消息”查询?
- c# - 当另一个打开时如何关闭嵌套的gridview
- jquery - JQuery 对话框类
- reactjs - react, gatsby - 如何在 React 类组件中访问 GraphQL 查询数据