Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am using Quickly and Glade for the first time. I want to add certain widgets such as label and buttons on viewport via python code. Is it possible?

share|improve this question
up vote 1 down vote accepted

Yes, you can. If you haven't already loaded the glade file the load it with:

builder = gtk.Builder()

Replace "/path/to/file" with the path to the glade file. You can then get the container like the viewport:

viewport = builder.get_object("nameOfViewport")

Replace "nameOfViewport" with what you named it in glade. You can then add the widget using the view ports add() method:


Replace "nameOfWidget" with the name of the widget you want to add.

Edit: Make sure you initialize the widget with something like

nameOfWidget = gtk.Label()

for a label widget.

share|improve this answer
Hii i tried with it, giving error as, TypeError: Expected Gtk.Widget, but got GObjectMeta – gau1991 Jun 21 '12 at 15:43
When adding the widget you need to either initialize it using something like "label = gtk.Label()" and then add label to the viewport or just "viewport.add(gtk.Label())" but I would reccomend the first method. – Sam Bickley Jun 21 '12 at 15:54
Thanks buddy now its working... – gau1991 Jun 21 '12 at 16:01

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.