Say I've created a gtk Widget like this:
class AwesomeTextView (gtk.TextView):
def set_font(self, font_description):
self.modify_font(pango.FontDescription(font_description))
How can I add my new widget to the palette in the Glade Interface Builder?
Best Answer
Okay, this is going to be step by step:
AwesomeTextView
, the module it's in will be calledawesome_text_view
. These are the only names we need.A glade widget consists of two parts, the module and the catalog.
We create a catalog,
awesome_text_view.xml
, and (as root) save it at/usr/share/glade3/catalogs/
This is what it looks like:
You should copy and adapt this template, as it works. :-)
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:
It's now displayed in Glade, and you can add it to your application.
Finally, you'll just need to
That's it!
Here's a little test app showing how to use your widget: