[pygtk] How to embed pygtk into a glade created gui?
Kosa
kosa at piradio.org
Mon Jun 16 09:01:28 WST 2008
Well, I FINALLY found a way to do it.
The trick is: first you have to get the hbox (or vbox)
as a variable using "hbox = self.xml.get_widget("glade_hbox")
and then put things into it using pack_start.
I mean, you can use glade to create a gui and you can name a frame,
an vbox, an hbox or something with anyname you want. Then you just
put pure pygtk widgets using pack_start like this..
glade_file = your_glade_file.glade
xml = glade.XML(galde_file,None, None)
window = = xml.get_widget("window") # "window" is the name of a window
you created using glade
hbox__1 = xml.get_widget("hbox_1") # wich is a hbox you puted inside the
"window"
# once done that you create something using pygtk... it this case it
would be a calendar...
calendar = gtk.Calendar()
# and you just ut it inide the "hbox_1" like this...
hbox.pack_start(calendar,False,False,100)
# Is still don't understand what are "False,False," but it has to be a
integer,
#100 is somehow the margin and it can be any number
#Then you just call the window using
window.show_all()
#You need to write a line for every thing you want to put into the box.
#If you want to put a button with the text "hola mundo", you would need
a line like this
button = gtk.Button(label = "hola mundo" #to declare "button"
#and a line like this
hbox.pack_start(button,False,False,100) #to append it into the hbox
#Do not forget the last step is calling the window using window.show:all()
That's it. Sorry for my bad english and thanks for you help.
Kosa
- Un mundo mejor es posible -
Kosa escribió:
> Hi there,
>
> this is my first time here and I'been using
> python for just some weeks. I really love it.
> First time writing code too, and loving it so
> far too.
>
> I'm using glade to build the gui and it works
> very well, but now I want to insert some pure pygtk
> things into it and I don't now how.
>
> I mean, I have this glade created window and it has
> an hbox with three columns. In the first column I put
> a button using glade, in the second I have label and
> the third is empty. I want to put a pygtk created
> calendar there.
>
> I can create a pure pygtk window and calendar, but
> I can't find the way to mix xml glade created guis and
> pygtk.
>
> Please help me.
>
> Thanks in advance.
>
> Kosa
>
> - Un mundo mejor es posible -
> _______________________________________________
> pygtk mailing list pygtk at daa.com.au
> http://www.daa.com.au/mailman/listinfo/pygtk
> Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/
> From - Thu
More information about the pygtk
mailing list