Views:
19,417
Votes: 7
Tags:
python
tkinter
treeview
hidpi
Link:
🔍 See Original Answer on Stack Overflow ⧉ 🔗
URL:
https://stackoverflow.com/q/59530481
Title:
How can I set the row height in Tkinter TreeView?
ID:
/2019/12/30/How-can-I-set-the-row-height-in-Tkinter-TreeView_
Created:
December 30, 2019
Edited: December 30, 2019
Upload:
September 15, 2024
Layout: post
TOC:
false
Navigation: false
Copy to clipboard: false
I already have a variable setup for font size and would like to avoid setting up a variable for row height. So my code looks like this:
style = ttk.Style()
style.configure("Treeview.Heading", font=(None, LARGE_FONT), \
rowheight=int(LARGE_FONT*2.5))
style.configure("Treeview", font=(None, MON_FONTSIZE), \
rowheight=int(MON_FONTSIZE*2.5))
When LARGE_FONT
is set to 14
, the row height is set to 35
. When MON_FONTSIZE
is set to 12
, the row height is calculated as 30
.
The end result has the correct spacing (IMO) for the system font. YMMV for other font families though: