Am 18.11.2008, 04:19 Uhr, schrieb Marcos Duarte <[EMAIL PROTECTED]>:
For now, I am going to be a user bothering you and I hope to at least help to improve fc2 with my feedback. Something that would help is the API documentation (just like the fc doxygen site would be enough).
That's actually a great way to help improving fc2! User feedback is really welcome. We will need to take a look how to generate good documentation for fc2 since some parts of it are generated on the fly, especially the "create" family of functions. Maybe I should type more informations into the docstrings for these cases. Or I'll generate the doc strings also at runtime if doxygen or some other tool is able to extract doc strings from a live program.
I have some very basic questions about fc2, in fact I think they are more python&wxpython doubts (see the attached program and add your own image in line 23):
Done, I am attaching the changed program which works on my machine. I've changed a few things for myself like location of the image file, the import statement and added redirect = False to the App object.
1. Line 27: How to set the order of appearance of drawed objects?
This is easy, just supply the where = 'back' or where = 'front' or where = siblingNodeAfterWhichToInsertThisNode parameters to create(). The first two forms are clear, the last form of "where" is useful if you want to insert a node at a very specific point in the front-to-back order. Note that front to back-order is also affected by grouping, so if one group is in front of another group, then all child nodes of the group in front will be in front of all the child nodes of the back group. Sounds more complicated than it is :) Just means if you have 2 images with points on them and the points are children of the images then you can move one map over the other and it will appear as you'd expect.
Here's the relevant code:self.canvas.create( 'Circle', 300, pos = (0,0), look=('red', 'red'), where = 'front' )
By default the bitmap is in front of everything, because it was added to the canvas first.
2. Line 49: How to delete a node selected with the mouse (the hit test works fine to find the node but I can't delete it)?
This is also easy, you almost got it. canvas.hitTest always returns a list of nodes which happen to be in the area to be tested. This list is sorted by order, the top-most node is the first element of the list. So you need to do this to use canvas.hitTest:
nodes = self.canvas.hitTest(evt.wx_event.GetPosition())
print nodes
if not nodes:
return
self.canvas.removeChild( nodes[0] )
First you test whether you hit anything at all. If not, you return from
the function. If there some nodes have been hit, you likely want to remove
the top one which is nodes[0].
I took the opportunity and extended the doc string of hitTest, so it should be clear what hitTest returns.
3. Line 72: I am trying to show the mouse position in a status bar but after I use the menu bar (fc2 guimode), it stops to work.
I found the cause. It's basically happening that your EVT_MOTION event interferes with the one setup internally in fc2. I've just posted a message to the wxPython mailing list asking for a way to solve this problem. Once this is clear I can probably fix fc2 so your code will continue to work.
I've also made the 'Bitmap' model simpler to use, you can now use the img directly instead of imgData and the clumsy fc.arrayFromImage. This also makes creation much faster. Update your working copy to get this feature. In addition I made another modification which makes things go even faster on creation time, but I cannot check this modification in yet, because I have changes in the code which are not ready for svn yet.
It also occured to me that using
print evt.wx_event.GetPosition()
nodes = self.canvas.hitTest(evt.wx_event.GetPosition())
is a bit quirky. An easier way would be
print evt.coords
nodes = self.canvas.hitTest(evt.coords)
Right now this is not implemented. I should probably think more about a
way to tag coordinates with their respective coordinate system (like using
a fc.Coords() class or adding a 'coordinateSytem' attribute to the
evt.coords tuple).
All in all the most problematic things you've faced seem to come from thee lack of api documentation (the where parameter and the hitTest result).
Please ask more questions :-) -Matthias
X5.py
Description: Binary data
_______________________________________________ FloatCanvas mailing list [email protected] http://mail.mithis.com/cgi-bin/mailman/listinfo/floatcanvas
