Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #60542 > unrolled thread

Tkinter: winfo_screenmmwidth discussion

Started byjosefg@gmail.com
First post2013-11-26 14:13 -0800
Last post2013-12-03 17:33 -0800
Articles 5 — 2 participants

Back to article view | Back to comp.lang.python


Contents

  Tkinter: winfo_screenmmwidth discussion josefg@gmail.com - 2013-11-26 14:13 -0800
    Re: Tkinter: winfo_screenmmwidth discussion Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2013-11-26 17:55 -0500
      Re: Tkinter: winfo_screenmmwidth discussion josefg@gmail.com - 2013-11-26 15:08 -0800
      Re: Tkinter: winfo_screenmmwidth discussion josefg@gmail.com - 2013-11-26 15:09 -0800
    Re: Tkinter: winfo_screenmmwidth discussion josefg@gmail.com - 2013-12-03 17:33 -0800

#60542 — Tkinter: winfo_screenmmwidth discussion

Fromjosefg@gmail.com
Date2013-11-26 14:13 -0800
SubjectTkinter: winfo_screenmmwidth discussion
Message-ID<b4ba86d6-1235-4bd3-a08a-cf9ccf11540d@googlegroups.com>
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.

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 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.

[toc] | [next] | [standalone]


#60544

FromDennis Lee Bieber <wlfraed@ix.netcom.com>
Date2013-11-26 17:55 -0500
Message-ID<mailman.3258.1385506557.18130.python-list@python.org>
In reply to#60542
On Tue, 26 Nov 2013 14:13:57 -0800 (PST), josefg@gmail.com declaimed the
following:

>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>)




-- 
	Wulfraed                 Dennis Lee Bieber         AF6VN
    wlfraed@ix.netcom.com    HTTP://wlfraed.home.netcom.com/

[toc] | [prev] | [next] | [standalone]


#60547

Fromjosefg@gmail.com
Date2013-11-26 15:08 -0800
Message-ID<49df0f66-f363-4de9-ac17-592bf5ab074f@googlegroups.com>
In reply to#60544
On Tuesday, November 26, 2013 2:55:52 PM UTC-8, Dennis Lee Bieber wrote:
> On Tue, 26 Nov 2013 14:13:57 -0800 (PST), josefg@gmail.com declaimed the
> 
> following:
> 
> 
> 
> >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>)
> 
> 
> 
> 
> 
> 
> 
> 
> 
> -- 
> 
> 	Wulfraed                 Dennis Lee Bieber         AF6VN
> 
>     wlfraed@ix.netcom.com    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 vertical mm). Those should be accurate regardless of OS and current resolution setting.

[toc] | [prev] | [next] | [standalone]


#60549

Fromjosefg@gmail.com
Date2013-11-26 15:09 -0800
Message-ID<fb93aad8-7928-4ed4-a887-23045aabc3d7@googlegroups.com>
In reply to#60544
On Tuesday, November 26, 2013 2:55:52 PM UTC-8, Dennis Lee Bieber wrote:
> On Tue, 26 Nov 2013 14:13:57 -0800 (PST), josefg@gmail.com declaimed the
> 
> following:
> 
> 
> 
> >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>)
> 
> 
> 
> 
> 
> 
> 
> 
> 
> -- 
> 
> 	Wulfraed                 Dennis Lee Bieber         AF6VN
> 
>     wlfraed@ix.netcom.com    HTTP://wlfraed.home.netcom.com/


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

[toc] | [prev] | [next] | [standalone]


#60982

Fromjosefg@gmail.com
Date2013-12-03 17:33 -0800
Message-ID<46210473-d5e9-421d-a9fd-1a4a66423f20@googlegroups.com>
In reply to#60542
On Tuesday, November 26, 2013 2:13:57 PM UTC-8, jos...@gmail.com wrote:
> 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.
> 
> 
> 
> 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 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))

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web