Re: Adding Tk Canvas tags to Gnome Canvas - looking for inputs



Skip Montanaro <skip pobox com> writes:

> I will be doing some work for a customer who is porting some large
> applications from Python+Tkinter to Python+Gtk+Gnome.  In their original
> application they make heavy use of the tags system that is part of the Tk
> canvas widget, and have expressed interest in adding that functionality to
> the Gnome canvas widget.  I took a look at the Tk canvas code.  The
> implementation of tags looks pretty straightforward, so I was a bit
> surprised to not find them already implemented or at least on the to-do list
> at the top of gnome-canvas.c.
> 
> I hope you can give me a little insight about the decision to not include
> this capability in Gnome's canvas widget and what thoughts, if any, you have
> about incorporating tags into the canvas widget in the future.  Is the
> programming model sufficiently different that tags don't make sense?  If
> there are requirements you'd place on such an implementation (API,
> performance, etc), I am at this point the proverbial clean sheet of paper.

The original version of the GNOME canvas did indeed use a tags system
very similar to the one in the Tk canvas; it did not use the GTK+
object system either.  We later ported it to the GTK+ object system
because it would be a better design, and we removed the tags.

I think tags are an ugly way of dealing with things.  They basically
map well to Tk's concept of "everything is a string", but they are
rather ugly in the GTK+ programming model.

It is better to have your application maintain separate lists of
canvas items based on their supposed tags.  So you would keep a list
of items with tag "foo", another list for items with tag "bar", etc.
When you want to perform an action on all the items that contain
such-and-such tags, you just walk the appropriate lists.

  Federico




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