RCS/faq10.003.htp,v --> standard output
revision 1.4
Title: 10.3. How do I get my windows to show up where I want?
Last-Changed-Date: Wed Oct 22 15:23:44 2003
Last-Changed-Author: Christian Reis
Last-Changed-Email: kiko@async.com.br
Last-Changed-Remote-Host: manonegra.async.com.br
Last-Changed-Remote-Address: 192.168.99.6
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:
The window manager is responsible for placing the window on the screen
when mapped if it isn't given an exact position. For dialog boxes,
make sure you're passing in the parent window when creating the dialog
box. Then GTK will set up the correct hints that would make window
managers treat the dialog window as a child of its parent. How the
window manager decides to treat the placement is configurable in some
window managers...
If you would like to specify that a dialog is a `sub-window' of a window, for instance, you can use the following command:
w = gtk.GtkWindow()
# ...
d = gtk.GtkDialog()
d.set_transient_for(w)
When d is displayed, the window manager will know it is a transient for the parent window; it will usually be placed centered upon the parent.
To do this with a dialog defined in a glade file, you'll need to do something like:
glade_tree.get_widget(dialog_name).set_transient_for(parent_window)
If you want to specify positioning further -- to get a centered dialog, for instance -- you can also use the GtkWindow.set_position() method, which is described at http://www.moeraki.com/pygtkreference/pygtk2reference/class-gtkwindow.html#method-gtkwindow--set-position