[wxPython] wxTreeCtrl sample requested

I'm looking for code to read that uses wxTreeCtrl that's more indepth
than the demo. Anybody have a fairly complicated application using
Trees that I can read the code for?

Background: I'm building an application that is making dictionaries 4
levels deep, with the bottom most level being datasets. Ex:

Level:
  sub:
    subsub:
      dataset:
        datapoint0
        datapoint1
        datapoint2

The user will be adding and deleting at the level of subsub and below,
so I need to be able to update the tree on the fly, as well as
copy/move items from branch to branch. I keep all the data in a main
dictionary in memory.

Anybody have anything similiar that I can read? Thanks.

-J

···

--
Jonathan Pennington | http://coastalgeology.org
Site Manager | Protection and stewardship
CoastalGeology.Org (CGO) | through public education.
john@coastalgeology.org | Join CGO, make a difference.

_______________________________________________
wxPython-users mailing list
wxPython-users@lists.sourceforge.net
http://lists.sourceforge.net/mailman/listinfo/wxpython-users

You can look at wxCvs. I started writing a GUI front end to CVS using wxPython. It uses the wxTreeCtrl for one of the widgets (wxCvsTreeCtrl). You can find the project at sourceforge (wxCvs download | SourceForge.net).

It's been a while since I worked on it but I remember thinking that I would handle the data a little differently to the implementation. It was something to do with the sorting. Robin mentioned that a simple/default sort might be implemented in the wxTreeCtrl (Python and/or C++) but I don't know what the latest status of that is. Anyways, it's an example of getting dynamic data from the filesystem (ie. filenames) and inserting them into a wxTreeCtrl.

Regards,
Brendan Simon.

Jonathan Pennington wrote:

···

I'm looking for code to read that uses wxTreeCtrl that's more indepth
than the demo. Anybody have a fairly complicated application using
Trees that I can read the code for?

Background: I'm building an application that is making dictionaries 4
levels deep, with the bottom most level being datasets. Ex:

Level:
  sub:
    subsub:
      dataset:
        datapoint0
        datapoint1
        datapoint2

The user will be adding and deleting at the level of subsub and below,
so I need to be able to update the tree on the fly, as well as
copy/move items from branch to branch. I keep all the data in a main
dictionary in memory.

Anybody have anything similiar that I can read? Thanks.

-J

_______________________________________________
wxPython-users mailing list
wxPython-users@lists.sourceforge.net
http://lists.sourceforge.net/mailman/listinfo/wxpython-users

Hello Jonathan,

Wednesday, January 10, 2001, 6:28:04 AM, you wrote:

I'm looking for code to read that uses wxTreeCtrl that's more indepth
than the demo. Anybody have a fairly complicated application using
Trees that I can read the code for?

Background: I'm building an application that is making dictionaries 4
levels deep, with the bottom most level being datasets. Ex:

Level:
        sub:
                subsub:
                        dataset:
                                datapoint0
                                datapoint1
                                datapoint2

The user will be adding and deleting at the level of subsub and below,
so I need to be able to update the tree on the fly, as well as
copy/move items from branch to branch. I keep all the data in a main
dictionary in memory.

Anybody have anything similiar that I can read? Thanks.

I am using dynamic tree made from TreeNodes as follow:

class TreeNode:
    """array of subnodes plus header"""

    def __len__(self):
        return 0

    def __getitem__( self, item ):
        raise IndexError

    def GetLabel( self ):
        raise RuntimeError, 'not implemented'

class ListNode(TreeNode):

    def __init__(self, nodes, title):
        self._nl = nodes
        self._tt = title

    def __len__(self):
        return len(self._nl)

    def __getitem__( self, item ):
        return self._nl[item]

    def GetLabel( self ):
        return self._tt

I start tree with like this:

                root = self.tree.AddRoot( dd.GetLabel() )
                self.tree.SetPyData( root, dd )
                self.tree.SetItemHasChildren( root, len(dd) )

where dd is TreeNode e.g.:

dd = ListNode( [
        ListNode( [
                ListNode( [DataNode(), ...], 'dataset' ),
                ListNode( [DataNode(), ...], 'dataset' ),
        ], 'subsub' )
    ], 'sub' )

then i use this to update tree according to current state of
TreeNodes:

    def UpdateBranch( self, item, recurse=None ):
        node = self.tree.GetPyData( item )
        child,boza = self.tree.GetFirstChild( item, 0 )
        for s in node:
            if child.IsOk():
                ni = child
                child,boza = self.tree.GetNextChild( item,boza )
                self.tree.SetItemText( ni, s.GetLabel() )
                self.tree.SetPyData( ni, s )
                #for wx 2.2.1
                #self.tree.SetItemData( ni, wxTreeItemData( s ) )
                self.tree.SetItemHasChildren( ni, len(s) )
                if len(s) and recurse:
                    self.UpdateBranch( ni, recurse )
            else:
                ni = self.tree.AppendItem( item, s.GetLabel() )
                self.tree.SetPyData( ni, s )
                self.tree.SetItemHasChildren( ni, len(s) )
        if child.IsOk():
            # prev list was longer
            extra =
            while child.IsOk():
                extra.append( child )
                child,boza = self.tree.GetNextChild( item,boza )
            map( self.tree.Delete, extra )

wx 2.2.1 has bug in wxTreeItemData for which is commented code

HTH,
Niki Spahiev

···

_______________________________________________
wxPython-users mailing list
wxPython-users@lists.sourceforge.net
http://lists.sourceforge.net/mailman/listinfo/wxpython-users

I read the wxCvs code. No, no, that's not what I want at all! I wanted
a *good*, *usable*, *complicated* tree, not some simple thing with
*less* functionality than the demo!

Then I run the program... see my file system, choose a file, expand it,
delete a subfolder externally and close and expand it again, and it's
gone.

Oh, alright then.

It'll take me some time to figure out where you hid all the code,
because just browsing through the files, it didn't seem like there was
anything there. And there are a couple of other nice things you've
done that have helped me clean up my code as well. How wonderful it is
to get a nice big programming pimp-slap! Thank you so much.

-J

···

--
Jonathan Pennington | http://coastalgeology.org
Site Manager | Protection and stewardship
CoastalGeology.Org (CGO) | through public education.
john@coastalgeology.org | Join CGO, make a difference.

_______________________________________________
wxPython-users mailing list
wxPython-users@lists.sourceforge.net
http://lists.sourceforge.net/mailman/listinfo/wxpython-users

Jonathan Pennington wrote:

I read the wxCvs code. No, no, that's not what I want at all! I wanted
a *good*, *usable*, *complicated* tree, not some simple thing with
*less* functionality than the demo!

Then I run the program... see my file system, choose a file, expand it,
delete a subfolder externally and close and expand it again, and it's
gone.

Oh, alright then.

It'll take me some time to figure out where you hid all the code,
because just browsing through the files, it didn't seem like there was
anything there. And there are a couple of other nice things you've
done that have helped me clean up my code as well. How wonderful it is
to get a nice big programming pimp-slap! Thank you so much.

I'm glad it helped you somewhat, although it may not of been exactly what you wanted. Be aware that this is my first python program, besides the simple hello_world type of tutorials. I wrote the wxCvs GUI by copying/pasting from the wxPythonDemo and then modifying to suit.

I can't remember exactly how I did things but if you have any questions I can quickly scan through the source code and answer them. I do want to continue with wxCvs when I get a little more time. I want it to be able to integrate with the wxStudio project which is also at a standstill at the moment.

Eventually I want to write a wxAegis (GUI frontend to the Aegis configuration management tool) and have that also integrate to wxStudio. Aegis is a far superior tool to CVS and can enforce different user roles (eg. administrator, developer, reviewer & integrator). It wont allow integration to the "baseline" of the repository until a "changeset" has been tested and reviewed. The tests must be executed and passed by both the developer and integrator. It is very configurable. The tests can be bypassed and one person can be assigned to all roles.

Brendan Simon.

···

_______________________________________________
wxPython-users mailing list
wxPython-users@lists.sourceforge.net
http://lists.sourceforge.net/mailman/listinfo/wxpython-users

Hello. newbie printing question here:

I'd like to take a bunch of HTML code, assign it to a variable, and then use wxHtmlEasyPrinting to print it out. So far, I haven't been able to find any sample code (and having a hard time figuring out how to do it from the documentation alone). Would someone please post some basic code if you have a few minutes?

thanks!

Steve

···

_______________________________________________
wxPython-users mailing list
wxPython-users@lists.sourceforge.net
http://lists.sourceforge.net/mailman/listinfo/wxpython-users

Hello. newbie printing question here:

I'd like to take a bunch of HTML code, assign it to a variable, and then use wxHtmlEasyPrinting to print it out. So far, I haven't been able to find any sample code (and having a hard time figuring out how to do it from the documentation alone). Would someone please post some basic code if you have a few minutes?

Look in the demo. It takes about two lines of code.

···

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

_______________________________________________
wxPython-users mailing list
wxPython-users@lists.sourceforge.net
http://lists.sourceforge.net/mailman/listinfo/wxpython-users

found it (the code). WOW!!!

btw, Robin, I just wanted to thank you for all your help so far and to say congrats on the new j.o.b. situation. looks like wxPython has a bright future ahead of it, as hopefully do you.

Best,
Steve

···

_______________________________________________
wxPython-users mailing list
wxPython-users@lists.sourceforge.net
http://lists.sourceforge.net/mailman/listinfo/wxpython-users

OK, so I've looked at the demo's code again and again, and I'm still having problems doing this simple exercise.

What I'd ideally *like* to do is to be able to print out HTML code (a la SetPage) without having to actually display that page first.

I'll try to work on some sample code of my dilemna tonight, but any suggestions are greatly appreciated...

-S

···

_______________________________________________
wxPython-users mailing list
wxPython-users@lists.sourceforge.net
http://lists.sourceforge.net/mailman/listinfo/wxpython-users

OK, so I've looked at the demo's code again and again, and I'm still having problems doing this simple exercise.

What I'd ideally *like* to do is to be able to print out HTML code (a la SetPage) without having to actually display that page first.

I'll try to work on some sample code of my dilemna tonight, but any suggestions are greatly appreciated...

wxHtmlEasyPrinting.PrintText(theText)

···

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

_______________________________________________
wxPython-users mailing list
wxPython-users@lists.sourceforge.net
http://lists.sourceforge.net/mailman/listinfo/wxpython-users

It's a beautiful thing when one line of code can make you feel like a complete moron.

:wink:

thanx.

···

_______________________________________________
wxPython-users mailing list
wxPython-users@lists.sourceforge.net
http://lists.sourceforge.net/mailman/listinfo/wxpython-users

It's a beautiful thing when one line of code can make you feel like a complete moron.

And I enjoy doing it so much too. <wink>

···

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

_______________________________________________
wxPython-users mailing list
wxPython-users@lists.sourceforge.net
http://lists.sourceforge.net/mailman/listinfo/wxpython-users