The FXTreeList constructor is defined by the following prototype: FXTreeList(p, nvis, tgt=None, sel=0,
opts=TREELIST_NORMAL, x=0, y=0, w=0, h=0)The arguments to the FXTreeList constructor
are described in the following list:
You add an item to a tree by supplying a parent and a text label. You begin by adding root items to the tree. Root items have a parent of None. The Abaqus GUI Toolkit provides several ways of adding items to a tree; however, the most convenient approach uses the addItemLast method, as shown in the following example: vf = FXVerticalFrame(gb, FRAME_SUNKEN|FRAME_THICK,
0,0,0,0, 0,0,0,0)
self.tree = FXTreeList(vf, 5, None, 0,
LAYOUT_FILL_X|LAYOUT_FILL_Y|
TREELIST_SHOWS_BOXES|TREELIST_ROOT_BOXES|
TREELIST_SHOWS_LINES|TREELIST_BROWSESELECT)
option1 = self.tree.addItemLast(None, 'Option 1')
self.tree.addItemLast(option1, 'Option 1a')
self.tree.addItemLast(option1, 'Option 1b')
option2 = self.tree.addItemLast(None, 'Option 2')
self.tree.addItemLast(option2, 'Option 2a')
option2b = self.tree.addItemLast(option2, 'Option 2b')
self.tree.addItemLast(option2b, 'Option 2bi')
option3 = self.tree.addItemLast(None, 'Option 3')
![]() You can also specify icons to be used for each tree item. The “open” icon is displayed next to an item when it is selected; the “closed” icon is displayed when the item is not selected. These icons are not associated with the expanded/collapsed state of a branch. For example, Microsoft's Windows Explorer uses open and closed folder icons to show the selected state. You can check if an item is selected using the tree's isItemSelected method. The tree widget will send its target a SEL_COMMAND message whenever the user clicks on an item. You can handle this message and then traverse all the items in the tree to find the selected item. The following example uses a message handler that assumes that the tree is browse-select and allows the user to select only one item at a time: def onCmdTree(self, sender, sel, ptr):
w = self.tree.getFirstItem()
while(w):
if self.tree.isItemSelected(w):
# Do something here based on
# the selected item, w.
break
if w.getFirst():
w=w.getFirst()
continue
while not w.getNext() and w.getParent():
w=w.getParent()
w=w.getNext() | |||||||||||||||||||||||||||