Re: wx attributes for Tree control

hwg <[email protected]>
Newsgroups gmane.comp.python.pythoncard
Message-ID <[email protected]>
Thanks for the help.  This worked for the TR_MULTIPLE attribute.  Curiously, when I tried to set TR_HIDE_ROOT, Python crashed!

hg

Jussi Salmela <[email protected]> wrote: hwg kirjoitti:
> I have a treeCtrl and I would like to have the ability to select 
> multiple items in the tree.
>
> I know the underlying wxTreeCtrl has some flags:
>
> e.g. style = wx.TR_MULTIPLE | wx.TR_HIDE_ROOT
>
> But I don't know how (or if) I can access these attributes from my 
> pythoncard code.
>
> Any help would be appreciated.
>
> hg
>
> ------------------------------------------------------------------------
> Don't pick lemons.
> See all the new 2007 cars 
>  
> at Yahoo! Autos. 
>  
>
> ------------------------------------------------------------------------
>
> -------------------------------------------------------------------------
> Take Surveys. Earn Cash. Influence the Future of IT
> Join SourceForge.net's Techsay panel and you'll get the chance to share your
> opinions on IT & business topics through brief surveys-and earn cash
> http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
> ------------------------------------------------------------------------
>
> _______________________________________________
> Pythoncard-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/pythoncard-users
>   
Here's a part of the PythonCard minimalTree.py file that I have been 
using to get acquainted with the tree control. I've not really used the 
tree control for anything but played a little with it last september 
when someone asked something about this control. So the code may differ 
from the minimalTree example in othe places also, but the modifications 
I made to solve your problem are shown with comments:


import wx # <== added by JS
from PythonCard import model

# events
# itemActivated, itemExpanding, itemExpanded,
# selectionChanging, selectionChanged

class Minimal(model.Background):

    def on_initialize(self, event):
        tree = self.components.tree
        self.root = tree.addRoot("1")
        #print tree.getItemText(self.root)
        tree.setItemHasChildren(self.root, 1)
        tree.selectItem(self.root)
        print dir(tree) # <== added by JS
        tree.SetWindowStyleFlag(wx.TR_MULTIPLE) # <== added by JS
 
Here's an explanation of what I did (in this order):

1. Added the print and copied its output to an editor
2. Searched among the bunch of interesting sounding methods for names 
containing 'style' in them
3. Read a litlle bit of the wxTreeCtrl documentation in the wxWidgets 
docs finding the term 'Window styles' there.
4. Decided that the appropriate method to use must be SetWindowStyleFlag
5. Browsed through the source of tree.py in
        C:\Python24\Lib\site-packages\PythonCard\components
to find any additional info. While doing this found the way to refer to 
the  TR_MULTIPLE constant
6. Made the changes and tested. Seems to work.

HTH,
Jussi

-- 
Jussi Salmela
http://personal.inet.fi/cool/operator/



 
---------------------------------
Now that's room service! Choose from over 150,000 hotels 
in 45,000 destinations on Yahoo! Travel to find your fit.

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV

_______________________________________________
Pythoncard-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/pythoncard-users
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.