Re: Please don't drop support for Curve

Ignoring the tone of your email and trying to make a point of that creating your own widget is relatively easy, I created an example showing a skeleton of a Gamma curve widget in Python and GooCanvas for your convenience. The example shows the power of using GooCanvas for doing the widget definition and how easy it is to create signals that notify that user of the widget of application changes. Note, that I have not added resize support. To get that you need to listen for the "configure" event.

An example gtk widget using the goo canvas.
Dov Grobgeld <dov grobgeld gmail com>
Sunday 2011-05-08 00:20
This file is in the public domain
import gobject
import gtk
import goocanvas
import math
class GooGammaCurve(goocanvas.Canvas):
    __gsignals__ = {
        "gamma-changed": (gobject.SIGNAL_RUN_LAST,
                          gobject.TYPE_NONE,          # Return type
                          (gobject.TYPE_FLOAT, ))     # Signature of signal

    def __init__(self):
        """Build the goocanvas widget and internal members"""
        self.height,self.width = 100,100
        root = self.get_root_item()
        m,w,h = self.margin, self.width, self.height
        self.axis = goocanvas.Group(parent=root)
        self.axis_x = goocanvas.Polyline(parent=self.axis,
                                         points = goocanvas.Points([(m,h-m),
        self.axis_y = goocanvas.Polyline(parent=self.axis,
                                         points = goocanvas.Points([(m,h-m),
        graph = [(0.01*i,
                  0.01*i) for i in range(100)]
        points = [self.curve_point_to_canvas(p) for p in graph]
        curve = goocanvas.Points(points)
        self.curve = goocanvas.Polyline(parent=root,
        wx,wy = self.curve_point_to_canvas((0.5,0.5))
        self.handle = goocanvas.Rect(parent=root,

    def rect_center(self, item):
        """Get the center coordinate of a rectangle"""
        bbox = item.get_bounds()
        return (0.5*(bbox.x1+bbox.x2),

    def setup_item_signals (self, item):
        item.connect ("motion_notify_event", self.on_motion_notify)
        item.connect ("button_press_event", self.on_button_press)
        item.connect ("button_release_event", self.on_button_release)

    def on_motion_notify (self, item, target, event):
        if (self.dragging == True) and (event.state & gtk.gdk.BUTTON1_MASK):
            new_x = event.x
            new_y = event.y
            # only move in y direction
            item.translate (0, new_y - self.drag_y)
            # Recalc and notify about gamma
            wx,wy = self.canvas_to_curve_point(self.rect_center(item))
            gamma = math.log(wy)/math.log(0.5)
        return True
    def on_button_press (self, item, target, event):
        if event.button == 1:
            self.drag_x = event.x
            self.drag_y = event.y
            fleur = gtk.gdk.Cursor (gtk.gdk.FLEUR)
            canvas = item.get_canvas ()
            canvas.pointer_grab (item,
                                 gtk.gdk.POINTER_MOTION_MASK | gtk.gdk.BUTTON_RELEASE_MASK,
            self.dragging = True
            return True
        return False

    def on_button_release (self, item, target, event):
        canvas = item.get_canvas ()
        canvas.pointer_ungrab (item, event.time)
        self.dragging = False

    def curve_point_to_canvas(self,
        """Translate coordinates in world coordinates to canvas
        m = self.margin
        w = self.width
        h = self.height
        return (m+p[0]*(w-3*m),

    def canvas_to_curve_point(self,
        """Translate canvas  coordinates to world coordinates"""
        m = self.margin
        w = self.width
        h = self.height
        return ((c[0]-m)/(w-3*m),

    def set_gamma(self,gamma):
        """Change the gamma curve and emit a signal that gamma
        has been changed"""
        self.gamma = gamma
        graph = [(0.01*i,
                  (0.01*i)**gamma) for i in range(100)]
        points = [self.curve_point_to_canvas(p) for p in graph]
        curve = goocanvas.Points(points)
        self.emit('gamma-changed', gamma)
class TestGammaCurve(gtk.Window):
    def on_gamma_changed(self,widget,gamma):
    def __init__(self):
        gtk.Window.__init__(self, gtk.WINDOW_TOPLEVEL)
        self.connect("delete_event", gtk.main_quit)
        vbox = gtk.VBox()
        self.goo_curve = GooGammaCurve()
        vbox.pack_start(self.goo_curve, True, True, 0)
        self.label = gtk.Label('gamma')
        vbox.pack_start(self.label, True, True, 0)

test = TestGammaCurve()

On Wed, May 4, 2011 at 21:15, Charlie De <charliecoeli yahoo com> wrote:
Don't be funny, Dov. As you know, GTK+ is tied through pyGTK to Python, and Python is not used by pro coders only, it also gets used by non-programmers as well. People like me. People who appreciate relatively easy solutions. And it was difficult enough getting to grips with Python, Glade and pyGTK, but it was doable. And that is the limit of what can be expected of a user like me. I looked at the link you provided, and it's anything but "very easy".

Anyhow, my last post. As I said in my reply to David, I think you're a bunch of bums. You might be good at coding, but you have no appreciation of how to serve a broad user base. To think that you'd so casually remove a unique widget that can't be replaced by any other, on such flimsy justification, and then simply say "learn to do it yourself" - it beggars belief. If this were a commercial project, you'd be out of your job by next week, I could guarantee you that.

Take it easy, campers, and thanks for nothing.


From: Dov Grobgeld <dov grobgeld gmail com>
To: Charlie De <charliecoeli yahoo com>
Cc: gtk-devel-list gnome org
Sent: Wed, May 4, 2011 4:37:55 PM
Subject: Re: Please don't drop support for Curve

I suggest that you learn how to create your own widget. A widget like GtkCurve is very easy to develop by subclassing one of the canvas widgets, e.g. GooCanvas. Or do it directly through Cairo on a GtkDrawingArea. This is described here:


On Wed, May 4, 2011 at 13:22, Charlie De <charliecoeli yahoo com> wrote:
Hello all,

I've joined up with this list for one single reason: to ask the developers to
re-consider and reverse their decision to deprecate and eventually remove the
Curve widget from GTK+.

Recently, I learnt to create Python scripts, and with the help of Glade, created
a GUI to ImageMagick routines, for my own "proprietary photo editor". The Curve
widget was absolutely central to this endeavour. The only downside is that it is
basic and not very well developed.

To me, the reasons given for this widget being deprecated, that it isn't very
useful and only appeals to a minority of users, sounds disingenuous and hurtful
to the easy usefulness of GTK+. What do you expect users to do in its absence?
Do you really expect users to go breaking their knuckles to try and create a
curve dialog with a drawing area? How could you see such "progress" as anything
but a step backwards?

So please, hear a busy user who has taken the trouble of registering here to
offer feedback: do not drop this essensial component of GTK+, and instead of
deprecating it, continue its development. You can drop Gamma Curve if you like,
which is too idiosyncratic to be of much use. What is needed instead is the
Curve offering point data - the points on the curve that the user creates -
being able to be read and manipulated by other widgets, such as the numerical
scroll boxes. (Rather like the Curves dialog in Photoshop.) And I'm sure there
are other improvements that could be made.

If on the other hand you insist on dropping the Curve, then when the time comes
I guess I'll have to switch to another widget toolset, whichever will still be
offering a Curve interface element. I can't even begin to image how long it
would take me to create the widget manually - it frankly strikes me as an insane
and pointless effort.

Thank you for your attention and best wishes with your continuing good work.
What you have created in GTK+ (and pyGTK) is greatly appreciated and wonderfully

All the best,

gtk-devel-list mailing list
gtk-devel-list gnome org

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]