Astan Chee wrote:
> Christopher Barker wrote:
>> Does that help?
> Yes it does, very much. Thanks. I few other questions I have regarding 
> methods and syntax in floatcanvas:

> 1. The line that states self.Canvas.AddObjects(Nodes)  is there a way to 
> iterate through these added objects (and possibly manipulate them)?

Sure. "Nodes" is a list of node object, so you can iterate on that just 
fine. In fact, that's what the next few lines of code do:

         for node in Nodes:
             #pass
             node.Bind(FC.EVT_FC_LEFT_DOWN, self.ObjectHit)

iterating on the node objects to bind events to them.

You can iterate the same way to manipulate them in all sorts of other ways.

> I can't find anything in the docs about added objects.

That's 'cause there are almost no docs ;-) -- however, the source is 
there. Anyway, all added objects are put in list:

Canvas._DrawList (or Canvas._ForeDrawList, if they are in the froeground 
layer).

However, in general, you don't want to work directly with those lists 
(that's why the names start with "_"). I consider that an implementation 
detail, and they may get replaced with some other data structure in the 
future. Also, those lists have everything in them, and in general, 
you're likely to want to manipulate subsets of the objects on the 
Canvas, not all of them.

The way to handle that is to store the objects that are logically 
grouped together in a list yourself (like Nodes, in this case), and then 
you can do what you want with them.

If you're at all familiar with the TK Canvas -- I've been asked why 
FloatCanvas doesn't have TK's "tags", and the reason is that you can 
accomplish the same thing by just putting all the objects that might 
share a tag into a shared list, and work with them that way. There's no 
reason a given DrawObject can't be in more than one list.

All the Canvas.Add* methods return a reference to the DrawObject added, 
or you can create the object first, ans add it to the Canvas later (like 
is done with the Nodes in this code).

In addition, if you have a few objects that work together functionally 
as one, you can use a Group object to hold them all together.

> 2.  I've had a look at the new Tree.py you have in the repository and 
> for me it crashes with the following error:
> AttributeError: 'BBox' object has no attribute 'Center'

Yes, I added the "Center" property to the BBox class when I wrote that 
demo -- you need the latest SVN version of FloatCanvas to use it.

-Chris


-- 
Christopher Barker, Ph.D.
Oceanographer

Emergency Response Division
NOAA/NOS/OR&R            (206) 526-6959   voice
7600 Sand Point Way NE   (206) 526-6329   fax
Seattle, WA  98115       (206) 526-6317   main reception

[EMAIL PROTECTED]
_______________________________________________
FloatCanvas mailing list
[email protected]
http://mail.mithis.com/cgi-bin/mailman/listinfo/floatcanvas

Reply via email to