tkinter - Changing the fontsize for the window and its widgets ?

R.Wieser address at not.available
Tue Jan 21 15:22:49 EST 2020


Terry,

> A physically large display should have physically larger pixels, but see 
> below.

:-)  Although the width of the monitor on which the default font size is 
used is 47 cm and that of the TV is 81, the distance to the monitor is about 
65 cm, while the distance to the TV is about 2.5 meters.  In other words, 
I'm relativily over twice as far from the TV as from the monitor.  Hence the 
need for a larger font.

> AFAIK, Toplevel windows do not have a font setting.

Great.  That effectivily means that, if I want to be able to read a windows 
caption, my distance to the display is fixed . :-(

> So the system settings would need to be changed to get relatively larger 
> window text.  Not easy, even if  possible, from within a python program.

If it would be able to be programmatically set (even if a reboot would be 
necessary) I would like to know how that its done (where do the changes need 
to be written to).

... that is, if it doesn't trash the desktop every time its switched. :-)

> Row height is set with the Treeview rowheight style.

I also found the "rowheight" style (in a bit of example code).  And after 
quite a bit more googeling I found that you could ask the font for its 
"linespace" metrics and apply that as the rowheight.   Nothing automagical, 
but it works.

> Searching "python tkinter treeview height" returns Q&As on Stackoverflow 
> and other forums.

:-) I've not been leaning back in that regard.  But its a hell of a job when 
you do not even know what exactly that you're looking for.

> If you allow dynamic font changes, you have to redo row height and column 
> widths

The whole idea was just a static change, before any of the widgets where 
created.  Alas, tkinter doesn't work that way.    But yes, I have seen code 
dealing with such dynamic font-size changes.

Thanks for the suggestions.

Regards,
Rudy Wieser




More information about the Python-list mailing list