Getting User Display Information

Christopher T King squirrel at WPI.EDU
Wed Jun 30 12:10:45 EDT 2004


> I was wondering if it was possible to get the screen display size and
> other associated properties somehow either using python modules or if
> possible using Tk methods.

Using Tkinter:

from Tkinter import Tk
w=Tk()
print w.winfo_screenwidth(),w.winfo_screenheight()
w.destroy()

There's a plethora of other information available as methods of the Tk 
object (actually any Tkinter widget), including color depth, cursor 
position, window manager type, etc.

Note that this is actually creating a Tk window; calling its destroy() 
method right after you've finished with it prevents it from appearing on 
screen. Don't do this if you actually are creating a GUI with Tk.




More information about the Python-list mailing list