Hi,

On Mon, 12 Jul 2021 17:13:18 +0000
Vasilis Vlachoudis <vasilis.vlachou...@cern.ch> wrote:

> Recently I've got a 4k laptop, and the first experience with linux and
> the 4k display is quite painful. I am still trying to tune it but for
> the moment my tkinter applications do not render nicely on such a
> display.
> - 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?

why not try it?

>>> from tkinter import *
>>> r=Tk()
>>> b=Button(r, bd='2m')
>>> b.pack()

looks like a 2 mm border here ;)
But then:

>>> b.configure(width='40m')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python3.7/tkinter/__init__.py", line 1485, in configure
    return self._configure('configure', cnf, kw)
  File "/usr/lib/python3.7/tkinter/__init__.py", line 1476, in _configure
    self.tk.call(_flatten((self._w, cmd)) + self._options(cnf))
_tkinter.TclError: expected integer but got "40m"
>>> b.configure(bitmap='questhead')
>>> b.configure(width='40m')
>>> # this worked!

So, things might be a bit tricky :)


> - checkbox, radiobox the indicator appears tiny wrt the text

Agreed, these may be even more tricky.

>
> Is there a way to detect from tkinter a high res display and force a
> window scaling x2 for everything? What is your experience with such
> displays?

I don't have any experience with 4k displays, but had a similar problem
when I set up a little app I wanted to run on my 1080p TV. From 3 m
distance even with that display a highlight thickness of 1 pixel is hard
to detect for my old eyes.
I ended up with an option database that changed the defaults of font
size, highlightthickness etc. to values that seemed to me appropriate in
that context.
Detecting the resolution of the display in use should be easy enough,
just use winfo_screenwidth() ; the values for such an option database
could then easily be calculated depending on the screen size, so maybe
fiddling with the dpi is not necessary.

With ttk widgets things might be more difficult, though. Might be that
the best way in the end is to edit one of the existing ttk themes to fit
your needs and save it as themename_4k or so.
And the checkbutton/radiobutton indicators still will remain tiny (as
well as any other images may seem too small).

Best regards

Michael

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

There is a multi-legged creature crawling on your shoulder.
                -- Spock, "A Taste of Armageddon", stardate 3193.9
_______________________________________________
Tkinter-discuss mailing list
Tkinter-discuss@python.org
https://mail.python.org/mailman/listinfo/tkinter-discuss

Reply via email to