[pygtk] Replacing a widget using libglade?

Andi Albrecht albrecht.andi at googlemail.com
Wed Jan 23 14:34:11 WST 2008


Two suggestions how you could use custom widgets together with glade files:

1) Create a Glade file with the Box, your menubar, an empty slot and
your statusbar and then add your CustomDrawingArea in the source code:

box = self.widgets.get_widget("vbox")
da = CustomDrawingArea()
box.pack_start(da)
box.reorder_child(da, 1)
da.show_all()

2) Create a dummy widget in the Glade file and replace it with your
CustomDrawingArea (of course, this looks better in Glade):

box = self.widgets.get_widget("vbox")
dummy = self.widgets.get_widget("dummy_widget")
da = CustomDrawingArea()
box.remove(dummy)
box.pack_start(da)
box.reorder_child(da, 1)

Regards,

Andi
da.show_all()

2008/1/22, Bil Simser <emailme at bilsimser.com>:
>
>
>
>
> Hi guys,
>
>
>
> I'm trying to figure out how to leverage libglade with my pygtk app. I have
> a window that contains a vbox with menu at the top and status bar at the
> bottom. I have a custom widget in code (inherited from gtk.DrawingArea) that
> I want to slip in between the menu and status bar. I'm not sure how I can do
> this without just ignoring the glade file and loading the widgets manually
> into a new vbox. I tried just adding in a stock DrawingArea widget onto my
> glade form and replacing it with something like this:
>
>
>
> self.stockDrawingArea = self.widgets.get_widget("drawingAreaPlaceHolder")
>
> self.stockDrawingArea = CustomDrawingArea()
>
>
>
> but of course that just assigns the object twice.
>
>
>
> I can do something like this in my code:
>
>
>
> Vbox = gtk.Vbox()
>
> Vbox.pack_start(widgets.get_widget("menuBar"))
>
> Vbox.pack_start(CustomDrawingArea())
>
> Vbox.pack_start(widgets.get_widget("statusBar"))
>
>
>
> But that seems like I'm misusing glade.
>
>
>
> Any suggestions?
> _______________________________________________
> 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/
>
>


More information about the pygtk mailing list