===================================================================
RCS file: RCS/faq10.003.htp,v
retrieving revision 1.6
retrieving revision 1.10
diff -u -r1.6 -r1.10
--- faq10.003.htp 2004/09/23 03:45:24 1.6
+++ faq10.003.htp 2009/06/12 09:12:04 1.10
@@ -1,9 +1,9 @@
Title: 10.3. How do I get my windows to show up where I want?
-Last-Changed-Date: Thu Sep 23 00:45:24 2004
-Last-Changed-Author: Christian Robottom Reis
-Last-Changed-Email: kiko@async.com.br
-Last-Changed-Remote-Host: manonegra.async.com.br
-Last-Changed-Remote-Address: 192.168.99.6
+Last-Changed-Date: Fri Jun 12 04:12:04 2009
+Last-Changed-Author: Pietro Battiston
+Last-Changed-Email: toobaz@email.it
+Last-Changed-Remote-Host:
+Last-Changed-Remote-Address: 137.204.30.43
The short answer is: you don't; in X11, the window manager usually decides where the window is going to show up. However, you can provide hints so it has an idea of where the best place might be. Matt Wilson says:
@@ -25,13 +25,15 @@
When d is displayed, the window manager will know it is a transient for the parent window. By calling set_position it will [usually] be placed centered upon the parent.
+(Note that some X11 servers such as Xming appear not to honour these placement settings.)
+
To do this with a dialog defined in a glade file, you'll need to do something like:
d = glade_tree.get_widget(dialog_name)
d.set_position(gtk.WIN_POS_CENTER_ON_PARENT)
d.set_transient_for(parent_window)
-If you want to specify positioning further -- to get a centered dialog, for instance -- you can use other options to the GtkWindow.set_position() method, which is described at http://www.moeraki.com/pygtkreference/pygtk2reference/class-gtkwindow.html#method-gtkwindow--set-position
+If you want to specify positioning further -- to get a centered dialog, for instance -- you can use other options to the GtkWindow.set_position() method, which is described at http://www.pygtk.org/docs/pygtk/class-gtkwindow.html#method-gtkwindow--set-position
You can also save and restore the window position and size. Save the position with:
@@ -40,6 +42,6 @@
Later restoring it with:
- w = gtk.GtkWindow()
+ w = gtk.Window()
w.move(x, y)
- w.set_size_request(w, h)
+ w.resize(w, h)