ComboTreeBox provides a ComboBox that pops up a tree instead of a list.
ComboTreeBox tries to provide the same interface as wx.ComboBox
as much as
possible. However, whereas the ComboBox widget uses indices to access
items in the list of choices, ComboTreeBox uses TreeItemId’s instead. If
you add an item to the ComboTreeBox (using Append or Insert), the
wx.TreeItemId
associated with the added item is returned. You can then use
that wx.TreeItemId
to add items as children of that first item. For
example:
from wx.lib.combotreebox import ComboTreeBox
combo = ComboTreeBox(parent)
item1 = combo.Append('Item 1') # Add a root item
item1a = combo.Append('Item 1a', parent=item1) # Add a child to item1
You can also add client data to each of the items like this:
item1 = combo.Append('Item 1', clientData=somePythonObject)
item1a = combo.Append('Item 1a', parent=item1,
clientData=someOtherPythonObject)
And later fetch the client data like this:
somePythonObject = combo.GetClientData(item1)
To get the client data of the currently selected item (if any):
currentItem = combo.GetSelection()
if currentItem:
somePythonObject = combo.GetClientData(currentItem)
Supported styles are the same as for wx.ComboBox
, i.e. wx.CB_READONLY
and
wx.CB_SORT
. Provide them as usual:
combo = ComboTreeBox(parent, style=wx.CB_READONLY|wx.CB_SORT)
Supported platforms: wxMSW and wxMAC natively, wxGTK by means of a workaround.
Module author: Frank Niessink <frank@niessink.com>
Copyright 2006, 2008, 2010, Frank Niessink License: wxWidgets license Version: 1.1 Date: August 1, 2010
Factory function to create the right ComboTreeBox depending on |
BaseComboTreeBox is the base class for platform specific versions of the |
|
BasePopupFrame is the base class for platform specific versions of the |
|
The ComboTreeBox widget for wxGTK. This is actually a work |
|
GTKPopupFrame is the base class GTK PopupFrame. |
|
TreeCtrl is the same as |
|
MacPopupFrame is the base class Mac PopupFrame. |
|
MSWComboTreeBox adds one piece of functionality as compared to |
|
MSWPopupFrame is the base class Windows PopupFrame. |
|
NativeComboTreeBox, and any subclass, uses the native ComboBox as basis, |
ComboTreeBox
(*args, **kwargs)¶Factory function to create the right ComboTreeBox depending on platform. You may force a specific class, e.g. for testing purposes, by setting the keyword argument ‘platform’, e.g. ‘platform=GTK’ or ‘platform=MSW’ or ‘platform=MAC’.
platform (string) – ‘GTK’|’MSW’|’MAC’ can be used to override the actual platform for testing