Note that there are some explanatory texts on larger screens.

plurals
  1. POpygtk window moves when resized
    text
    copied!<p>Setup:</p> <ul> <li>OS: Ubuntu Precise (12.04) amd64</li> <li>Python: 2.7.3</li> <li>GTK: 2.24.0</li> <li>WindowManager: metacity and FVWM2 both exhibit the same behavior</li> </ul> <p>I have a small pygtk app that contains (among other widgets) a treeview. The window has resizable=False so as the treeview is expanded/collapsed, the window automatically resizes to fit the content. This all works just fine.</p> <p>The problem is that when the window resizes, it stays centered on where it was. I want the top-left corner of the window to stay in the same spot when the window resizes.</p> <p>I've found that calling parse_geometry() with a +x+y position will induce the desired behavior. But that's not always an option. In the typical case, I want the window to open where the mouse is, not in a fixed location.</p> <p>I suspect I need to set gtk.gdk.HINT_USER_POS, but as best I can tell, pygtk's version of set_geometry_hints() doesn't allow me to pass GdkWindowHints like the C and Perl interfaces do.</p> <p>How can I make the window's top-left corner stay still as the contents cause the window to change size?</p> <p><b>Update:</b></p> <p>Since parse_geometry() sets the bit for me, just before gtk.main(), I call</p> <pre><code>gobject.timeout_add(500, self.fix_window) </code></pre> <p>The callback is:</p> <pre><code>def fix_window(self): self.window.parse_geometry("+%d+%d" % self.window.get_position()) </code></pre> <p>While this works, it's ugly so I'd still appreciate a better alternative.</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