Note that there are some explanatory texts on larger screens.

plurals
  1. POHow do I get the size of a pygtk window?
    text
    copied!<p>I'm trying to use gtk.window.get_size(), but it always just returns the default width and height. <a href="http://www.pygtk.org/docs/pygtk/class-gtkwindow.html#method-gtkwindow--get-size" rel="nofollow">The documentation says</a></p> <blockquote> <p>The get_size() method returns a tuple containing the current width and height of the window. If the window is not on-screen, it returns the size PyGTK will suggest to the window manager for the initial window size. The size obtained by the get_size() method is the last size received in a configure event, that is, PyGTK uses its locally-stored size, rather than querying the X server for the size. As a result, if you call the resize() method then immediately call the get_size() method, the size won't have taken effect yet. After the window manager processes the resize request, PyGTK receives notification that the size has changed via a configure event, and the size of the window gets updated.</p> </blockquote> <p>I've tried resizing the window manually and waiting a minute or so, but I still get the default width and height.</p> <p>I'm trying to use this to save the window size on quit so that I can restore it on start. Is there a better way to do this?</p> <p>Here's the code snipit I have for my main quit.</p> <pre><code>def on_main_window_destroy(self, widget, data=None): if self.view.current_view.layout == 'list': self.view.current_view.set_column_order() width = self.main_window.get_size()[0] height = self.main_window.get_size()[1] #test statement print (width, height) self.prefs.set_size_prefs(width, height) self.prefs.set_view_prefs(self.view.current_view.media, self.view.current_view.layout) gtk.main_quit() </code></pre> <p>I think I understand what's happening now. This is inside the destroy signal, so by the time the code gets called, the window is already gone. Is there a more canonical way of handling window resizing? I was hoping to avoid handling resize events everytime the user resized the window.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload