Hi,

On Mon, 12 Jul 2021 20:31:57 +0100
E Paine <xepain...@gmail.com> wrote:

> > - all widths like borderwidths, decorations, separators etc, set in
> > pixels do not scale with the dpi settings. Could we use "mm" for their
> > settings instead?
>
> Definitely! The defaults in Tk use pixels, but you can use mm for
> lengths: tk.Label(root, text="foo", borderwidth="5mm", relief="groove")
>
> > - checkbox, radiobox the indicator appears tiny wrt the text
>
> This may be related to https://bugs.python.org/issue41969, in which case
> you're just waiting for your repos to update Tk.

Not sure, this seems to be a windows-specific thing. The OP was more
interested in ways to let Tk do the job by itself (at least that is what
I assumed :) .

>
> > Is there a way to detect from tkinter a high res display and force a
> > window scaling x2 for everything?
>
> IDLE has a `fix_scaling` method. Maybe you could use something similar?
> https://github.com/python/cpython/blob/da2e673c5/Lib/idlelib/run.py#L313

Looks like this will scale only font sizes. To scale "everything" you can
try to use the "tk scaling" command directly, like

root.tk.call('tk', 'scaling', chosen_dpi / 72.0)

(I thought that's what Vasilis already does).

Please note that this must be called early in the code, before any
widgets are created.

According to `man tk` this should scale everything that is measured in
"physical units" like mm, points or inches, but it won't scale e.g. a
borderwidth or a font size given in pixels. Obviously it won't scale
images either, which I guess is the problem with the check- and
radiobuttons; the indicators are probably just hard-coded images or
bitmaps.

Another problem with that fix_scaling() method might be that it relies on
the scaling factor already in use (I guess), which may be treacherous, at
least if you have a cheap monitor (like I do :) . These monitors often
report incorrect EDID data, which lead to an incorrect default dpi value
(in my case iirc with default settings everything appeared too small on
the screen, like a 100 mm line being displayed at 80 mm size or so; with
linux I had to manually override the dpi X11 uses to work around this;
I never bothered to check with windows, but I suppose that problem
still exists).

When using "tk scaling" you can add some configuration switch to let the
user decide which dpi value to use.

Best regards

Michael

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

Without followers, evil cannot spread.
                -- Spock, "And The Children Shall Lead", stardate 5029.5
_______________________________________________
Tkinter-discuss mailing list
Tkinter-discuss@python.org
https://mail.python.org/mailman/listinfo/tkinter-discuss

Reply via email to