pyGTK -- why can't I center a window?

Grant Edwards ge at nowhere.none
Thu Oct 12 10:54:01 EDT 2000


In article <8s4d18$aqt$1 at nnrp1.deja.com>, python9999 at my-deja.com wrote:
>for setting any widget in gtk to center position you just have to do
>these simple steps.
>for example
>	win=GtkDialog()
>	win.set_position(WIN_POS_CENTER)
>	win.show()

That is what I'm doing, and it doesn't work.  Below is a
complete example.  The dialog box does not come up centered on
the screen.  Other apps (non-gtk based ones: Motif, Lesstif and
Tk) don't seem to have any trouble positioning their dialog
boxes -- but I've noticed that other gtk-based ones (like grip)
have dialog boxes that pop up in "empty" places on the screen
even though they are supposed to be centered.  Does this
example work correctly for other people?

----------------------------------------------------------------------
from gtk import *
from GDK import *

b = GtkButton("Quit")
b.connect('clicked',mainquit)
b.connect('destroy',mainquit)

win = GtkWindow()
win.set_border_width(20)
win.add(b)
win.show_all()

dialog = GtkDialog()

def dialogDismiss(*args):
    dialog.destroy()
    
b = GtkButton("OK")
b.connect('clicked',dialogDismiss)
dialog.vbox.pack_start(GtkLabel(" Hello World "))
dialog.action_area.pack_start(b)

dialog.set_position(WIN_POS_CENTER)
dialog.show_all()

mainloop()
    
-- 
Grant Edwards                   grante             Yow!  .. are the STEWED
                                  at               PRUNES still in the HAIR
                               visi.com            DRYER?



More information about the Python-list mailing list