You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
importtkintertkinter.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.
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'.
Activity
Ackbach commentedon Oct 7, 2018
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
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!
terryjreedy commentedon Oct 12, 2018
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'.
serhiy-storchaka commentedon Oct 12, 2018
This is a Tk issue. Tkinter returns the same result as a plain Tk (unsurprisingly).