From: Jussi S. <jus...@pp...> - 2007-03-23 10:11:17
|
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 > <http://autos.yahoo.com/new_cars.html;_ylc=X3oDMTE0OGRsc3F2BF9TAzk3MTA3MDc2BHNlYwNtYWlsdGFncwRzbGsDbmV3Y2Fycw--> > at Yahoo! Autos. > <http://autos.yahoo.com/new_cars.html;_ylc=X3oDMTE0OGRsc3F2BF9TAzk3MTA3MDc2BHNlYwNtYWlsdGFncwRzbGsDbmV3Y2Fycw--> > > ------------------------------------------------------------------------ > > ------------------------------------------------------------------------- > 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 > Pyt...@li... > 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/ |