Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re: Tk screen and monitor size in mm, DPI and scaling

by kcott (Archbishop)
on Mar 13, 2021 at 05:55 UTC ( [id://11129559]=note: print w/replies, xml ) Need Help??


in reply to Tk screen and monitor size in mm, DPI and scaling

G'day Discipulus,

I don't believe I've ever used either of those mm methods; and I don't think I've used mm sizes for specifying widths, padding, etc. Except for character sizes for a few text-based widgets, I always gone with pixels. Anyway, I was curious and do seem to have a similar issue to what you describe. Here's the output from the test code you posted:

screen name :0.0 pixel width 2560 pixel height 1440 scaling 1.33398982438864 mm width 677 mm height 381

I have Perl 5.32 and Tk 804.035 running on a Cygwin/Win10 OS. The system (Win10 Settings) reports 2560x1440; I'm pretty sure that's accurate. The manufacturer's spec gives the monitor width as 27" — I wonder if that's the physical size (i.e. includes the housing surrounding the useable/viewable part of the screen).

Those numbers would give me a DPI of 94.8148148148148 (2560/27); and, factoring in the scaling, a point size of 1/71.0761154855644" (not the expected 1/72").

I don't know how the mm sizes are determined. I had a look in https://github.com/eserte/perl-tk/blob/master/Tk/Widget.pm but couldn't see anything useful there; it's probably hidden away in XS code somewhere.

I also had a look in "Active bugs for Tk". I didn't see anything relevant but, with 140 outstanding issues, it's not impossible that I missed something. It may be worth raising a bug report.

I don't use PowerShell but I do have it available. I tried your Get-WmiObject command, both as a normal user and as Administrator, and got the same error:

PS C:\WINDOWS\system32> Get-WmiObject -Namespace root\WMI -ComputerNa +me localhost -Query "select InstanceName, MaxHorizontalImagesize, Max +vwerticalImageSize from WmiMoninitorBasicDisplayParams" Get-WmiObject : Invalid class "WmiMoninitorBasicDisplayParams" At line:1 char:1 + Get-WmiObject -Namespace root\WMI -ComputerName localhost -Query "s +e ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +~ + CategoryInfo : InvalidType: (:) [Get-WmiObject], Manage +mentException + FullyQualifiedErrorId : GetWMIManagementException,Microsoft.Powe +rShell.Commands.GetWmiObjectCommand

I, too, was a little surprised at the scaling value. The system (Win10 Settings) reports scaling of 100%; not 133.398982438864%.

— Ken

Replies are listed 'Best First'.
Re^2: Tk screen and monitor size in mm, DPI and scaling
by Discipulus (Canon) on Mar 14, 2021 at 20:47 UTC
    Hello kcott and thanks for looking,

    the Tk scaling is not the windows scaling: you probably already read the vr's answer below. Is like Tk is assuming always a 96dpi settings while nowadays we are always running higher values.

    Me too I dont use powershell but was the only way I found to retrieve physical monitor size and does not works in win7. As vr noted, I had a typo in the powershell cut&paste and if you see above now I have fixed it. I dont use power(s)hell also because its totally unuseful errors (tell me if the error emitted is the relevant one.. ;)

    I love perl for its errors!

    L*

    There are no rules, there are no thumbs..
    Reinvent the wheel, then learn The Wheel; may be one day you reinvent one of THE WHEELS.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11129559]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others imbibing at the Monastery: (3)
As of 2024-03-29 07:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found