[wxPython-users] Re: Putting Leaves on wx.TreeCtrl() Twigs

Rich Shepard rshepard at appl-ecosys.com
Tue Dec 19 06:44:48 PST 2006


On Tue, 19 Dec 2006, Brian Smith wrote:

> The problem with the above is that you are not using the subpolicies list that
> you created.  I think you want to do something like this:
>
> ...
> subpolicies = [sp[0] for sp in self.appData.subPols if sp[1]==policy]
> for subpol in subpolicies:
>    self.polTree.AppendItem( ngc, subpol )

Brian,

   This is _exactly_ what I was missing. I knew I needed to walk the
subpolicy list, item by item, but thought it had to come before the top line
of code above.

> Note that I haven't assigned the return value of AppendItem() to a
> variable. I am assuming from your previous messages that this is the
> deepest level of the tree and you will not be adding any children to these
> items.  If that is not the case, or if you need to know/store the
> TreeItemID returned, then you can of course add an assignment to the
> above.

   This is the deepest tree level. I did not realize that the items could be
appended without an explicit assignment on the LHS. I think that was a major
part of my stuggle to write the correct code.

   I am very grateful to the lesson you provided. It increased my
understanding of wxPython significantly. Now the code does what I need it to
do.

Thank you very much,

Rich

-- 
Richard B. Shepard, Ph.D.               |    The Environmental Permitting
Applied Ecosystem Services, Inc.(TM)    |            Accelerator
<http://www.appl-ecosys.com>     Voice: 503-667-4517      Fax: 503-667-8863




More information about the wxpython-users mailing list