[Tkinter-discuss] 4k HiDPI displays and tkinter [cont]

Michael Lange klappnase at web.de
Thu Mar 17 06:25:18 EDT 2022


Hi,

On Thu, 17 Mar 2022 09:47:16 +0000
Vasilis Vlachoudis <Vasilis.Vlachoudis at cern.ch> wrote:

> Hi Michael,
>
> no I am using the default fonts.
> What is different is the I have set a high DPI for the X-server to
> match the screen resolution.
>
> I saw in the page
> https://www.tcl.tk/man/tcl/TkCmd/ttk_treeview.html
>
> under "Styling Options'
> there is parameter to set the -rowheight
> that needs to be defined as
>
> ttk::style configure Treeview \
>      -rowheight [expr {[font metrics font -linespace] + 2}]
>
> however I could not find how to call this command, and when
> If I do the following
>
> style = ttk.Style()
> style.configure("Treeview", rowheight="30")
>
> it works, but it is not dynamic with the font size/dpi

you could do something like

>>> f=font.Font(name='TkDefaultFont', exists=1)
>>> rowheight=f.metrics('linespace')+2
>>> rowheight
17

This value is in pixels; I am not sure, if you did something to the
dpi setting, maybe you still need to increase this value somehow according
to the scaling factor in use, which you should be able to query with:

>>> root.tk.call('tk', 'scaling')
1.2450980392156863

I am just doing guesswork here, though.

Regards

Michael


.-.. .. ...- .   .-.. --- -. --.   .- -. -..   .--. .-. --- ... .--. . .-.

It would be illogical to kill without reason.
		-- Spock, "Journey to Babel", stardate 3842.4


More information about the Tkinter-discuss mailing list