Skip,
How about just defining a connect method for your ColorScale class in
which you keep track of the callback function yourself. Then when the
color changes, call the function if it has been set:
class ColorScale(gtk.GtkTable):
def __init__(self, *args):
<bla bla bla>
self.color_changed_func = None
def connect_color_change(self, func):
if callable(func):
self.color_changed_func = func
def emit_color_changed(self, ...):
if callable(self.color_changed_func):
self.color_changed_func(...)
Ralph Walden
[EMAIL PROTECTED] wrote:
> I want to create a compound widget that consists of a GtkTable,
> three labels (red, green, blue) and an HScale for each color. Furthermore,
> I'd like to define a new signal for the subclass, let's call it
> "color-changed". My compound widget would connect to the "value-changed"
> signals from each of the HScales, update its notion of the current color
> (perhaps by converting to a "#XXXXXX"-style string), then emit
> "color-changed", so code that is interested can notice when any of the
> HScales changes value without me having to expose them directly. The
> question is, can I do that from PyGtk2? I've never used PyGtk1.2, but I was
> under the impression that you couldn't do what I want there.
>
> To make things even more concrete, here's a skeleton:
>
> class ColorScale(gtk.GtkTable):
> def __init__(self, *args):
> gtk.GtkTable.__init__(self, *args)
> self.red = gtk.GtkHScale()
> self.green = gtk.GtkHScale()
> self.blue = gtk.GtkHScale()
> self.attach_defaults(self.red, ...)
> self.attach_defaults(self.green, ...)
> self.attach_defaults(self.blue, ...)
> # connect emit_color_changed to HScale "value-changed" signals
>
> def emit_color_changed(self, ...):
> self.emit("color-changed", ...)
>
> ... do the signal dance ...
>
> At "do the signal dance" I would like to define the "color-changed" signal
> for my new class.
>
> Skip
>
--
Ralph E. Walden
Tripos, Inc.
[EMAIL PROTECTED]
_______________________________________________
pygtk mailing list [EMAIL PROTECTED]
http://www.daa.com.au/mailman/listinfo/pygtk