fsleyes_widgets.autotextctrl¶
This module provides the AutoTextCtrl class, an alternative to the
wx.TextCtrl, which has auto-completion capability.
I wrote this class because wx.TextCtrl auto-completion does not work under
OSX, and the wx.ComboBox does not give me enough fine-grained control with
respect to managing focus.
-
class
fsleyes_widgets.autotextctrl.AutoTextCtrl(parent, style=0, ownloop=True)¶ Bases:
wx._core.PanelThe
AutoTextCtrlclass is essentially awx.TextCtrlwhich is able to dynamically show a list of options to the user, with aAutoCompletePopup.Create an
AutoTextCtrl.Parameters: - parent – The
wxparent object. - style – Can be
ATC_CASE_SENSITIVEto restrict the auto-completion options to case sensitive matches.
arg ownloop: See
AutoCompletePopup.__init__().-
__init__(parent, style=0, ownloop=True)¶ Create an
AutoTextCtrl.Parameters: - parent – The
wxparent object. - style – Can be
ATC_CASE_SENSITIVEto restrict the auto-completion options to case sensitive matches.
arg ownloop: See
AutoCompletePopup.__init__().- parent – The
-
textCtrl¶ Returns a reference to the internal
wx.TextCtrl.
-
popup¶ Returns a reference to the
AutoCompletePopuporNoneif it is not currently shown.
-
AutoComplete(options)¶ Set the list of options to be shown to the user.
-
GetValue()¶ Returns the current value shown on this
AutoTextCtrl.
-
SetValue(value)¶ Sets the current value shown on this
AutoTextCtrl.Note
Calling this method will result in an
wx.EVT_TEXTevent being generated - useChangeValue()if you do not want this to occur.
-
ChangeValue(value)¶ Sets the current value shown on this
AutoTextCtrl.
-
GetInsertionPoint()¶ Returns the cursor location in this
AutoTextCtrl.
-
SetInsertionPoint(idx)¶ Sets the cursor location in this
AutoTextCtrl.
-
GenEnterEvent()¶ Programmatically generates an
EVT_ATC_TEXT_ENTERevent.
-
SetTakeFocus(takeFocus)¶ If
takeFocusisTrue, thisAutoTextCtrlwill give itself focus when itsAutoCompletePopupis closed.
-
_AutoTextCtrl__onDoubleClick(ev)¶ Called when the user double clicks in this
AutoTextCtrl. Creates anAutoCompletePopup.
-
_AutoTextCtrl__onEnter(ev)¶ Called when the user presses enter in this
AutoTextCtrl. Generates anEVT_ATC_TEXT_ENTERevent.
-
_AutoTextCtrl__onKeyDown(ev)¶ Called on
EVT_KEY_DOWNevents in the text control.
-
_AutoTextCtrl__onSetFocus(ev)¶ Called when this
AutoTextCtrlor any of its children gains focus. Makes sure that the text control insertion point is at the end of its current contents.
-
_AutoTextCtrl__onText(ev)¶ Called when the user changes the text shown on this
AutoTextCtrl. Creates anAutoCompletePopup.
-
_AutoTextCtrl__showPopup(text)¶ Creates an
AutoCompletePopupwhich displays a list of auto-completion options, matching the given prefix text, to the user.The popup is not displayed if there are no options with the given prefix.
-
__module__= 'fsleyes_widgets.autotextctrl'¶
- parent – The
-
fsleyes_widgets.autotextctrl.ATC_CASE_SENSITIVE= 1¶ Syle flag for use with the
AutoTextCtrlclass. If set, the auto-completion pattern matching will be case sensitive.
-
fsleyes_widgets.autotextctrl.EVT_ATC_TEXT_ENTER= <wx.core.PyEventBinder object>¶ Identifier for the
AutoTextCtrlEnterEvent, which is generated when the user presses enter in anAutoTextCtrl.
-
fsleyes_widgets.autotextctrl.AutoTextCtrlEnterEvent¶ alias of
wx.lib.newevent.NewEvent.<locals>._Event
-
class
fsleyes_widgets.autotextctrl.AutoCompletePopup(parent, atc, text, options, style=0, ownloop=True)¶ Bases:
wx._core.FrameThe
AutoCompletePopupclass is used by theAutoTextCtrlto display a list of completion options to the user.Create an
AutoCompletePopup.Parameters: - parent – The
wxparent object. - atc – The
AutoTextCtrlthat is using this popup. - text – Initial text value.
- options – A list of all possible auto-completion options.
- style – Set to
ATC_CASE_SENSITIVEto make the pattern matching case sensitive. - ownloop – If
True(the default), a separate event loop is created and run while the popup is displayed. This gives the popup modal behaviour.
-
__init__(parent, atc, text, options, style=0, ownloop=True)¶ Create an
AutoCompletePopup.Parameters: - parent – The
wxparent object. - atc – The
AutoTextCtrlthat is using this popup. - text – Initial text value.
- options – A list of all possible auto-completion options.
- style – Set to
ATC_CASE_SENSITIVEto make the pattern matching case sensitive. - ownloop – If
True(the default), a separate event loop is created and run while the popup is displayed. This gives the popup modal behaviour.
- parent – The
-
Show()¶ Shows this
AutoCompletePopup. If theownloopparameter passed to__init__()wasTrue, a A newwx.GUIEventLoopis created and started, until thisAutoCompletePopuploses focus.
-
GetCount()¶ Returns the number of auto-completion options currently available.
-
textCtrl¶ Returns a reference to the
wx.TextCtrl.
-
listBox¶ Returns a reference to the
wx.ListBox.
-
_AutoCompletePopup__destroy(genEnter=True, returnFocus=True)¶ Called by various event handlers. Copies the current value in this
AutoCompletePopupto the owningAutoTextCtrl, and then (asynchronously) destroys thisAutoCompletePopup.
-
_AutoCompletePopup__getMatches(prefix)¶ Returns a list of auto-completion options which match the given prefix.
-
_AutoCompletePopup__onEnter(ev)¶ Called on an
EVT_TEXT_ENTERevent from the text control.
-
_AutoCompletePopup__onKeyDown(ev)¶ Called on an
EVT_KEY_DOWNevent from the text control.
-
_AutoCompletePopup__onKillFocus(ev)¶ Called when this
AutoCompletePopuploses focus. Calls__destroy().
-
_AutoCompletePopup__onListKeyDown(ev)¶ Called on an
EVT_KEY_DOWNevent from the list box.
-
_AutoCompletePopup__onListMouseDblClick(ev)¶ Called when the user double clicks an item in the list box.
-
_AutoCompletePopup__onListMouseDown(ev)¶ Called on GTK when the user clicks in the list box. Forces the list box to have focus.
-
_AutoCompletePopup__onSetFocus(ev)¶ Called when this
AutoCompletePopupor any of its children gains focus. Makes sure that the text control insertion point is at the end of its current contents.
-
_AutoCompletePopup__onText(ev)¶ Called on an
EVT_TEXTevent from the text control.
-
__module__= 'fsleyes_widgets.autotextctrl'¶
- parent – The
-
fsleyes_widgets.autotextctrl.EVT_ATC_POPUP_DESTROY= <wx.core.PyEventBinder object>¶ Identifier for the
ATCPopupDestroyEvent.
-
fsleyes_widgets.autotextctrl.ATCPopupDestroyEvent¶ alias of
wx.lib.newevent.NewEvent.<locals>._Event