[fc] Graphical Hierarchy Tree in wxPython

Astan Chee wrote:

Hi Chris,
Thanks for all that help.

You're welcome.

I have several questions: when graphing alot of nodes (there are 500-4000 in my tree but only 1-3 levels) it seems to always fit to screen so they look all clumped together.

In most of my examples, I put a call in to:

Canvas.ZoomToBB()

this set the zoom so that everything fits, but may not be what you want. You can pass in any bounding box you want to to ZoomToBB(), to show just what you need. Here's the method signature:

ZoomToBB(self, NewBB=None, DrawFlag=True)

>or expand the width of the window to suit the height?

You may want to do that too. You can set the Windows size in all the same ways that you way with any other wx.Window

> Secondly, is there a way to 'hide' a node (and its line) ?

All FloatCanvas DrawObjects have a Hide() and Show() method.

Does that help?

-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

Chris.Barker@noaa.gov

Christopher Barker wrote:

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

Thanks for all that.
Its mostly working now, I've attached the example Im using and only 1 bug left.
I've added functionalities like rubberbands and collapse and expand nodes and find and select nodes.
The bug that Im having problem is on line 242 of the code. In a nutshell, if there are children nodes/shape with the same name the connector lines becomes weird and the expand and collapse functions are incomplete. Im not sure how to handle this. Any suggestions (aside from having each node a unique name)? Also I would like to add a rotate function to the canvas, has anyone done this to FloatCanvas before (and would like to share)?
Thanks again for all your help
Astan
PS:again, i know my code can be improved alot, but Im also learning how to use FloatCanvas at the same time.

TreeExample.py (24.7 KB)

Astan,

Maybe this should only be on the FloatCanvas list -- but I'm sending to wxPython-users as well for the moment.

Astan Chee wrote:

I've added functionalities like rubberbands

Does this work right for you? I'm getting

"EnsureIsValid(): Cannot nest wxDCs on the same window"

errors on OS-X, but I haven't had a chance to look yet at why.

The bug that Im having problem is on line 242 of the code. In a nutshell, if there are children nodes/shape with the same name the connector lines becomes weird and the expand and collapse functions are incomplete. Im not sure how to handle this. Any suggestions (aside from having each node a unique name)?

Here's your code:

VP1 = TreeNode("VP1", Children = leaves)
VP2 = TreeNode("VP2", Children = leaves) #doing this does not work, but

in this case, you are assigning the exact same objects as the leaves -- so they are going to get confused. Making another set of nodes with the same names seems to work:

leaves1 = [TreeNode(name) for name in elem]
leaves2 = [TreeNode(name) for name in elem]

VP1 = TreeNode("VP1", Children = leaves1)
VP2 = TreeNode("VP2", Children = leaves2)

Note that my tree implementation is pretty much a proof of concept -- I'm sure there are a lot of kinks to work out.

Also I would like to add a rotate function to the canvas, has anyone done this to FloatCanvas before (and would like to share)?

It's been talked about, I don't know it anyone's done it. Do you want to rotate the whole Canvas? or rotate individual objects?

-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

Chris.Barker@noaa.gov

Christopher Barker wrote:

Astan,

Maybe this should only be on the FloatCanvas list -- but I'm sending to wxPython-users as well for the moment.

Astan Chee wrote:

I've added functionalities like rubberbands

Does this work right for you? I'm getting

"EnsureIsValid(): Cannot nest wxDCs on the same window"

errors on OS-X, but I haven't had a chance to look yet at why.

This will happen if you have a paint or client DC associated with a window and then you either cause a recursive call to the same code, or you have some other code that is called that creates another DC for the same window before the first one is destroyed. This is an issue only on OS X where you must make sure that there is only one active DC at a time for the window.

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!