Tkinter: winfo_screenmmwidth discussion

J

josefg

I am currently using Windows 7 Sp1, Tkinter 8.5, Python 2.7.4 on a laptop with no attached monitor. I am attempting to use winfo_screenmmwidth, but the returned value is incorrect. Specs state 280 mm. Physical measurement is 275 mm. EDID states 280 mm. Tkinter's winfo_screenmmwidth returns 361 mm. Idon't have very much tkinter experience, please bear with me.

From where does winfo_screenmmheight get this information? I have looked through the source code and can't really find the source. The source code seems to lead to WidthMMOfScreen(Screen(tkwin)) in both tkGet.c and tkObj.c. Xlib.h defines the Screen structure which has mwidth defined in it. Xlib.h also defines WidthMMOfScreen as a macro "#define WidthMMOfScreen(s) ((s)->mwidth)" The X Window System Protocol:8 Connection Setup:Screen Information states "Width-in-millimeters and height-in-millimeters can be used to determine the physical size and the aspect ratio," but I'm not sure where the code is for the request.

So that's where I stopped on the X Windows side of things. I think I need to look at the source code for _tkinter.lib, but I'm not sure. I downloaded and started to look at the pywin32.exe (win32all) source code, but I'm not sure where to start with that either. I was expecting to see an entry whichreturns the EDID information, but I have not seen that yet.

Could somebody point me in the right direction? Or does anyone have any ideas?

Thank you in advance.
 
D

Dennis Lee Bieber

I am currently using Windows 7 Sp1, Tkinter 8.5, Python 2.7.4 on a laptop with no attached monitor. I am attempting to use winfo_screenmmwidth, but the returned value is incorrect. Specs state 280 mm. Physical measurement is 275 mm. EDID states 280 mm. Tkinter's winfo_screenmmwidth returns 361 mm. I don't have very much tkinter experience, please bear with me.
Windows systems used to be quite lax on monitor size... Two monitors of
physically different sizes having the same pixel dimensions could possibly
report as being the same width. Especially if one is not using 100% for
text size and for DPI setting.

My current monitor is 20.5 inches across (by steel tape measure), but
Windows defaults to 96DPI... Which comes to a 20 inch width when using
1920x1200 (native mode). The real resolution is 93.66DPI (while my previous
computer ran a clean 100DPI <G>)
 
J

josefg

Windows systems used to be quite lax on monitor size... Two monitors of

physically different sizes having the same pixel dimensions could possibly

report as being the same width. Especially if one is not using 100% for

text size and for DPI setting.



My current monitor is 20.5 inches across (by steel tape measure), but

Windows defaults to 96DPI... Which comes to a 20 inch width when using

1920x1200 (native mode). The real resolution is 93.66DPI (while my previous

computer ran a clean 100DPI <G>)









--

Wulfraed Dennis Lee Bieber AF6VN

(e-mail address removed) HTTP://wlfraed.home.netcom.com/

"Windows systems used to be quite lax on monitor size... Two monitors of
physically different sizes having the same pixel dimensions could possibly
report as being the same width."

Check your monitor's EDID bytes 21 (max horizontal mm) and 22 (max verticalmm). Those should be accurate regardless of OS and current resolution setting.
 
J

josefg

Windows systems used to be quite lax on monitor size... Two monitors of

physically different sizes having the same pixel dimensions could possibly

report as being the same width. Especially if one is not using 100% for

text size and for DPI setting.



My current monitor is 20.5 inches across (by steel tape measure), but

Windows defaults to 96DPI... Which comes to a 20 inch width when using

1920x1200 (native mode). The real resolution is 93.66DPI (while my previous

computer ran a clean 100DPI <G>)









--

Wulfraed Dennis Lee Bieber AF6VN

(e-mail address removed) HTTP://wlfraed.home.netcom.com/


Check your monitor's EDID bytes 21 (max horizontal mm) and 22 (max verticalmm). Those should be accurate regardless of OS and current resolution setting.
 
J

josefg

I am currently using Windows 7 Sp1, Tkinter 8.5, Python 2.7.4 on a laptopwith no attached monitor. I am attempting to use winfo_screenmmwidth, but the returned value is incorrect. Specs state 280 mm. Physical measurement is 275 mm. EDID states 280 mm. Tkinter's winfo_screenmmwidth returns 361 mm.I don't have very much tkinter experience, please bear with me.



From where does winfo_screenmmheight get this information? I have looked through the source code and can't really find the source. The source code seems to lead to WidthMMOfScreen(Screen(tkwin)) in both tkGet.c and tkObj.c.Xlib.h defines the Screen structure which has mwidth defined in it. Xlib.halso defines WidthMMOfScreen as a macro "#define WidthMMOfScreen(s) ((s)->mwidth)" The X Window System Protocol:8 Connection Setup:Screen Informationstates "Width-in-millimeters and height-in-millimeters can be used to determine the physical size and the aspect ratio," but I'm not sure where the code is for the request.



So that's where I stopped on the X Windows side of things. I think I needto look at the source code for _tkinter.lib, but I'm not sure. I downloaded and started to look at the pywin32.exe (win32all) source code, but I'm not sure where to start with that either. I was expecting to see an entry which returns the EDID information, but I have not seen that yet.



Could somebody point me in the right direction? Or does anyone have any ideas?



Thank you in advance.

I wrote this to extract the EDID information. It's not very robust and for some reason not all of the subkeys are iterated in a sub key. I also haven't gotten a response from the tcl/tk folks yet.

import _winreg

def screen_wh():
"""Input - none
Output - Screen's physical (width, height)"""
hive = _winreg.HKEY_LOCAL_MACHINE
path = "SYSTEM\\CurrentControlSet\\Enum\\DISPLAY"
number = 0
rtpath = None

def search_subkeys(hive, path, number, rtpath):
number = number + 1
key = _winreg.OpenKey(hive, path, 0, _winreg.KEY_READ)
try:
i = 0
while 1:
name = _winreg.EnumKey(key, i)
#print(" "*number + name, i) #Used to view registry path
#for some reason this does not iterate over all registry keys crappy fix
if i == 2:
try:
#This works with a direct call, but it's not very portable.
name2 = _winreg.EnumKey(key, 3)
if name2 == "Control":
rtpath = path
except WindowsError:
pass
if rtpath == None:
rtpath = search_subkeys(hive, path+"\\"+name, number,rtpath)
i += 1
except WindowsError:
pass

return(rtpath)

monitor = search_subkeys(hive,path, number,rtpath)
print("EDID registry path: {0}".format(monitor))
key = _winreg.OpenKey(hive, monitor+"\\Device Parameters")
try:
i = 0
while 1:
name, data, type = _winreg.EnumValue(key, i)
if name == 'EDID':
break
except WindowsError:
"EDID not found"
width = int(data[21].encode('hex'),16) * 10
height = int(data[22].encode('hex'),16) * 10
print("Width: {0} mm\nHeight: {1} mm".format(width,height))
return((width, height))
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,981
Messages
2,570,188
Members
46,731
Latest member
MarcyGipso

Latest Threads

Top