Thanks for the reply, and sorry, I should really have posted the source first thing. Here's a cut down version of the class (I just stripped out all the cairo drawing code and the code I use to respond to update signals):
Code:
class NewWidget(Gtk.ToggleButton):
__gtype_name__ = 'NewWidget'
def __init__(self):
Gtk.ToggleButton.__init__(self)
self.face = Gtk.DrawingArea()
self.add(self.face)
self.connect('draw', self.draw)
self.face.connect('draw', self.face_draw)
self.connect('realize', self.realize)
def draw(self, *args):
self.face.queue_draw()
def face_draw(self, drawingarea, context):
...
def realize(self, *args):
self.face.realize()
def update(self, *args):
self.face.queue_draw()
I'm subclassing from Gtk imported from gi.repository, which if you're not familiar with it, is Python's GObject introspection bindings. I'm pretty sure this means it's subclassing from the same GObject that I'd be subclassing from if I wrote the widget more or less from scratch, which I guess means I can override/add signals etc. if I need to (that was the plan anyway). This widget is going to be a reusable one (I've loaded it into a Glade catalog for the project), which is why I wanted it all wrapped up nicely in a class. My hope was that in subclassing directly from ToggleButton, I'd be able to keep all the functionality I still wanted, and just tack on the DrawingArea and any extra bits I needed.