How Can I Set The Row Height In Tkinter Treeview?
I wrote a small app recently that needs to be cross-platform. I used Python and Tkinter for the GUI. It works great but recently I got a new laptop with a hiDPI screen and it seems
Solution 1:
s = ttk.Style()
s.configure('Treeview', rowheight=40) # repace 40 with whatever you need
Solution 2:
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:
Post a Comment for "How Can I Set The Row Height In Tkinter Treeview?"