Say I've created a gtk Widget like this:

class AwesomeTextView (gtk.TextView):

    def set_font(self, font_description):

How can I add my new widget to the palette in the Glade Interface Builder?

enter image description here


Okay, this is going to be step by step:

  • Our widget is going to be named AwesomeTextView, the module it's in will be called awesome_text_view. These are the only names we need.

A glade widget consists of two parts, the module and the catalog.

  1. We create a catalog, awesome_text_view.xml, and (as root) save it at /usr/share/glade3/catalogs/

    This is what it looks like:

    <glade-catalog name="awesome_text_view"
       <glade-widget-class title="Awesome TextView"
     <glade-widget-group name="python" title="Python">
       <glade-widget-class-ref name="AwesomeTextView"/>

    You should copy and adapt this template, as it works. :-)

  2. We create a module, awesome_text_view.py, and (again as root) save it at /usr/lib/glade3/modules/

    Here's what that looks like:

    import gobject
    import gtk
    import pango
    class AwesomeTextView (gtk.TextView):
        __gtype_name__ = 'AwesomeTextView'
        def __init__(self):
        def set_font(self, font_description):

    It's now displayed in Glade, and you can add it to your application.

  3. Finally, you'll just need to

        export PYTHONPATH="$PYTHONPATH:/usr/lib/glade3/modules/"

That's it!

Here's a little test app showing how to use your widget:

import gtk
import awesome_text_view

class App (object):

    builder = gtk.Builder()

    def __init__(self):

    def on_window1_destroy(self, widget):

  • So in practice, there is no way to easily distribute the custom widget with your code and let contributors add it to Glade without them having to manually install it on their systems, I understand. Glade is great, a pity that custom widgets cannot be added without having to go into the guts of the system. In any case, nice answer! – David Planella May 29 '12 at 17:50
  • This doesn't work for me in 12.04. Glade prints this: (glade:25053): GladeUI-WARNING **: Failed to load external library 'gladepython' – user1477 Jun 11 '12 at 23:59

You need to make a catalog for your widgets, see this folder: /usr/share/glade3/catalogs/ and you'll see gnome.xml, have a look for an example.

See also the gnome documentation:


  • Doesn't work :-( It seems that the documentation is simply wrong, I'll update my question. Also, did you mean gtk+.xml, or am I just missing gnome.xml for some reason? – Stefano Palazzo Apr 13 '11 at 14:26
  • You have to make your own xml file, not modify an existing one. – Martin Owens -doctormo- Apr 13 '11 at 15:17
  • I understood that, it's just that I don't have gnome.xml, and I wondered if that might be indicative of a problem. Instructions in the link you've posted are wrong in any case, still working on it :-) – Stefano Palazzo Apr 13 '11 at 16:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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