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

2022-03-23 Thread Vasilis Vlachoudis
I forgot to reply to you,

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


works beautifully.
Many thanks!!
___
Tkinter-discuss mailing list
Tkinter-discuss@python.org
https://mail.python.org/mailman/listinfo/tkinter-discuss


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

2022-03-17 Thread Michael Lange
Hi,

On Thu, 17 Mar 2022 09:47:16 +
Vasilis Vlachoudis  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
___
Tkinter-discuss mailing list
Tkinter-discuss@python.org
https://mail.python.org/mailman/listinfo/tkinter-discuss


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

2022-03-17 Thread Vasilis Vlachoudis
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

Vasilis

From: Tkinter-discuss 
[tkinter-discuss-bounces+vasilis.vlachoudis=cern...@python.org] on behalf of 
Michael Lange [klappn...@web.de]
Sent: Thursday, March 17, 2022 10:35
To: tkinter-discuss@python.org
Subject: Re: [Tkinter-discuss] 4k HiDPI displays and tkinter [cont]

Hi,

On Wed, 16 Mar 2022 16:16:36 +
Vasilis Vlachoudis  wrote:

> On the same topic of HiDPI screens, the Treeview seems to calculate
> wrongly the font height (see attach image)
> Do you know any way to correct that?
>

are you possibly using a point-sized font? If yes, maybe there is some
dpi issue again?

Regards

Michael

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

No problem is insoluble.
-- Dr. Janet Wallace, "The Deadly Years", stardate 3479.4
___
Tkinter-discuss mailing list
Tkinter-discuss@python.org
https://mail.python.org/mailman/listinfo/tkinter-discuss
___
Tkinter-discuss mailing list
Tkinter-discuss@python.org
https://mail.python.org/mailman/listinfo/tkinter-discuss


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

2022-03-17 Thread Michael Lange
Hi,

On Wed, 16 Mar 2022 16:16:36 +
Vasilis Vlachoudis  wrote:

> On the same topic of HiDPI screens, the Treeview seems to calculate
> wrongly the font height (see attach image)
> Do you know any way to correct that?
>

are you possibly using a point-sized font? If yes, maybe there is some
dpi issue again?

Regards

Michael

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

No problem is insoluble.
-- Dr. Janet Wallace, "The Deadly Years", stardate 3479.4
___
Tkinter-discuss mailing list
Tkinter-discuss@python.org
https://mail.python.org/mailman/listinfo/tkinter-discuss


Re: [Tkinter-discuss] 4k HiDPI displays and tkinter

2021-07-14 Thread Paul
Title: signature

  
  
style.configure("TScrollbar", arrowsize=10)

  
  
  
  
  
  Regards

Paul
Malherbe

  
  

  

  Phone


  +27(0)28 314 0092

  
  

  Mobile


  +27(0)82 900 5260

  

  
  

  

On 2021/07/14 16:22, Vasilis Vlachoudis
  wrote:


  
  
  I am trying to change the tk widgets
to ttk, so I can globally correct them, e.g.

  root=tk.Tk()
  sb=ttk.Scrollbar(root)
  sb.pack(side=tk.RIGHT,fill=tk.Y)
  style=ttk.Style()

style.configure("TScrollbar",
width="10m")


However the width doesn't apply on the up/downarrows which
  they remain tiny.
Where I can find the style options that I can change?
  
I've tried 
style.configure("TScrollbar.uparrow",
width="10m")
but doesn't work



  

  
Vasilis



  

  


  
  From:
  Tkinter-discuss
  [tkinter-discuss-bounces+vasilis.vlachoudis=cern...@python.org]
  on behalf of Vasilis Vlachoudis
  [vasilis.vlachou...@cern.ch]
  Sent: Wednesday, July 14, 2021 15:48
  To: Aivar Annamaa; tkinter-discuss@python.org
      Subject: Re: [Tkinter-discuss] 4k HiDPI
  displays and tkinter

  
  
Thank you all for the
  suggestions.
  I am going to try them.
  It would have been nice it tk had a global option
to rescale everything by x2
Like in XFCE window manager
  

  

  
Vasilis


  

  


  
  From:
  Tkinter-discuss
  [tkinter-discuss-bounces+vasilis.vlachoudis=cern...@python.org]
  on behalf of Aivar Annamaa
  [aivar.anna...@gmail.com]
  Sent: Tuesday, July 13, 2021 12:41
  To: tkinter-discuss@python.org
  Subject: Re: [Tkinter-discuss] 4k HiDPI
  displays and tkinter

  
  
If you want to relate your screen
  distances to the size of characters in a font,
  then you could use font's `measure` method to
  compute pixel distances for
  em-s: https://github.com/thonny/thonny/blob/3f2607ff0b27ffedac9b24a107ea9fff5f6b1f1f/thonny/ui_utils.py#L2271
  
  
  Best regards,
Aivar



  On Mon, Jul
12, 2021 at 8:13 PM 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?
- c

Re: [Tkinter-discuss] 4k HiDPI displays and tkinter

2021-07-14 Thread Michael Lange
Hi,

On Wed, 14 Jul 2021 14:22:37 +
Vasilis Vlachoudis  wrote:

> I am trying to change the tk widgets to ttk, so I can globally correct
> them, e.g. root=tk.Tk()
> sb=ttk.Scrollbar(root)
> sb.pack(side=tk.RIGHT,fill=tk.Y)
> style=ttk.Style()
> style.configure("TScrollbar", width="10m")
>
> However the width doesn't apply on the up/downarrows which they remain
> tiny. Where I can find the style options that I can change?
> I've tried
> style.configure("TScrollbar.uparrow", width="10m")
> but doesn't work

looking at defaults.tcl helps :)

At least here on X11 with default ttk style

st.configure('TScrollbar', width='10m', arrowsize='10m')

works.

With the default style scaling a checkbutton with

st.configure('TCheckbutton', indicatordiameter='10m')

also works, not with the "alt" theme though (I guess they are using a
bitmap there again).

Best regards

Michael


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

Without freedom of choice there is no creativity.
-- Kirk, "The return of the Archons", stardate 3157.4
___
Tkinter-discuss mailing list
Tkinter-discuss@python.org
https://mail.python.org/mailman/listinfo/tkinter-discuss


Re: [Tkinter-discuss] 4k HiDPI displays and tkinter

2021-07-14 Thread Vasilis Vlachoudis
I am trying to change the tk widgets to ttk, so I can globally correct them, 
e.g.
root=tk.Tk()
sb=ttk.Scrollbar(root)
sb.pack(side=tk.RIGHT,fill=tk.Y)
style=ttk.Style()
style.configure("TScrollbar", width="10m")

However the width doesn't apply on the up/downarrows which they remain tiny.
Where I can find the style options that I can change?
I've tried
style.configure("TScrollbar.uparrow", width="10m")
but doesn't work

Vasilis


From: Tkinter-discuss 
[tkinter-discuss-bounces+vasilis.vlachoudis=cern...@python.org] on behalf of 
Vasilis Vlachoudis [vasilis.vlachou...@cern.ch]
Sent: Wednesday, July 14, 2021 15:48
To: Aivar Annamaa; tkinter-discuss@python.org
Subject: Re: [Tkinter-discuss] 4k HiDPI displays and tkinter

Thank you all for the suggestions.
I am going to try them.
It would have been nice it tk had a global option to rescale everything by x2
Like in XFCE window manager

Vasilis


From: Tkinter-discuss 
[tkinter-discuss-bounces+vasilis.vlachoudis=cern...@python.org] on behalf of 
Aivar Annamaa [aivar.anna...@gmail.com]
Sent: Tuesday, July 13, 2021 12:41
To: tkinter-discuss@python.org
Subject: Re: [Tkinter-discuss] 4k HiDPI displays and tkinter

If you want to relate your screen distances to the size of characters in a 
font, then you could use font's `measure` method to compute pixel distances for 
em-s: 
https://github.com/thonny/thonny/blob/3f2607ff0b27ffedac9b24a107ea9fff5f6b1f1f/thonny/ui_utils.py#L2271

Best regards,
Aivar

On Mon, Jul 12, 2021 at 8:13 PM Vasilis Vlachoudis 
mailto: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?
- checkbox, radiobox the indicator appears tiny wrt the text

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?

Vasilis
___
Tkinter-discuss mailing list
Tkinter-discuss@python.org<mailto:Tkinter-discuss@python.org>
https://mail.python.org/mailman/listinfo/tkinter-discuss
___
Tkinter-discuss mailing list
Tkinter-discuss@python.org
https://mail.python.org/mailman/listinfo/tkinter-discuss


Re: [Tkinter-discuss] 4k HiDPI displays and tkinter

2021-07-14 Thread Vasilis Vlachoudis
Thank you all for the suggestions.
I am going to try them.
It would have been nice it tk had a global option to rescale everything by x2
Like in XFCE window manager

Vasilis


From: Tkinter-discuss 
[tkinter-discuss-bounces+vasilis.vlachoudis=cern...@python.org] on behalf of 
Aivar Annamaa [aivar.anna...@gmail.com]
Sent: Tuesday, July 13, 2021 12:41
To: tkinter-discuss@python.org
Subject: Re: [Tkinter-discuss] 4k HiDPI displays and tkinter

If you want to relate your screen distances to the size of characters in a 
font, then you could use font's `measure` method to compute pixel distances for 
em-s: 
https://github.com/thonny/thonny/blob/3f2607ff0b27ffedac9b24a107ea9fff5f6b1f1f/thonny/ui_utils.py#L2271

Best regards,
Aivar

On Mon, Jul 12, 2021 at 8:13 PM Vasilis Vlachoudis 
mailto: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?
- checkbox, radiobox the indicator appears tiny wrt the text

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?

Vasilis
___
Tkinter-discuss mailing list
Tkinter-discuss@python.org<mailto:Tkinter-discuss@python.org>
https://mail.python.org/mailman/listinfo/tkinter-discuss
___
Tkinter-discuss mailing list
Tkinter-discuss@python.org
https://mail.python.org/mailman/listinfo/tkinter-discuss


Re: [Tkinter-discuss] 4k HiDPI displays and tkinter

2021-07-13 Thread Aivar Annamaa
If you want to relate your screen distances to the size of characters in a
font, then you could use font's `measure` method to compute pixel distances
for *em*-s:
https://github.com/thonny/thonny/blob/3f2607ff0b27ffedac9b24a107ea9fff5f6b1f1f/thonny/ui_utils.py#L2271

Best regards,
Aivar

On Mon, Jul 12, 2021 at 8:13 PM 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?
> - checkbox, radiobox the indicator appears tiny wrt the text
>
> 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?
>
> Vasilis
> ___
> Tkinter-discuss mailing list
> Tkinter-discuss@python.org
> https://mail.python.org/mailman/listinfo/tkinter-discuss
>
___
Tkinter-discuss mailing list
Tkinter-discuss@python.org
https://mail.python.org/mailman/listinfo/tkinter-discuss


Re: [Tkinter-discuss] 4k HiDPI displays and tkinter

2021-07-13 Thread Michael Lange
Hi,

On Mon, 12 Jul 2021 20:31:57 +0100
E Paine  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


Re: [Tkinter-discuss] 4k HiDPI displays and tkinter

2021-07-12 Thread E Paine
> - 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.

> 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

Hope this helped!
___
Tkinter-discuss mailing list
Tkinter-discuss@python.org
https://mail.python.org/mailman/listinfo/tkinter-discuss


Re: [Tkinter-discuss] 4k HiDPI displays and tkinter

2021-07-12 Thread Michael Lange
Hi,

On Mon, 12 Jul 2021 17:13:18 +
Vasilis Vlachoudis  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 "", line 1, in 
  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


[Tkinter-discuss] 4k HiDPI displays and tkinter

2021-07-12 Thread Vasilis Vlachoudis
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?
- checkbox, radiobox the indicator appears tiny wrt the text

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?

Vasilis
___
Tkinter-discuss mailing list
Tkinter-discuss@python.org
https://mail.python.org/mailman/listinfo/tkinter-discuss