I\'m trying to use gtk.window.get_size(), but it always just returns the default width and height. The documentation says
The get_size() method return
This seems to fix your problem:
import gtk
def print_size(widget, data=None):
print window.get_size()
def delete_event(widget, data=None):
print window.get_size()
return False
def destroy(widget, data=None):
gtk.main_quit()
window = gtk.Window()
window.connect('delete_event', delete_event)
window.connect('destroy', destroy)
button = gtk.Button(label='Print size')
button.connect('clicked', print_size)
window.add(button)
window.show_all()
gtk.main()
I think the key is calling get_size
on the delete_event
signal rather than the destroy
signal. If you do it on the destroy
signal, it's like you describe, it just returns the default size.