Skip to content

Python 3 tkinter measurement problem #79099

Closed

Description

@Ackbach
mannequin
BPO 34918
Nosy @terryjreedy, @serhiy-storchaka, @Ackbach

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields:

assignee = None
closed_at = <Date 2018-10-12.17:05:24.373>
created_at = <Date 2018-10-07.05:09:01.046>
labels = ['3.7', '3.8', 'type-bug', 'expert-tkinter']
title = 'Python 3 tkinter measurement problem'
updated_at = <Date 2018-10-12.17:05:24.362>
user = 'https://github.com/Ackbach'

bugs.python.org fields:

activity = <Date 2018-10-12.17:05:24.362>
actor = 'serhiy.storchaka'
assignee = 'none'
closed = True
closed_date = <Date 2018-10-12.17:05:24.373>
closer = 'serhiy.storchaka'
components = ['Tkinter']
creation = <Date 2018-10-07.05:09:01.046>
creator = 'Ackbach'
dependencies = []
files = []
hgrepos = []
issue_num = 34918
keywords = []
message_count = 3.0
messages = ['327265', '327598', '327599']
nosy_count = 3.0
nosy_names = ['terry.reedy', 'serhiy.storchaka', 'Ackbach']
pr_nums = []
priority = 'normal'
resolution = 'third party'
stage = 'resolved'
status = 'closed'
superseder = None
type = 'behavior'
url = 'https://bugs.python.org/issue34918'
versions = ['Python 3.6', 'Python 3.7', 'Python 3.8']

Activity

  1. Ackbach commented on Oct 7, 2018

    Ackbachmannequin
    MannequinAuthor

    tkinter.Tk().winfo_screenmmwidth() and tkinter.Tk().winfo_screenmmheight() give manifestly incorrect values in Windows. This does not appear to be an issue in Linux. I have not tested a Mac. The values reported in Windows are too large by as much as 58%. Searching online seems to indicate that the issue is some applications in Windows are "dpi aware"; unfortunately, none of the so-called work-arounds I've found actually fix the problem. The tkinter.Tk().winfo_screenwidth() and tkinter.Tk().winfo_screenheight() functions, reporting their results in pixels, appear to be correct. A MWE is simply

    import tkinter
    tkinter.Tk().winfo_screenmmwidth()

    This reports a 508 mm on my 15.6" screen, when the true value is closer to 343 mm. This is a 48% error, and hence an unusable result.

    Thank you for your time!

  2. added
    type-bug
    on Oct 7, 2018
  3. terryjreedy commented on Oct 12, 2018

    @terryjreedy
    Member

    I cannot reproduce 'too large'. My screen in 340 mm high. It is reported as 305 in console Python 3.7.1rc1 and in IDLE run normally and with -n (no subprocess) and in console Python 3.6.7. The point of trying '-n' is to run the test code in the IDLE process, which now makes a DPIAwareness call. I am fairly sure that my console does not.

    In any case, tkinter interfaces to tcl/tk via _tkinter. Unless it can be shown that _tkinter distorts the value returned by tk, I think this should be closed as '3rd party'.

  4. added
    3.7 (EOL)
    3.8 (EOL)
    on Oct 12, 2018
  5. serhiy-storchaka commented on Oct 12, 2018

    @serhiy-storchaka
    Member

    This is a Tk issue. Tkinter returns the same result as a plain Tk (unsurprisingly).

    $ rlwrap wish
    % winfo screenmmwidth .
    1016
    % winfo screenwidth .
    3840
    % puts [expr "25.4*[winfo screenwidth .]/[winfo screenmmwidth .]"]
    96.0
  6. transferred this issue fromon Apr 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    3.7 (EOL)3.8 (EOL)topic-tkintertype-bug

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions