]>
git.saurik.com Git - wxWidgets.git/blob - utils/wxPython/demo/wxTreeCtrl.py
2 from wxPython
. wx
import *
4 #---------------------------------------------------------------------------
6 class TestTreeCtrlPanel ( wxPanel
):
7 def __init__ ( self
, parent
, log
):
8 wxPanel
.__ init
__ ( self
, parent
, - 1 )
13 self
. tree
= wxTreeCtrl ( self
, tID
)
14 root
= self
. tree
. AddRoot ( "The Root Item" )
16 child
= self
. tree
. AppendItem ( root
, "Item %d " % x
)
18 last
= self
. tree
. AppendItem ( child
, "item %d-%s " % ( x
, chr ( ord ( "a" )+ y
)))
20 self
. tree
. AppendItem ( last
, "item %d-%s-%d " % ( x
, chr ( ord ( "a" )+ y
), z
))
22 self
. tree
. Expand ( root
)
23 EVT_TREE_ITEM_EXPANDED ( self
, tID
, self
. OnItemExpanded
)
24 EVT_TREE_ITEM_COLLAPSED ( self
, tID
, self
. OnItemCollapsed
)
25 EVT_TREE_SEL_CHANGED ( self
, tID
, self
. OnSelChanged
)
28 def OnSize ( self
, event
):
29 w
, h
= self
. GetClientSizeTuple ()
30 self
. tree
. SetDimensions ( 0 , 0 , w
, h
)
33 def OnItemExpanded ( self
, event
):
34 item
= event
. GetItem ()
35 self
. log
. WriteText ( "OnItemExpanded: %s \n " % self
. tree
. GetItemText ( item
))
37 def OnItemCollapsed ( self
, event
):
38 item
= event
. GetItem ()
39 self
. log
. WriteText ( "OnItemCollapsed: %s \n " % self
. tree
. GetItemText ( item
))
41 def OnSelChanged ( self
, event
):
42 item
= event
. GetItem ()
43 self
. log
. WriteText ( "OnSelChanged: %s \n " % self
. tree
. GetItemText ( item
))
45 #---------------------------------------------------------------------------
47 def runTest ( frame
, nb
, log
):
48 win
= TestTreeCtrlPanel ( nb
, log
)
51 #---------------------------------------------------------------------------
71 A tree control presents information as a hierarchy, with items that may be expanded to show further items. Items in a tree control are referenced by wxTreeItemId handles.
74 -------------------------
78 wxTreeCtrl(wxWindow* parent, wxWindowID id, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxTR_HAS_BUTTONS, const wxValidator& validator = wxDefaultValidator, const wxString& name = "listCtrl")
80 Constructor, creating and showing a tree control.
85 parent = Parent window. Must not be NULL.
87 id = Window identifier. A value of -1 indicates a default value.
89 pos = Window position.
91 size = Window size. If the default size (-1, -1) is specified then the window is sized appropriately.
93 style = Window style. See wxTreeCtrl.
95 validator = Window validator.