I use a subclass of a wxTreeCtrl to display my application data,
expanding
nodes on demand. I used the pyTree in the demo as an example. Everything
works fine more or less.
But: I'd like to display the first level of items at application
startup.
I use a call to self.Expand(self.root). This makes the first level pop
up
initially, but all objects APPEAR TWICE! I added the command above to
the
demo and the same problem appears as well.
I use a subclass of a wxTreeCtrl to display my application data,
expanding
nodes on demand. I used the pyTree in the demo as an example. Everything
works fine more or less.
But: I'd like to display the first level of items at application
startup.
I use a call to self.Expand(self.root). This makes the first level pop
up
initially, but all objects APPEAR TWICE! I added the command above to
the
demo and the same problem appears as well.
Great, thanks for the quick help. For clarification: it seems as if I
could choose
either of the three proposals?
Lars
"Mike C. Fletcher" wrote:
···
When using run-time-expanding trees you need to:
1) Check whether the expanding item already has children. If so, do _not_
add new children.
2) Keep track of which items you've already expanded, and not expand those
which you've already scanned. (Same as 1, but explicit).
3) Always delete all children of the item and re-add when the item expands.
Not sure if you're doing that already, but it's what caused the effect in my
proggies. HTH,
Mike
-----Original Message-----
From: wxpython-users-admin@lists.wxwindows.org
[mailto:wxpython-users-admin@lists.wxwindows.org]On Behalf Of Lars von
Wedel
Sent: May 18, 2001 05:37
To: wxPython
Subject: [wxPython] Behavior of wxTreeCtrl / EVT_TREE_ITEM_EXPANDING
Hello,
I use a subclass of a wxTreeCtrl to display my application data,
expanding
nodes on demand. I used the pyTree in the demo as an example. Everything
works fine more or less.
But: I'd like to display the first level of items at application
startup.
I use a call to self.Expand(self.root). This makes the first level pop
up
initially, but all objects APPEAR TWICE! I added the command above to
the
demo and the same problem appears as well.
For this specific case (pyTree or something modeled after it) a little
simpler solutions is to just check if the item is already expanded. The
self.Expand results in the EXPANDING event to be fired twice, so if it is
already expanded just return immediately from the event handler.
Mike's suggestions are good as well.
Robin
Great, thanks for the quick help. For clarification: it seems as if I
could choose
either of the three proposals?
Lars
"Mike C. Fletcher" wrote:
>
> When using run-time-expanding trees you need to:
>
> 1) Check whether the expanding item already has children. If
so, do _not_
> add new children.
>
> 2) Keep track of which items you've already expanded, and not
expand those
> which you've already scanned. (Same as 1, but explicit).
>
> 3) Always delete all children of the item and re-add when the
item expands.
>
> Not sure if you're doing that already, but it's what caused the effect
in my
···
> proggies. HTH,
> Mike
>
> -----Original Message-----
> From: wxpython-users-admin@lists.wxwindows.org
> [mailto:wxpython-users-admin@lists.wxwindows.org]On Behalf Of Lars von
> Wedel
> Sent: May 18, 2001 05:37
> To: wxPython
> Subject: [wxPython] Behavior of wxTreeCtrl / EVT_TREE_ITEM_EXPANDING
>
> Hello,
>
> I use a subclass of a wxTreeCtrl to display my application data,
> expanding
> nodes on demand. I used the pyTree in the demo as an example. Everything
> works fine more or less.
>
> But: I'd like to display the first level of items at application
> startup.
> I use a call to self.Expand(self.root). This makes the first level pop
> up
> initially, but all objects APPEAR TWICE! I added the command above to
> the
> demo and the same problem appears as well.
>
> Is this a bug!?
>
> Lars
>
> _______________________________________________
> wxpython-users mailing list
> wxpython-users@lists.wxwindows.org
> http://lists.wxwindows.org/mailman/listinfo/wxpython-users
Yes, any of the three should work fine. I use the "delete all children"
approach, because it means that updates are reflected when you re-expand,
but it's got much higher overhead than the other two.
Enjoy,
Mike
···
-----Original Message-----
From: wxpython-users-admin@lists.wxwindows.org
[mailto:wxpython-users-admin@lists.wxwindows.org]On Behalf Of Lars von
Wedel
Sent: May 18, 2001 08:29
To: wxpython-users@lists.wxwindows.org
Subject: Re: [wxPython] Behavior of wxTreeCtrl / EVT_TREE_ITEM_EXPANDING
Great, thanks for the quick help. For clarification: it seems as if I
could choose
either of the three proposals?
Lars
"Mike C. Fletcher" wrote:
When using run-time-expanding trees you need to:
1) Check whether the expanding item already has children. If so,
do _not_
add new children.
2) Keep track of which items you've already expanded, and not
expand those
which you've already scanned. (Same as 1, but explicit).
3) Always delete all children of the item and re-add when the item
expands.
Not sure if you're doing that already, but it's what caused the effect in
my
proggies. HTH,
Mike
-----Original Message-----
From: wxpython-users-admin@lists.wxwindows.org
[mailto:wxpython-users-admin@lists.wxwindows.org]On Behalf Of Lars von
Wedel
Sent: May 18, 2001 05:37
To: wxPython
Subject: [wxPython] Behavior of wxTreeCtrl / EVT_TREE_ITEM_EXPANDING
Hello,
I use a subclass of a wxTreeCtrl to display my application data,
expanding
nodes on demand. I used the pyTree in the demo as an example. Everything
works fine more or less.
But: I'd like to display the first level of items at application
startup.
I use a call to self.Expand(self.root). This makes the first level pop
up
initially, but all objects APPEAR TWICE! I added the command above to
the
demo and the same problem appears as well.