python - Unexpected behaviour in pygtk Window resizing -


i writing code obtain size of physical screen , use dimensions resize window :

#!/usr/bin/env python  import gtk  class gettingstarted:     def __init__(self):         window = gtk.window()         width = gtk.gdk.screen.get_width()#line1         height = gtk.gdk.screen.get_height()#line2         window.resize(width,height)#line3         label = gtk.label("hello")         window.add(label)          window.connect("destroy", lambda q : gtk.main_quit())         window.show_all()  gettingstarted() gtk.main() 

with line1,line2,line3 commented out of code, regular window "hello" displayed on screen. aforesaid lines included in code, calendar displayed reason! error thrown :

traceback (most recent call last):   file "gettingstarted.py", line 17, in <module>     gettingstarted()   file "gettingstarted.py", line 8, in __init__     width = gtk.gdk.screen.get_width() typeerror: descriptor 'get_width' of 'gtk.gdk.screen' object needs argument 

there's no mention of arguments get_width() or get_height() in docs.what's happening?

you using class instead of instance in 2 locations, line1 , line2, try gtk.gdk.screen_get_default() instead of gtk.gdk.screen in both locations.

#!/usr/bin/env python  import gtk  class gettingstarted:     def __init__(self):         window = gtk.window()         width = gtk.gdk.screen_get_default().get_width()#line1         height = gtk.gdk.screen_get_default().get_height()#line2         window.resize(width,height)#line3         label = gtk.label("hello")         window.add(label)          window.connect("destroy", lambda q : gtk.main_quit())         window.show_all()  gettingstarted() gtk.main() 

Comments

Popular posts from this blog

java - WrongTypeOfReturnValue exception thrown when unit testing using mockito -

php - Magento - Deleted Base url key -

android - How to disable Button if EditText is empty ? -