Re: 4k HiDPI displays and tkinter [cont]

Michael Lange <[email protected]> Thu, 17 Mar 2022 11:25:18 +0100
Newsgroups gmane.comp.python.tkinter
Message-ID <[email protected]>
Hi,

On Thu, 17 Mar 2022 09:47:16 +0000
Vasilis Vlachoudis <[email protected]> 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