[pygtk] Centering widgets horizontally on screen

Pietro Battiston toobaz at email.it
Thu Aug 27 15:39:55 WST 2009


Il giorno mer, 26/08/2009 alle 23.28 -0400, Art Hunkins ha scritto:
> Hello, Saeed,
> 
> I need a little more help.
> 
> Following one of your examples, here is the code I wrote (import gtk is of 
> course included):
> 
>    but1 = gtk.Button("    1 - MyMusicMIDI ?     ")
>    but2 = gtk.Button("    2 - MyMusicASCII ?    ")
>    but3 = gtk.Button("    3 - OurMusicMIDI ?    ")
>    but4 = gtk.Button("    4 - OurMusicASCII ?   ")
>    hbox = gtk.HBox()
>    hbox.pack_start(but1, False, False)
>    hbox.pack_start(but2, False, False)
>    hbox.pack_start(but3, False, False)
>    hbox.pack_start(but4, False, False)
>    win2 = gtk.Window()
>    win2.add(hbox)
>    win2.show_all() [I also tried: win2.show()]

This code works perfectly to me (if I just add "import gtk" before and
"gtk.main()" after... so if you have problems maybe you should post the
entire code...


> 
> This code is placed right under other code that displays on the screen just 
> fine; however, *this* code displays nothing. What am I lacking?


It's a stupid question, I know, but did you insert your code _between_
the existing gtk code and the gtk.main() call (instead than after both)?

Pietro



More information about the pygtk mailing list