wx.SearchCtrl¶A search control is a composite control with a search button, a text control, and a cancel button.
This control is implemented natively under macOS and GTK 3.6 or later and generically for all the other platforms.
Please note that this class provides many TextCtrl-like methods, but does not necessarily derive from wx.TextCtrl in all ports (although it does in the generic version). Only the methods defined in wx.TextEntry interface class are guaranteed to be available under all platforms.
Window Styles¶This class supports the following styles:
wx.TE_PROCESS_TAB: The control will receive wxEVT_CHAR events for TAB pressed - normally, TAB is used for passing to the next control in a dialog instead. For the control created with this style, you can still use Ctrl-Enter to pass to the next control from the keyboard.
wx.TE_NOHIDESEL: By default, the Windows text control doesn’t show the selection when it doesn’t have focus - use this style to force it to always show it. It doesn’t do anything under other platforms.
wx.TE_LEFT: The text in the control will be left-justified (default).
wx.TE_CENTRE: The text in the control will be centered (currently wxMSW and wxGTK2 only).
wx.TE_RIGHT: The text in the control will be right-justified (currently wxMSW and wxGTK2 only).
TE_CAPITALIZE: On PocketPC and Smartphone, causes the first letter to be capitalized.
Events Emitted by this Class¶Handlers bound for the following event types will receive a wx.CommandEvent parameter.
EVT_SEARCH: Respond to a wxEVT_SEARCH event, generated when the search button is clicked. Note that this does not initiate a search on its own, you need to perform the appropriate action in your event handler. You may use:
event.GetString()
to retrieve the string to search for in the event handler code.
EVT_SEARCH_CANCEL: Respond to a wxEVT_SEARCH_CANCEL event, generated when the cancel button is clicked.
See also
Class Hierarchy¶
Inheritance diagram for class SearchCtrl:
Control Appearance¶
Methods Summary¶Default constructor. |
|
Appends the text to the end of the text control. |
|
Call this function to enable auto-completion of the text typed in a single-line text control using the given choices. |
|
Call this function to enable auto-completion of the text using the file system directories. |
|
Call this function to enable auto-completion of the text typed in a single-line text control using all valid file system paths. |
|
Returns |
|
Returns |
|
Returns |
|
Returns |
|
Returns |
|
Sets the new text control value. |
|
Clears the text in the control. |
|
Copies the selected text to the clipboard. |
|
Copies the selected text to the clipboard and removes it from the control. |
|
Convert all text entered into the control to upper case. |
|
Return the text displayed when there is not yet any user input. |
|
Returns the current hint string. |
|
Returns the insertion point, or cursor, position. |
|
Returns the zero based index of the last position in the text control, which is equal to the number of characters in the control. |
|
Returns the margins used by the control. |
|
Returns a pointer to the search control’s menu object or |
|
Returns the string containing the text starting in the positions from and up to to in the control. |
|
Gets the current selection span. |
|
Gets the text currently selected in the control. |
|
Gets the contents of the control. |
|
Returns the cancel button’s visibility state. |
|
Returns |
|
Returns |
|
Returns the search button visibility value. |
|
Pastes text from the clipboard to the text item. |
|
If there is a redo facility and the last operation can be redone, redoes the last operation. |
|
Removes the text starting at the first given position up to (but not including) the character at the last position. |
|
Replaces the text starting at the first position up to (but not including) the character at the last position with the given text. |
|
Selects all text in the control. |
|
Deselects selected text in the control. |
|
Set the text to be displayed in the search control when the user has not yet typed anything in it. |
|
Makes the text item editable or read-only, overriding the |
|
Sets a hint shown in an empty unfocused text control. |
|
Sets the insertion point at the given position. |
|
Sets the insertion point at the end of the text control. |
|
Attempts to set the control margins. |
|
This function sets the maximum number of characters the user can enter into the control. |
|
Sets the search control’s menu object. |
|
Selects the text starting at the first position up to (but not including) the character at the last position. |
|
Sets the new text control value. |
|
Shows or hides the cancel button. |
|
Sets the search button visibility value on the search control. |
|
If there is an undo facility and the last operation can be undone, undoes the last operation. |
|
Writes the text into the text control at the current insertion position. |
Properties Summary¶See |
|
See |
|
See |
|
See |
|
Class API¶Possible constructors:
SearchCtrl() -> None
SearchCtrl(parent, id=ID_ANY, value='', pos=DefaultPosition,
size=DefaultSize, style=0, validator=DefaultValidator,
name=SearchCtrlNameStr) -> None
A search control is a composite control with a search button, a text control, and a cancel button.
__init__ (self)
Default constructor.
None
__init__ (self, parent, id=ID_ANY, value=’’, pos=DefaultPosition, size=DefaultSize, style=0, validator=DefaultValidator, name=SearchCtrlNameStr)
Constructor, creating and showing a text control.
parent (wx.Window) – Parent window. Should not be None.
id (wx.WindowID) – Control identifier. A value of -1 denotes a default value.
value (string) – Default text value.
pos (wx.Point) – Text control position.
size (wx.Size) – Text control size.
style (long) – Window style. See wx.SearchCtrl.
validator (wx.Validator) – Window validator.
name (string) – Window name.
None
See also
Appends the text to the end of the text control.