Aki Koskinen wrote:
> Hi there. I'm learning to use FloatCanvas and at the same time evaluating if 
> it would be a fit tool for my purposes.

Welcome.


I've cc'd this note to the floatcanvas list -- I like to keep 
correspondence on that list, as it creates an archive, and others can 
chime in. I hope you will join the list.

http://mail.mithis.com/cgi-bin/mailman/listinfo/floatcanvas

> R = Canvas.AddRectangle((x,y), (w, h))
> T = Canvas.AddText("Text", (x, y))
> G = Canvas.AddGroup()
> G.AddObject(self.R)
> G.AddObject(self.T)

You probably don't want to do it that way -- that will put draw each of 
those objects twice -- once by itself, and once as part of the group. 
You want:

R = FloatCanvas.Rectangle((x,y), (w, h))
T = FloatCanvas.Text("Text", (x, y))
G = Canvas.AddGroup()
G.AddObject(self.R)
G.AddObject(self.T)

Thought that's not the problem at hand.

> In the first AddObject call to the Group object I get an exception that says:
> 
> File "[...]/wx/lib/floatcanvas/FloatCanvas.py", line 353, in AddObject        
>                                                                               
>      
>     self.BoundingBox.Merge(obj.BoundingBox)                                   
>                             
> AttributeError: 'NoneType' object has no attribute 'Merge'
> 
> As I looked in to the source of FloatCanvas I noticed that if one creates a 
> Group object without any initial objects, the bounding box of the group is 
> initialized to None. Actually this is done by the Group.CalcBoundingBox 
> method which sets the bounding box to None whenever there are zero objects in 
> the group.
> 
> However in the AddObject method no check is made for the bounding box member 
> if it is None or not. Effectively adding an object to an empty group becomes 
> impossible.

Quite right -- sorry for the oversight -- I guess I've always 
initialized a group with one or more objects. As you've found, you can 
of course work around the bug by doing just that, but you're right that 
it should be possible to create an empty group and add objects later,

> I think the AddObject should be something like:
> 
> def AddObject(self, obj):
>   self.ObjectList.append(obj)
>   if self.BoundingBox != None:
>     self.BoundingBox.Merge(obj.BoundingBox)
>   else:
>     self.BoundingBox = obj.BoundingBox

hmm. I wonder if that's the best approach, or if I should create a Null 
bounding box object....

Questions:

What would the width and height of a null BB be? 0 or None?

What would the center be? -- None?

Would it overlap with no bounding boxes, or all of them?

Would all BBs be inside it, or none?

Would it be equal to other null BBs?


I'll try to get a solution in place today.

>  I'm still continuing with
> FloatCanvas so it looks promising, so I guess good work anyway :)

thanks, keep the questions coming.

-CHB



-- 
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