.. wxPython Phoenix documentation

   This file was generated by Phoenix's sphinx generator and associated
   tools, do not edit by hand.

   Copyright: (c) 2011-2020 by Total Control Software
   License:   wxWindows License

.. include:: headings.inc



.. _wx.ComboCtrl:

==========================================================================================================================================
|phoenix_title|  **wx.ComboCtrl**
==========================================================================================================================================

A combo control is a generic combobox that allows totally custom popup.          

In addition it has other customization features. For instance, position and size of the dropdown button can be changed. 



|phoenix_title| Setting Custom Popup for ComboCtrl
==================================================

:ref:`wx.ComboCtrl`  needs to be told somehow which control to use and this is done by :meth:`~wx.ComboCtrl.SetPopupControl`. However, we need something more than just a :ref:`wx.Control`  in this method as, for example, we need to call SetStringValue("initial text value") and :ref:`wx.Control`  doesn't have such method. So we also need a :ref:`wx.ComboPopup`  which is an interface which must be implemented by a control to be usable as a popup. We couldn't derive :ref:`wx.ComboPopup`  from :ref:`wx.Control`  as this would make it impossible to have a class deriving from a wxWidgets control and from it, so instead it is just a mix-in. Here's a minimal sample of :ref:`wx.ListView`  popup: ::

        """
        A simple test case for wx.ComboCtrl using a wx.ListCtrl for the popup
        """

        import wx

        #----------------------------------------------------------------------
        # This class is used to provide an interface between a ComboCtrl and the
        # ListCtrl that is used as the popoup for the combo widget.

        class ListCtrlComboPopup(wx.ComboPopup):

            def __init__(self):
                wx.ComboPopup.__init__(self)
                self.lc = None

            def AddItem(self, txt):
                self.lc.InsertItem(self.lc.GetItemCount(), txt)

            def OnMotion(self, evt):
                item, flags = self.lc.HitTest(evt.GetPosition())
                if item >= 0:
                    self.lc.Select(item)
                    self.curitem = item

            def OnLeftDown(self, evt):
                self.value = self.curitem
                self.Dismiss()


            # The following methods are those that are overridable from the
            # ComboPopup base class.  Most of them are not required, but all
            # are shown here for demonstration purposes.

            # This is called immediately after construction finishes.  You can
            # use self.GetCombo if needed to get to the ComboCtrl instance.
            def Init(self):
                self.value = -1
                self.curitem = -1

            # Create the popup child control.  Return true for success.
            def Create(self, parent):
                self.lc = wx.ListCtrl(parent, style=wx.LC_LIST | wx.LC_SINGLE_SEL | wx.SIMPLE_BORDER)
                self.lc.Bind(wx.EVT_MOTION, self.OnMotion)
                self.lc.Bind(wx.EVT_LEFT_DOWN, self.OnLeftDown)
                return True

            # Return the widget that is to be used for the popup
            def GetControl(self):
                return self.lc

            # Called just prior to displaying the popup, you can use it to
            # 'select' the current item.
            def SetStringValue(self, val):
                idx = self.lc.FindItem(-1, val)
                if idx != wx.NOT_FOUND:
                    self.lc.Select(idx)

            # Return a string representation of the current item.
            def GetStringValue(self):
                if self.value >= 0:
                    return self.lc.GetItemText(self.value)
                return ""

            # Called immediately after the popup is shown
            def OnPopup(self):
                wx.ComboPopup.OnPopup(self)

            # Called when popup is dismissed
            def OnDismiss(self):
                wx.ComboPopup.OnDismiss(self)

            # This is called to custom paint in the combo control itself
            # (ie. not the popup).  Default implementation draws value as
            # string.
            def PaintComboControl(self, dc, rect):
                wx.ComboPopup.PaintComboControl(self, dc, rect)

            # Receives key events from the parent ComboCtrl.  Events not
            # handled should be skipped, as usual.
            def OnComboKeyEvent(self, event):
                wx.ComboPopup.OnComboKeyEvent(self, event)

            # Implement if you need to support special action when user
            # double-clicks on the parent wxComboCtrl.
            def OnComboDoubleClick(self):
                wx.ComboPopup.OnComboDoubleClick(self)

            # Return final size of popup. Called on every popup, just prior to OnPopup.
            # minWidth = preferred minimum width for window
            # prefHeight = preferred height. Only applies if > 0,
            # maxHeight = max height for window, as limited by screen size
            #   and should only be rounded down, if necessary.
            def GetAdjustedSize(self, minWidth, prefHeight, maxHeight):
                return wx.ComboPopup.GetAdjustedSize(self, minWidth, prefHeight, maxHeight)

            # Return true if you want delay the call to Create until the popup
            # is shown for the first time. It is more efficient, but note that
            # it is often more convenient to have the control created
            # immediately.
            # Default returns false.
            def LazyCreate(self):
                return wx.ComboPopup.LazyCreate(self)

Here's how you would create and populate it in a dialog constructor: ::

        comboCtrl = wx.ComboCtrl(self, wx.ID_ANY, "")

        popupCtrl = ListViewComboPopup()

        # It is important to call SetPopupControl() as soon as possible
        comboCtrl.SetPopupControl(popupCtrl)

        # Populate using wx.ListView methods
        popupCtrl.InsertItem(popupCtrl.GetItemCount(), "First Item")
        popupCtrl.InsertItem(popupCtrl.GetItemCount(), "Second Item")
        popupCtrl.InsertItem(popupCtrl.GetItemCount(), "Third Item")



.. _ComboCtrl-styles:

|styles| Window Styles
================================

This class supports the following styles:   

- ``wx.CB_READONLY``: Text will not be editable.  
- ``wx.CB_SORT``: Sorts the entries in the list alphabetically.  
- ``wx.TE_PROCESS_ENTER``: The control will generate the event  ``wxEVT_TEXT_ENTER``   (otherwise pressing Enter key is either processed internally by the control or used for navigation between dialog controls). Windows only.   
- ``wx.CC_SPECIAL_DCLICK``: Double-clicking triggers a call to popup's OnComboDoubleClick. Actual behaviour is defined by a derived class. For instance, :ref:`wx.adv.OwnerDrawnComboBox`  will cycle an item. This style only applies if ``wx.CB_READONLY`` is used as well.  
- ``wx.CC_STD_BUTTON``: Drop button will behave more like a standard push button.  






.. _ComboCtrl-events:

|events| Events Emitted by this Class
=====================================

Handlers bound for the following event types will receive one of the :ref:`wx.CommandEvent` parameters.

- EVT_TEXT: Process a  ``wxEVT_TEXT``   event, when the text changes.   
- EVT_TEXT_ENTER: Process a  ``wxEVT_TEXT_ENTER``   event, when ``RETURN`` is pressed in the combo control.   
- EVT_COMBOBOX_DROPDOWN: Process a  ``wxEVT_COMBOBOX_DROPDOWN``   event, which is generated when the popup window is shown (drops down).   
- EVT_COMBOBOX_CLOSEUP: Process a  ``wxEVT_COMBOBOX_CLOSEUP``   event, which is generated when the popup window of the combo control disappears (closes up). You should avoid adding or deleting items in this event.   






.. seealso:: :ref:`wx.ComboBox`, :ref:`wx.Choice`, :ref:`wx.adv.OwnerDrawnComboBox`, :ref:`wx.ComboPopup`, :ref:`wx.CommandEvent`    







|

|class_hierarchy| Class Hierarchy
=================================

.. raw:: html

   <div id="toggleBlock" onclick="return toggleVisibility(this)" class="closed" style="cursor:pointer;">
   <img id="toggleBlock-trigger" src="_static/images/closed.png"/>
   Inheritance diagram for class <strong>ComboCtrl</strong>:
   </div>
   <div id="toggleBlock-summary" style="display:block;"></div>
   <div id="toggleBlock-content" style="display:none;">
   <p class="graphviz">
   <center><img src="_static/images/inheritance/wx.ComboCtrl_inheritance.png" alt="Inheritance diagram of ComboCtrl" usemap="#dummy" class="inheritance"/></center>
   <script type="text/javascript">toggleVisibilityOnLoad(document.getElementById('toggleBlock'))</script>
   <map id="dummy" name="dummy"> <area shape="rect" id="node1" href="wx.ComboCtrl.html" title="wx.ComboCtrl" alt="" coords="113,315,227,344"/> <area shape="rect" id="node2" href="wx.Control.html" title="wx.Control" alt="" coords="63,237,155,267"/> <area shape="rect" id="node3" href="wx.TextEntry.html" title="wx.TextEntry" alt="" coords="179,237,286,267"/> <area shape="rect" id="node4" href="wx.Window.html" title="wx.Window" alt="" coords="60,160,157,189"/> <area shape="rect" id="node5" href="wx.EvtHandler.html" title="wx.EvtHandler" alt="" coords="50,83,167,112"/> <area shape="rect" id="node6" href="wx.Object.html" title="wx.Object" alt="" coords="5,5,92,35"/> <area shape="rect" id="node7" href="wx.Trackable.html" title="wx.Trackable" alt="" coords="117,5,223,35"/> </map> 
   </p>
   </div>

|


|appearance| Control Appearance
===============================

|

.. figure:: _static/images/widgets/fullsize/wxmsw/wx.comboctrl.png
   :alt: wxMSW
   :figclass: floatleft

   **wxMSW**


.. figure:: _static/images/widgets/fullsize/wxmac/wx.comboctrl.png
   :alt: wxMAC
   :figclass: floatright

   **wxMAC**


.. figure:: _static/images/widgets/fullsize/wxgtk/wx.comboctrl.png
   :alt: wxGTK
   :figclass: floatcenter

   **wxGTK**


|


|sub_classes| Known Subclasses
==============================

:ref:`wx.adv.OwnerDrawnComboBox`, :ref:`wx.richtext.RichTextStyleComboCtrl`

|


|method_summary| Methods Summary
================================

================================================================================ ================================================================================
:meth:`~wx.ComboCtrl.__init__`                                                   Default constructor.
:meth:`~wx.ComboCtrl.AnimateShow`                                                This member function is not normally called in application code.
:meth:`~wx.ComboCtrl.Copy`                                                       Copies the selected text to the clipboard.
:meth:`~wx.ComboCtrl.Create`                                                     Creates the combo control for two-step construction.
:meth:`~wx.ComboCtrl.Cut`                                                        Copies the selected text to the clipboard and removes the selection.
:meth:`~wx.ComboCtrl.Dismiss`                                                    Dismisses the popup window.
:meth:`~wx.ComboCtrl.DoSetPopupControl`                                          This member function is not normally called in application code.
:meth:`~wx.ComboCtrl.DoShowPopup`                                                This member function is not normally called in application code.
:meth:`~wx.ComboCtrl.EnablePopupAnimation`                                       Enables or disables popup animation, if any, depending on the value of the argument.
:meth:`~wx.ComboCtrl.GetBitmapDisabled`                                          Returns disabled button bitmap that has been set with :meth:`~ComboCtrl.SetButtonBitmaps` .
:meth:`~wx.ComboCtrl.GetBitmapHover`                                             Returns button mouse hover bitmap that has been set with :meth:`~ComboCtrl.SetButtonBitmaps` .
:meth:`~wx.ComboCtrl.GetBitmapNormal`                                            Returns default button bitmap that has been set with :meth:`~ComboCtrl.SetButtonBitmaps` .
:meth:`~wx.ComboCtrl.GetBitmapPressed`                                           Returns depressed button bitmap that has been set with :meth:`~ComboCtrl.SetButtonBitmaps` .
:meth:`~wx.ComboCtrl.GetButtonSize`                                              Returns current size of the dropdown button.
:meth:`~wx.ComboCtrl.GetClassDefaultAttributes`                                  
:meth:`~wx.ComboCtrl.GetCustomPaintWidth`                                        Returns custom painted area in control.
:meth:`~wx.ComboCtrl.GetFeatures`                                                Returns features supported by :ref:`wx.ComboCtrl`.
:meth:`~wx.ComboCtrl.GetHint`                                                    Returns the current hint string.
:meth:`~wx.ComboCtrl.GetInsertionPoint`                                          Returns the insertion point for the combo control's text field.
:meth:`~wx.ComboCtrl.GetLastPosition`                                            Returns the last position in the combo control text field.
:meth:`~wx.ComboCtrl.GetMargins`                                                 Returns the margins used by the control.
:meth:`~wx.ComboCtrl.GetPopupControl`                                            Returns current popup interface that has been set with :meth:`~ComboCtrl.SetPopupControl` .
:meth:`~wx.ComboCtrl.GetPopupWindow`                                             Returns popup window containing the popup control.
:meth:`~wx.ComboCtrl.GetTextCtrl`                                                Get the text control which is part of the combo control.
:meth:`~wx.ComboCtrl.GetTextRect`                                                Returns area covered by the text field (includes everything except borders and the dropdown button).
:meth:`~wx.ComboCtrl.GetValue`                                                   Returns text representation of the current value.
:meth:`~wx.ComboCtrl.HidePopup`                                                  Dismisses the popup window.
:meth:`~wx.ComboCtrl.IsKeyPopupToggle`                                           Returns ``True`` if given key combination should toggle the popup.
:meth:`~wx.ComboCtrl.IsPopupShown`                                               Returns ``True`` if the popup is currently shown.
:meth:`~wx.ComboCtrl.IsPopupWindowState`                                         Returns ``True`` if the popup window is in the given state.
:meth:`~wx.ComboCtrl.OnButtonClick`                                              Implement in a derived class to define what happens on dropdown button click.
:meth:`~wx.ComboCtrl.Paste`                                                      Pastes text from the clipboard to the text field.
:meth:`~wx.ComboCtrl.Popup`                                                      Shows the popup portion of the combo control.
:meth:`~wx.ComboCtrl.PrepareBackground`                                          Prepare background of combo control or an item in a dropdown list in a way typical on platform.
:meth:`~wx.ComboCtrl.Remove`                                                     Removes the text between the two positions in the combo control text field.
:meth:`~wx.ComboCtrl.Replace`                                                    Replaces the text between two positions with the given text, in the combo control text field.
:meth:`~wx.ComboCtrl.SetButtonBitmaps`                                           Sets custom dropdown button graphics.
:meth:`~wx.ComboCtrl.SetButtonPosition`                                          Sets size and position of dropdown button.
:meth:`~wx.ComboCtrl.SetCustomPaintWidth`                                        Set width, in pixels, of custom painted area in control without  ``CB_READONLY``   style.
:meth:`~wx.ComboCtrl.SetHint`                                                    Sets a hint shown in an empty unfocused combo control.
:meth:`~wx.ComboCtrl.SetInsertionPoint`                                          Sets the insertion point in the text field.
:meth:`~wx.ComboCtrl.SetInsertionPointEnd`                                       Sets the insertion point at the end of the combo control text field.
:meth:`~wx.ComboCtrl.SetMargins`                                                 Attempts to set the control margins.
:meth:`~wx.ComboCtrl.SetPopupAnchor`                                             Set side of the control to which the popup will align itself.
:meth:`~wx.ComboCtrl.SetPopupControl`                                            Set popup interface class derived from :ref:`wx.ComboPopup`.
:meth:`~wx.ComboCtrl.SetPopupExtents`                                            Extends popup size horizontally, relative to the edges of the combo control.
:meth:`~wx.ComboCtrl.SetPopupMaxHeight`                                          Sets preferred maximum height of the popup.
:meth:`~wx.ComboCtrl.SetPopupMinWidth`                                           Sets minimum width of the popup.
:meth:`~wx.ComboCtrl.SetSelection`                                               Selects the text between the two positions, in the combo control text field.
:meth:`~wx.ComboCtrl.SetText`                                                    Sets the text for the text field without affecting the popup.
:meth:`~wx.ComboCtrl.SetTextCtrlStyle`                                           Set a custom window style for the embedded :ref:`wx.TextCtrl`.
:meth:`~wx.ComboCtrl.SetValue`                                                   Sets the text for the combo control text field.
:meth:`~wx.ComboCtrl.SetValueByUser`                                             Changes value of the control as if user had done it by selecting an item from a combo box drop-down list.
:meth:`~wx.ComboCtrl.ShouldDrawFocus`                                            Returns ``True`` if focus indicator should be drawn in the control.
:meth:`~wx.ComboCtrl.ShowPopup`                                                  Show the popup.
:meth:`~wx.ComboCtrl.Undo`                                                       Undoes the last edit in the text field.
:meth:`~wx.ComboCtrl.UseAltPopupWindow`                                          Enable or disable usage of an alternative popup window, which guarantees ability to focus the popup control, and allows common native controls to function normally.
================================================================================ ================================================================================


|


|property_summary| Properties Summary
=====================================

================================================================================ ================================================================================
:attr:`~wx.ComboCtrl.BitmapDisabled`                                             See :meth:`~wx.ComboCtrl.GetBitmapDisabled`
:attr:`~wx.ComboCtrl.BitmapHover`                                                See :meth:`~wx.ComboCtrl.GetBitmapHover`
:attr:`~wx.ComboCtrl.BitmapNormal`                                               See :meth:`~wx.ComboCtrl.GetBitmapNormal`
:attr:`~wx.ComboCtrl.BitmapPressed`                                              See :meth:`~wx.ComboCtrl.GetBitmapPressed`
:attr:`~wx.ComboCtrl.ButtonSize`                                                 See :meth:`~wx.ComboCtrl.GetButtonSize`
:attr:`~wx.ComboCtrl.CustomPaintWidth`                                           See :meth:`~wx.ComboCtrl.GetCustomPaintWidth` and :meth:`~wx.ComboCtrl.SetCustomPaintWidth`
:attr:`~wx.ComboCtrl.Hint`                                                       See :meth:`~wx.ComboCtrl.GetHint` and :meth:`~wx.ComboCtrl.SetHint`
:attr:`~wx.ComboCtrl.InsertionPoint`                                             See :meth:`~wx.ComboCtrl.GetInsertionPoint` and :meth:`~wx.ComboCtrl.SetInsertionPoint`
:attr:`~wx.ComboCtrl.LastPosition`                                               See :meth:`~wx.ComboCtrl.GetLastPosition`
:attr:`~wx.ComboCtrl.Margins`                                                    See :meth:`~wx.ComboCtrl.GetMargins` and :meth:`~wx.ComboCtrl.SetMargins`
:attr:`~wx.ComboCtrl.PopupControl`                                               See :meth:`~wx.ComboCtrl.GetPopupControl` and :meth:`~wx.ComboCtrl.SetPopupControl`
:attr:`~wx.ComboCtrl.PopupWindow`                                                See :meth:`~wx.ComboCtrl.GetPopupWindow`
:attr:`~wx.ComboCtrl.TextCtrl`                                                   See :meth:`~wx.ComboCtrl.GetTextCtrl`
:attr:`~wx.ComboCtrl.TextRect`                                                   See :meth:`~wx.ComboCtrl.GetTextRect`
:attr:`~wx.ComboCtrl.Value`                                                      See :meth:`~wx.ComboCtrl.GetValue` and :meth:`~wx.ComboCtrl.SetValue`
================================================================================ ================================================================================


|


|api| Class API
===============


.. class:: wx.ComboCtrl(Control, TextEntry)

   **Possible constructors**::

       ComboCtrl()
       
       ComboCtrl(parent, id=ID_ANY, value=EmptyString, pos=DefaultPosition,
                 size=DefaultSize, style=0, validator=DefaultValidator,
                 name=ComboBoxNameStr)
       
   
   A combo control is a generic combobox that allows totally custom
   popup.



   .. method:: __init__(self, *args, **kw)



      |overload| Overloaded Implementations:

      :html:`<hr class="overloadsep" /><br />`

      
      **__init__** `(self)`
      
      Default constructor.                   
      
      
      
      
      :html:`<hr class="overloadsep" /><br />`

      
      **__init__** `(self, parent, id=ID_ANY, value=EmptyString, pos=DefaultPosition, size=DefaultSize, style=0, validator=DefaultValidator, name=ComboBoxNameStr)`
      
      Constructor, creating and showing a combo control.                  
      
      
      
      
      :param `parent`: Parent window. Must not be ``None``.   
      :type `parent`: wx.Window
      :param `id`: Window identifier. The value ``wx.ID_ANY`` indicates a default value.   
      :type `id`: wx.WindowID
      :param `value`: Initial selection string. An empty string indicates no selection.   
      :type `value`: string
      :param `pos`: Window position. If :ref:`wx.DefaultPosition`  is specified then a default position is chosen.   
      :type `pos`: wx.Point
      :param `size`: Window size. If :ref:`wx.DefaultSize`  is specified then the window is sized appropriately.   
      :type `size`: wx.Size
      :param `style`: Window style. See :ref:`wx.ComboCtrl`.   
      :type `style`: long
      :param `validator`: Window validator.   
      :type `validator`: wx.Validator
      :param `name`: Window name.  
      :type `name`: string
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
                        
      
      
      
      .. seealso:: :meth:`Create` , :ref:`wx.Validator`    
      
      
      
      
      
      
      
      :html:`<hr class="overloadsep" /><br />`






   .. method:: AnimateShow(self, rect, flags)

      This member function is not normally called in application code.                  

      Instead, it can be implemented in a derived class to create a custom popup animation. 

      The parameters are the same as those for :meth:`DoShowPopup` . 

                


      :param `rect`: 
      :type `rect`: wx.Rect
      :param `flags`: 
      :type `flags`: int




      :rtype: `bool`







      :returns: 

         ``True`` if animation finishes before the function returns, ``False`` otherwise. In the latter case you need to manually call :meth:`DoShowPopup`   after the animation ends.   








   .. method:: Copy(self)

      Copies the selected text to the clipboard.                   





   .. method:: Create(self, parent, id=ID_ANY, value=EmptyString, pos=DefaultPosition, size=DefaultSize, style=0, validator=DefaultValidator, name=ComboBoxNameStr)

      Creates the combo control for two-step construction.                  

      Derived classes should call or replace this function. See :ref:`wx.ComboCtrl`  for further details.                  


      :param `parent`: 
      :type `parent`: wx.Window
      :param `id`: 
      :type `id`: wx.WindowID
      :param `value`: 
      :type `value`: string
      :param `pos`: 
      :type `pos`: wx.Point
      :param `size`: 
      :type `size`: wx.Size
      :param `style`: 
      :type `style`: long
      :param `validator`: 
      :type `validator`: wx.Validator
      :param `name`: 
      :type `name`: string




      :rtype: `bool`








   .. method:: Cut(self)

      Copies the selected text to the clipboard and removes the selection.                   





   .. method:: Dismiss(self)

      Dismisses the popup window.                  

      Notice that calling this function will generate a  ``wxEVT_COMBOBOX_CLOSEUP``   event. 

                 



      .. versionadded:: 2.9.2 
     








   .. method:: DoSetPopupControl(self, popup)

      This member function is not normally called in application code.                  

      Instead, it can be implemented in a derived class to return default :ref:`wx.ComboPopup`, in case `popup`  is ``None``. 

                


      :param `popup`: 
      :type `popup`: wx.ComboPopup






      .. note:: 

         If you have implemented :meth:`OnButtonClick`   to do something else than show the popup, then :meth:`DoSetPopupControl`   must always set `popup`  to ``None``.   








   .. method:: DoShowPopup(self, rect, flags)

      This member function is not normally called in application code.                  

      Instead, it must be called in a derived class to make sure popup is properly shown after a popup animation has finished (but only if :meth:`AnimateShow`   did not finish the animation within its function scope). 




      :param `rect`: Position to show the popup window at, in screen coordinates.   
      :type `rect`: wx.Rect
      :param `flags`: Combination of any of the following: :meth:`wx.ComboCtrl.ShowAbove` , and :meth:`wx.ComboCtrl.CanDeferShow` .   
      :type `flags`: int






                  





   .. method:: EnablePopupAnimation(self, enable=True)

      Enables or disables popup animation, if any, depending on the value of the argument.                  


      :param `enable`: 
      :type `enable`: bool







   .. method:: GetBitmapDisabled(self)

      Returns disabled button bitmap that has been set with :meth:`SetButtonBitmaps` .                  

                

      :rtype: :ref:`wx.Bitmap`







      :returns: 

         A reference to the disabled state bitmap.   








   .. method:: GetBitmapHover(self)

      Returns button mouse hover bitmap that has been set with :meth:`SetButtonBitmaps` .                  

                

      :rtype: :ref:`wx.Bitmap`







      :returns: 

         A reference to the mouse hover state bitmap.   








   .. method:: GetBitmapNormal(self)

      Returns default button bitmap that has been set with :meth:`SetButtonBitmaps` .                  

                

      :rtype: :ref:`wx.Bitmap`







      :returns: 

         A reference to the normal state bitmap.   








   .. method:: GetBitmapPressed(self)

      Returns depressed button bitmap that has been set with :meth:`SetButtonBitmaps` .                  

                

      :rtype: :ref:`wx.Bitmap`







      :returns: 

         A reference to the depressed state bitmap.   








   .. method:: GetButtonSize(self)

      Returns current size of the dropdown button.                  

      :rtype: :ref:`wx.Size`








   .. staticmethod:: GetClassDefaultAttributes(variant=WINDOW_VARIANT_NORMAL)




      :param `variant`: 
      :type `variant`: wx.WindowVariant




      :rtype: :ref:`wx.VisualAttributes`








   .. method:: GetCustomPaintWidth(self)

      Returns custom painted area in control.                  

                

      :rtype: `int`







      .. seealso:: :meth:`SetCustomPaintWidth` .   








   .. staticmethod:: GetFeatures()

      Returns features supported by :ref:`wx.ComboCtrl`.                  

      If needed feature is missing, you need to instead use GenericComboCtrl, which however may lack a native look and feel (but otherwise sports identical API). 

                

      :rtype: `int`







      :returns: 

         Value returned is a combination of the flags defined in :ref:`wx.ComboCtrlFeatures`.   








   .. method:: GetHint(self)

      Returns the current hint string.                  

      See :meth:`SetHint`   for more information about hints. 

                

      :rtype: `string`







      .. versionadded:: 2.9.1 
     








   .. method:: GetInsertionPoint(self)

      Returns the insertion point for the combo control's text field.                  

                

      :rtype: `long`







      .. note:: 

         Under Windows, this function always returns 0 if the combo control doesn't have the focus.   








   .. method:: GetLastPosition(self)

      Returns the last position in the combo control text field.                  

      :rtype: `long`








   .. method:: GetMargins(self)

      Returns the margins used by the control.                  

      The  ``x``   field of the returned point is the horizontal margin and the   ``y``   field is the vertical one. 

                

      :rtype: :ref:`wx.Point`







      .. versionadded:: 2.9.1 
     







      .. note:: 

         If given margin cannot be accurately determined, its value will be set to -1.  







      .. seealso:: :meth:`SetMargins`   








   .. method:: GetPopupControl(self)

      Returns current popup interface that has been set with :meth:`SetPopupControl` .                  

      :rtype: :ref:`wx.ComboPopup`








   .. method:: GetPopupWindow(self)

      Returns popup window containing the popup control.                  

      :rtype: :ref:`wx.Window`








   .. method:: GetTextCtrl(self)

      Get the text control which is part of the combo control.                  

      :rtype: :ref:`wx.TextCtrl`








   .. method:: GetTextRect(self)

      Returns area covered by the text field (includes everything except borders and the dropdown button).                  

      :rtype: :ref:`wx.Rect`








   .. method:: GetValue(self)

      Returns text representation of the current value.                  

      For writable combo control it always returns the value in the text field.                  

      :rtype: `string`








   .. method:: HidePopup(self, generateEvent=False)

      Dismisses the popup window.                  




      :param `generateEvent`: Set this to ``True`` in order to generate  ``wxEVT_COMBOBOX_CLOSEUP``   event.  
      :type `generateEvent`: bool




                  



      .. wxdeprecated:: 
         Use :meth:`Dismiss`   instead.    








   .. method:: IsKeyPopupToggle(self, event)

      Returns ``True`` if given key combination should toggle the popup.                  


      :param `event`: 
      :type `event`: wx.KeyEvent




      :rtype: `bool`








   .. method:: IsPopupShown(self)

      Returns ``True`` if the popup is currently shown.                  

      :rtype: `bool`








   .. method:: IsPopupWindowState(self, state)

      Returns ``True`` if the popup window is in the given state.                  

      Possible values are: 



      ======================== ============================================================================= 
      `ComboCtrl.Hidden`       Popup window is hidden.                                                       
      `ComboCtrl.Animating`    Popup window is being shown, but the popup animation has not yet finished.    
      `ComboCtrl.Visible`      Popup window is fully visible.                                                
      ======================== ============================================================================= 

      |

                 


      :param `state`: 
      :type `state`: int




      :rtype: `bool`








   .. method:: OnButtonClick(self)

      Implement in a derived class to define what happens on dropdown button click.                  

      Default action is to show the popup. 

                 



      .. note:: 

         If you implement this to do something else than show the popup, you must then also implement :meth:`DoSetPopupControl`   to always return ``None``.   








   .. method:: Paste(self)

      Pastes text from the clipboard to the text field.                   





   .. method:: Popup(self)

      Shows the popup portion of the combo control.                  

      Notice that calling this function will generate a  ``wxEVT_COMBOBOX_DROPDOWN``   event. 

                 



      .. versionadded:: 2.9.2 
     








   .. method:: PrepareBackground(self, dc, rect, flags)

      Prepare background of combo control or an item in a dropdown list in a way typical on platform.                  

      This includes painting the focus/disabled background and setting the clipping region. 

      Unless you plan to paint your own focus indicator, you should always call this in your :meth:`wx.ComboPopup.PaintComboControl`   implementation. In addition, it sets pen and text colour to what looks good and proper against the background. 

      flags: :ref:`wx.RendererNative`  flags: ``wx.CONTROL_ISSUBMENU``: is drawing a list item instead of combo control ``wx.CONTROL_SELECTED``: list item is selected ``wx.CONTROL_DISABLED``: control/item is disabled                  


      :param `dc`: 
      :type `dc`: wx.DC
      :param `rect`: 
      :type `rect`: wx.Rect
      :param `flags`: 
      :type `flags`: int







   .. method:: Remove(self, frm, to)

      Removes the text between the two positions in the combo control text field.                  




      :param `frm`: 
      :type `frm`: long
      :param `to`: The last position.   
      :type `to`: long




      The first position.  



                  





   .. method:: Replace(self, frm, to, text)

      Replaces the text between two positions with the given text, in the combo control text field.                  




      :param `frm`: 
      :type `frm`: long
      :param `to`: The second position.   
      :type `to`: long
      :param `text`: The text to insert.   
      :type `text`: string




      The first position.  





                  





   .. method:: SetButtonBitmaps(self, bmpNormal, pushButtonBg=False, bmpPressed=NullBitmap, bmpHover=NullBitmap, bmpDisabled=NullBitmap)

      Sets custom dropdown button graphics.                  




      :param `bmpNormal`: Default button image.   
      :type `bmpNormal`: wx.Bitmap
      :param `pushButtonBg`: If ``True``, blank push button background is painted below the image.   
      :type `pushButtonBg`: bool
      :param `bmpPressed`: Depressed button image.   
      :type `bmpPressed`: wx.Bitmap
      :param `bmpHover`: Button image when mouse hovers above it. This should be ignored on platforms and themes that do not generally draw different kind of button on mouse hover.   
      :type `bmpHover`: wx.Bitmap
      :param `bmpDisabled`: Disabled button image.   
      :type `bmpDisabled`: wx.Bitmap












                  





   .. method:: SetButtonPosition(self, width=-1, height=-1, side=RIGHT, spacingX=0)

      Sets size and position of dropdown button.                  




      :param `width`: Button width. Value = 0 specifies default.   
      :type `width`: int
      :param `height`: Button height. Value = 0 specifies default.   
      :type `height`: int
      :param `side`: Indicates which side the button will be placed. Value can be ``wx.LEFT`` or ``wx.RIGHT``.   
      :type `side`: int
      :param `spacingX`: Horizontal spacing around the button. Default is 0.   
      :type `spacingX`: int










                  





   .. method:: SetCustomPaintWidth(self, width)

      Set width, in pixels, of custom painted area in control without  ``CB_READONLY``   style.                   

      In read-only :ref:`wx.adv.OwnerDrawnComboBox`, this is used to indicate area that is not covered by the focus rectangle.                  


      :param `width`: 
      :type `width`: int







   .. method:: SetHint(self, hint)

      Sets a hint shown in an empty unfocused combo control.                  

      Notice that hints are known as `cue banners`  under MSW or `placeholder strings`  under macOS. 

                


      :param `hint`: 
      :type `hint`: string




      :rtype: `bool`







      .. versionadded:: 2.9.1 
     







      .. seealso:: :meth:`wx.TextEntry.SetHint`   








   .. method:: SetInsertionPoint(self, pos)

      Sets the insertion point in the text field.                  




      :param `pos`: The new insertion point.   
      :type `pos`: long




                  





   .. method:: SetInsertionPointEnd(self)

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





   .. method:: SetMargins(self, *args, **kw)

      Attempts to set the control margins.                  

      When margins are given as :ref:`wx.Point`, x indicates the left and y the top margin. Use -1 to indicate that an existing value should be used. 

                 



      :returns: 

         ``True`` if setting of all requested margins was successful.  







      .. versionadded:: 2.9.1 
     





      |overload| Overloaded Implementations:

      :html:`<hr class="overloadsep" /><br />`

      
      **SetMargins** `(self, pt)`
      
      
      
      
      :param `pt`: 
      :type `pt`: wx.Point
      
      
      
      
      :rtype: `bool`
      
      
      
      
      
      
      
      :html:`<hr class="overloadsep" /><br />`

      
      **SetMargins** `(self, left, top=-1)`
      
      
      
      
      :param `left`: 
      :type `left`: int
      :param `top`: 
      :type `top`: int
      
      
      
      
      :rtype: `bool`
      
      
      
      
      
      
      
      :html:`<hr class="overloadsep" /><br />`






   .. method:: SetPopupAnchor(self, anchorSide)

      Set side of the control to which the popup will align itself.                  

      Valid values are  ``LEFT`` ,   ``RIGHT``   and 0. The default value 0 means that the most appropriate side is used (which, currently, is always   ``LEFT`` ).                   


      :param `anchorSide`: 
      :type `anchorSide`: int







   .. method:: SetPopupControl(self, popup)

      Set popup interface class derived from :ref:`wx.ComboPopup`.                  

      This method should be called as soon as possible after the control has been created, unless :meth:`OnButtonClick`   has been overridden.                  


      :param `popup`: 
      :type `popup`: wx.ComboPopup







   .. method:: SetPopupExtents(self, extLeft, extRight)

      Extends popup size horizontally, relative to the edges of the combo control.                  




      :param `extLeft`: How many pixel to extend beyond the left edge of the control. Default is 0.   
      :type `extLeft`: int
      :param `extRight`: How many pixel to extend beyond the right edge of the control. Default is 0.  
      :type `extRight`: int






                  



      .. note:: 

         Popup minimum width may override arguments. It is up to the popup to fully take this into account.   








   .. method:: SetPopupMaxHeight(self, height)

      Sets preferred maximum height of the popup.                  

                


      :param `height`: 
      :type `height`: int






      .. note:: 

         Value -1 indicates the default.   








   .. method:: SetPopupMinWidth(self, width)

      Sets minimum width of the popup.                  

      If wider than combo control, it will extend to the left. 

                


      :param `width`: 
      :type `width`: int






      .. note:: 

         Value -1 indicates the default. Also, popup implementation may choose to ignore this.   








   .. method:: SetSelection(self, frm, to)

      Selects the text between the two positions, in the combo control text field.                  




      :param `frm`: 
      :type `frm`: long
      :param `to`: The second position.   
      :type `to`: long




      The first position.  



                  





   .. method:: SetText(self, value)

      Sets the text for the text field without affecting the popup.                  

      Thus, unlike :meth:`SetValue` , it works equally well with combo control using  ``CB_READONLY``   style.                   


      :param `value`: 
      :type `value`: string







   .. method:: SetTextCtrlStyle(self, style)

      Set a custom window style for the embedded :ref:`wx.TextCtrl`.                  

      Usually you will need to use this during two-step creation, just before :meth:`Create` . For example: 

      ::

                      comboCtrl = wx.ComboCtrl()

                      # Let's make the text right-aligned
                      comboCtrl.SetTextCtrlStyle(wx.TE_RIGHT)

                      comboCtrl.Create(parent, wx.ID_ANY, "")

                 


      :param `style`: 
      :type `style`: int







   .. method:: SetValue(self, value)

      Sets the text for the combo control text field.                  

                


      :param `value`: 
      :type `value`: string






      .. note:: 

         For a combo control with  ``CB_READONLY``   style the string must be accepted by the popup (for instance, exist in the dropdown list), otherwise the call to  :meth:`SetValue`   is ignored.   








   .. method:: SetValueByUser(self, value)

      Changes value of the control as if user had done it by selecting an item from a combo box drop-down list.                  


      :param `value`: 
      :type `value`: string







   .. method:: ShouldDrawFocus(self)

      Returns ``True`` if focus indicator should be drawn in the control.                  

      :rtype: `bool`








   .. method:: ShowPopup(self)

      Show the popup.                  

                 



      .. wxdeprecated:: 
         Use :meth:`Popup`   instead.    








   .. method:: Undo(self)

      Undoes the last edit in the text field.                  

      Windows only.                   





   .. method:: UseAltPopupWindow(self, enable=True)

      Enable or disable usage of an alternative popup window, which guarantees ability to focus the popup control, and allows common native controls to function normally.                  

      This alternative popup window is usually a :ref:`wx.Dialog`, and as such, when it is shown, its parent top-level window will appear as if the focus has been lost from it.                  


      :param `enable`: 
      :type `enable`: bool







   .. attribute:: BitmapDisabled

      See :meth:`~wx.ComboCtrl.GetBitmapDisabled`


   .. attribute:: BitmapHover

      See :meth:`~wx.ComboCtrl.GetBitmapHover`


   .. attribute:: BitmapNormal

      See :meth:`~wx.ComboCtrl.GetBitmapNormal`


   .. attribute:: BitmapPressed

      See :meth:`~wx.ComboCtrl.GetBitmapPressed`


   .. attribute:: ButtonSize

      See :meth:`~wx.ComboCtrl.GetButtonSize`


   .. attribute:: CustomPaintWidth

      See :meth:`~wx.ComboCtrl.GetCustomPaintWidth` and :meth:`~wx.ComboCtrl.SetCustomPaintWidth`


   .. attribute:: Hint

      See :meth:`~wx.ComboCtrl.GetHint` and :meth:`~wx.ComboCtrl.SetHint`


   .. attribute:: InsertionPoint

      See :meth:`~wx.ComboCtrl.GetInsertionPoint` and :meth:`~wx.ComboCtrl.SetInsertionPoint`


   .. attribute:: LastPosition

      See :meth:`~wx.ComboCtrl.GetLastPosition`


   .. attribute:: Margins

      See :meth:`~wx.ComboCtrl.GetMargins` and :meth:`~wx.ComboCtrl.SetMargins`


   .. attribute:: PopupControl

      See :meth:`~wx.ComboCtrl.GetPopupControl` and :meth:`~wx.ComboCtrl.SetPopupControl`


   .. attribute:: PopupWindow

      See :meth:`~wx.ComboCtrl.GetPopupWindow`


   .. attribute:: TextCtrl

      See :meth:`~wx.ComboCtrl.GetTextCtrl`


   .. attribute:: TextRect

      See :meth:`~wx.ComboCtrl.GetTextRect`


   .. attribute:: Value

      See :meth:`~wx.ComboCtrl.GetValue` and :meth:`~wx.ComboCtrl.SetValue`

