phoenix_title 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.

styles 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 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

wx.TextCtrl


class_hierarchy Class Hierarchy

Inheritance diagram for class SearchCtrl:

appearance Control Appearance


wxMSW

wxMSW

wxMAC

wxMAC

wxGTK

wxGTK


method_summary Methods Summary

__init__

Default constructor.

AppendText

Appends the text to the end of the text control.

AutoComplete

Call this function to enable auto-completion of the text typed in a single-line text control using the given choices.

AutoCompleteDirectories

Call this function to enable auto-completion of the text using the file system directories.

AutoCompleteFileNames

Call this function to enable auto-completion of the text typed in a single-line text control using all valid file system paths.

CanCopy

Returns True if the selection can be copied to the clipboard.

CanCut

Returns True if the selection can be cut to the clipboard.

CanPaste

Returns True if the contents of the clipboard can be pasted into the text control.

CanRedo

Returns True if there is a redo facility available and the last operation can be redone.

CanUndo

Returns True if there is an undo facility available and the last operation can be undone.

ChangeValue

Sets the new text control value.

Clear

Clears the text in the control.

Copy

Copies the selected text to the clipboard.

Create

Cut

Copies the selected text to the clipboard and removes it from the control.

ForceUpper

Convert all text entered into the control to upper case.

GetClassDefaultAttributes

GetDescriptiveText

Return the text displayed when there is not yet any user input.

GetHint

Returns the current hint string.

GetInsertionPoint

Returns the insertion point, or cursor, position.

GetLastPosition

Returns the zero based index of the last position in the text control, which is equal to the number of characters in the control.

GetMargins

Returns the margins used by the control.

GetMenu

Returns a pointer to the search control’s menu object or None if there is no menu attached.

GetRange

Returns the string containing the text starting in the positions from and up to to in the control.

GetSelection

Gets the current selection span.

GetStringSelection

Gets the text currently selected in the control.

GetValue

Gets the contents of the control.

IsCancelButtonVisible

Returns the cancel button’s visibility state.

IsEditable

Returns True if the controls contents may be edited by user (note that it always can be changed by the program).

IsEmpty

Returns True if the control is currently empty.

IsSearchButtonVisible

Returns the search button visibility value.

Paste

Pastes text from the clipboard to the text item.

Redo

If there is a redo facility and the last operation can be redone, redoes the last operation.

Remove

Removes the text starting at the first given position up to (but not including) the character at the last position.

Replace

Replaces the text starting at the first position up to (but not including) the character at the last position with the given text.

SelectAll

Selects all text in the control.

SelectNone

Deselects selected text in the control.

SetCancelBitmap

SetDescriptiveText

Set the text to be displayed in the search control when the user has not yet typed anything in it.

SetEditable

Makes the text item editable or read-only, overriding the wx.TE_READONLY flag.

SetHint

Sets a hint shown in an empty unfocused text control.

SetInsertionPoint

Sets the insertion point at the given position.

SetInsertionPointEnd

Sets the insertion point at the end of the text control.

SetMargins

Attempts to set the control margins.

SetMaxLength

This function sets the maximum number of characters the user can enter into the control.

SetMenu

Sets the search control’s menu object.

SetSearchBitmap

SetSearchMenuBitmap

SetSelection

Selects the text starting at the first position up to (but not including) the character at the last position.

SetValue

Sets the new text control value.

ShowCancelButton

Shows or hides the cancel button.

ShowSearchButton

Sets the search button visibility value on the search control.

Undo

If there is an undo facility and the last operation can be undone, undoes the last operation.

WriteText

Writes the text into the text control at the current insertion position.


property_summary Properties Summary

CancelButtonVisible

See IsCancelButtonVisible and ShowCancelButton

DescriptiveText

See GetDescriptiveText and SetDescriptiveText

Hint

See GetHint and SetHint

InsertionPoint

See GetInsertionPoint and SetInsertionPoint

LastPosition

See GetLastPosition

Margins

See GetMargins and SetMargins

Menu

See GetMenu and SetMenu

SearchButtonVisible

See IsSearchButtonVisible and ShowSearchButton

StringSelection

See GetStringSelection

Value

See GetValue and SetValue


api Class API

class wx.SearchCtrl(Control)

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.


Methods

__init__(self, *args, **kw)

overload Overloaded Implementations:



__init__ (self)

Default constructor.

Return type:

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.

Parameters:
  • 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.

Return type:

None





AppendText(self, text)

Appends the text to the end of the text control.