问题描述
我最近写了一个需要跨平台的小应用.我使用 Python 和 Tkinter 作为 GUI.
I wrote a small app recently that needs to be cross-platform. I used Python and Tkinter for the GUI.
效果很好,但最近我买了一台带有 hiDPI 屏幕的新笔记本电脑,它似乎弄乱了 TreeView(见下图).与行高相比,文本高度过大.
It works great but recently I got a new laptop with a hiDPI screen and it seems to mess up the TreeView (see image below). The text height is too big compared to the height of the rows.
图片取自以访客身份运行 Windows 7 的虚拟机.我必须将文本设置为更大的尺寸 (125%) 才能在屏幕上阅读(我尝试过的所有其他程序都可以在此设置下正常工作).
The picture is taken from a virtual machine running Windows 7 as a guest. I had to set the text to a larger size (125%) to be able to read on the screen (every other program I've tried work fine with this setting).
有没有办法在 Tkinter TreeView 中设置行高?我在文档中没有看到类似的内容.
Is there any way to set the height of a row in Tkinter TreeView? I haven't seen anything like that in the docs.
推荐答案
s = ttk.Style()
s.configure('Treeview', rowheight=40) # repace 40 with whatever you need
这篇关于如何在 Tkinter TreeView 中设置行高?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!