fsleyes_widgets.elistbox¶
This module provides the EditableListBox class, an alternative to
wx.gizmos.EditableListBox.
-
class
fsleyes_widgets.elistbox.EditableListBox(parent, labels=None, clientData=None, tooltips=None, style=0, vgap=0)[source]¶ Bases:
wx._core.PanelA panel which displays a list of items.
An
EditableListBoxcontains awx.Panelwhich in turn contains a collection ofwx.StaticTextwidgets, which are laid out vertically, and display labels for each of the items in the list. Some rudimentary wrapper methods for modifying the list contents are provided by anEditableListBoxobject, with an interface similar to that of thewx.ListBoxclass.In addition to displaying
StaticTextcontrols, theEditableListBoxcan also display arbitrary panels/controls associated with each label - see theInsert()andSetItemWidget`()methods.Warning
If you are using an
EditableListBoxto display arbitrary controls/panels it is important to know that theEditableListBoxassumes that all items are of the same size. Sizing/scrolling will not work properly if controls/panels for different list items are of different sizes.The following style flags are available:
If enabled, there will be no scrollbar.
If enabled, there will be no add item button.
If enabled, there will be no remove item button.
If enabled there will be no move item up or move item down buttons.
If enabled, the first item in the list (index 0) will be shown at the bottom, and the last item at the top.
If enabled, list items will be replaced with a tooltip on mouse-over.
If enabled, double clicking a list item will allow the user to edit the item value.
If enabled, item labels are not shown - this is intended for lists which are to consist solely of widgets (see the
extraWidgetparameter to theInsert()method).If enabled, item widgets are shown to the right of the item label.
If enabled, when the left mouse button is clicked and held down on a list item, the item label is replaced with its tooltip while the mouse is held down.
If enabled, and
ELB_NO_SCROLLis not enabled, up/down buttons are added above/below the list, which allow the user to scroll up/down.An
EditableListBoxgenerates the following events:alias of
wx.lib.newevent.NewEvent.<locals>._Eventalias of
wx.lib.newevent.NewEvent.<locals>._Eventalias of
wx.lib.newevent.NewEvent.<locals>._Eventalias of
wx.lib.newevent.NewEvent.<locals>._Eventalias of
wx.lib.newevent.NewEvent.<locals>._Eventalias of
wx.lib.newevent.NewEvent.<locals>._EventNote
The
EditableListBoxis an alternative to thewx.gizmos.EditableListBox. The latter is buggy under OS X, and getting tooltips working with thewx.ListBoxis an absolute pain in the behind. So I felt the need to replicate its functionality. This implementation supports single selection only.Create an
EditableListBox.- Parameters
parent –
wxparent objectlabels – List of strings, the items in the list
clientData – List of data associated with the list items.
tooltips – List of strings, tooltips for each item.
style – Style bitmask - accepts
ELB_NO_SCROLL,ELB_NO_ADD,ELB_NO_REMOVE,ELB_NO_MOVE,ELB_REVERSE,ELB_TOOLTIP,ELB_EDITABLE,ELB_NO_LABEL,ELB_WIDGET_RIGHT,ELB_TOOLTIP_DOWN, andELB_SCROLL_BUTTONS.vgap – Vertical gap in pixels between each item. Ignored if
ELB_NO_LABELis set.
-
VisibleItemCount()[source]¶ Returns the number of items in the list which are visible (i.e. which have not been hidden via a call to
ApplyFilter()).
-
GetSelection()[source]¶ Returns the index of the selected item, or
wx.NOT_FOUNDif no item is selected.
-
Insert(label, pos, clientData=None, tooltip=None, extraWidget=None)[source]¶ Insert an item into the list.
- Parameters
label – The label to be displayed.
pos – Index at which the item is to be inserted.
clientData – Data associated with the item.
tooltip – Tooltip to be shown, if the
ELB_TOOLTIPstyle is active.extraWidget – A widget to be displayed alongside the label.
-
Append(label, clientData=None, tooltip=None, extraWidget=None)[source]¶ Appends an item to the end of the list.
- Parameters
label – The label to be displayed
clientData – Data associated with the item
tooltip – Tooltip to be shown, if the
ELB_TOOLTIPstyle is active.extraWidget – A widget to be displayed alonside the item.
-
SetItemLabel(n, s)[source]¶ Sets the label of the item at index
nto the strings.- Parameters
n – Index of the item.
s – New label for the item.
-
GetItemLabel(n)[source]¶ Returns the label of the item at index
n.- Parameters
n – Index of the item.
-
SetItemWidget(n, widget=None)[source]¶ Sets the widget to be displayed alongside the item at index
n.If
widgetis set toNone, any existing widget associated with the item is destroyed.
-
GetItemWidget(i)[source]¶ Returns the widget for the item at index
i, orNone, if the widget hasn’t been set.
-
SetItemForegroundColour(n, defaultColour=None, selectedColour=None)[source]¶ Sets the foreground colour of the item at index
n.
-
SetItemBackgroundColour(n, defaultColour=None, selectedColour=None)[source]¶ Sets the background colour of the item at index
n.
-
ApplyFilter(filterStr=None, ignoreCase=False)[source]¶ Hides any items for which the label does not contain the given
filterStr.To clear the filter (and hence show all items), pass in
filterStr=None.
-
MoveItem(offset, event=False)[source]¶ Move the currently selected item the specified offset.
Called when the move up or move down buttons are pushed.
Moves the selected item by the specified offset unless it doesn’t make sense to do the move.
If the item is moved, and
event is True, posts aEVT_ELB_MOVE_EVENT,
-
fsleyes_widgets.elistbox.EVT_ELB_SELECT_EVENT= <wx.core.PyEventBinder object>¶ Identifier for the
ListSelectEventevent.
-
fsleyes_widgets.elistbox.EVT_ELB_ADD_EVENT= <wx.core.PyEventBinder object>¶ Identifier for the
ListAddEventevent.
-
fsleyes_widgets.elistbox.EVT_ELB_REMOVE_EVENT= <wx.core.PyEventBinder object>¶ Identifier for the
ListRemoveEventevent.
-
fsleyes_widgets.elistbox.EVT_ELB_MOVE_EVENT= <wx.core.PyEventBinder object>¶ Identifier for the
ListMoveEventevent.
-
fsleyes_widgets.elistbox.EVT_ELB_EDIT_EVENT= <wx.core.PyEventBinder object>¶ Identifier for the
ListEditEventevent.
-
fsleyes_widgets.elistbox.ListSelectEvent¶ alias of
wx.lib.newevent.NewEvent.<locals>._Event
-
fsleyes_widgets.elistbox.ListAddEvent¶ alias of
wx.lib.newevent.NewEvent.<locals>._Event
-
fsleyes_widgets.elistbox.ListRemoveEvent¶ alias of
wx.lib.newevent.NewEvent.<locals>._Event
-
fsleyes_widgets.elistbox.ListMoveEvent¶ alias of
wx.lib.newevent.NewEvent.<locals>._Event
-
fsleyes_widgets.elistbox.ListEditEvent¶ alias of
wx.lib.newevent.NewEvent.<locals>._Event
-
fsleyes_widgets.elistbox.ListDblClickEvent¶ alias of
wx.lib.newevent.NewEvent.<locals>._Event
-
fsleyes_widgets.elistbox.ELB_NO_SCROLL= 1¶ If enabled, there will be no scrollbar.
-
fsleyes_widgets.elistbox.ELB_NO_ADD= 2¶ If enabled, there will be no add item button.
-
fsleyes_widgets.elistbox.ELB_NO_REMOVE= 4¶ If enabled, there will be no remove item button.
-
fsleyes_widgets.elistbox.ELB_NO_MOVE= 8¶ If enabled there will be no move item up or move item down buttons.
-
fsleyes_widgets.elistbox.ELB_REVERSE= 16¶ If enabled, the first item in the list (index 0) will be shown at the bottom, and the last item at the top.
-
fsleyes_widgets.elistbox.ELB_TOOLTIP= 32¶ If enabled, list items will be replaced with a tooltip on mouse-over. If disabled, a regular tooltip is shown.
-
fsleyes_widgets.elistbox.ELB_EDITABLE= 64¶ If enabled, double clicking a list item will allow the user to edit the item value.
If this style is disabled, the
EVT_ELB_DBLCLICK_EVENTwill not be generated.
-
fsleyes_widgets.elistbox.ELB_NO_LABELS= 128¶ If enabled, item labels are not shown - this is intended for lists which are to consist solely of widgets (see the
extraWidgetparameter to theInsert()method). This style flag will negate theELB_EDITABLEflag.
-
fsleyes_widgets.elistbox.ELB_WIDGET_RIGHT= 256¶ If enabled, item widgets are shown to the right of the item label. Otherwise (by default) item widgets are shown to the left.
-
fsleyes_widgets.elistbox.ELB_TOOLTIP_DOWN= 512¶ If enabled, when the left mouse button is clicked and held down on a list item, the item label is replaced with its tooltip while the mouse is held down. This style is ignored if the
ELB_TOOLTIPstyle is active.
-
fsleyes_widgets.elistbox.ELB_SCROLL_BUTTONS= 1024¶ If enabled, and
ELB_NO_SCROLLis not enabled, up/down buttons are added above/below the list, which allow the user to scroll up/down.