如何在 Tkinter TreeView 中设置行高? [英] How can I set the row height in Tkinter TreeView?

查看:30
本文介绍了如何在 Tkinter TreeView 中设置行高?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近写了一个需要跨平台的小应用.我使用 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 中设置行高?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆