= How to create a combo box (Phoenix) =
'''Keywords :''' Combo box.

<<TableOfContents>>

--------
= Introduction : =
{{{wx.ComboBox}}} is a combination of a single line text field, a button with a down arrow image and a listbox.

When you press the button, a listbox appears.

User can select only one option from the supplied string list.

{{{wx.ComboBox}}} has the following constructor :

{{{
wx.ComboBox(int id, string value='', wx.Point pos=wx.DefaultPosition, wx.Size size=wx.DefaultSize,
            wx.List choices=wx.EmptyList, int style=0, wx.Validator validator=wx.DefaultValidator,
            string name=wx.ComboBoxNameStr)
}}}

'''{{{wx.ComboBox styles :}}}'''

 * wx.CB_DROPDOWN
 * wx.CB_READONLY
 * wx.CB_SORT

||||<style="text-align:center;">'''{{{wx.ComboBox methods}}}''' ||
||<#d0d0d0>{{{string GetValue()}}} ||<#d0d0d0>return the current value ||
||{{{SetValue(string value)}}} ||set the value into the textfield of the combobox ||
||<#d0d0d0>{{{Copy()}}} ||<#d0d0d0>copy the selected value to the clipboard ||
||{{{Cut()}}} ||cut the selected value to the clipboard ||
||<#d0d0d0>{{{Paste()}}} ||<#d0d0d0>paste text from the clipboard to the combobox's text field ||
||{{{SetInsertionPoint(int pos)}}} ||set the insertion point in the combobox's text field ||
||<#d0d0d0>{{{int GetInsertionPoint()}}} ||<#d0d0d0>get the insertion point for the combobox's text field ||
||{{{int GetLastPosition()}}} ||return the last position in the combobox's text field ||
||<#d0d0d0>{{{Replace(int from, int to, string value)}}} ||<#d0d0d0>replace the text between from and to positions in the combobox's text field ||
||{{{SetSelection(int n)}}} ||select the item at position n ||
||<#d0d0d0>{{{SetMark(int from, int to)}}} ||<#d0d0d0>select the text between from and to positions in the combobox's text field ||
||{{{(int from, int to) GetMark()}}} ||return the from and to positions of the selected text in the combobox's text field ||
||<#d0d0d0>{{{int GetCurrentSelection()}}} ||<#d0d0d0>return the current selection ||
||{{{bool SetStringSelection(string string)}}} ||select the item with the specified string ||
||<#d0d0d0>{{{int SetString(int n, string string)}}} ||<#d0d0d0>set the label for the item at position n ||
||{{{bool SetEditable(bool editable)}}} ||toggle readonly flag for the combobox's text field ||
||<#d0d0d0>{{{int SetInsertionPointEnd()}}} ||<#d0d0d0>set the insertion point at the end of the combobox's text field. ||
||{{{Remove(int from, int to)}}} ||remove the text between the two positions in the combobox's text field ||
||<#d0d0d0>{{{bool IsEditable()}}} ||<#d0d0d0>return true if the combobox is editable ||
||{{{SelectAll(int from, int to)}}} ||select all the text in the combo's text field ||


(info by '''Jan Bodnar / Zetcode''').

--------
= Demonstrating : =
__'''''Tested''' py3.x, wx4.x and Win10. ''__

Are you ready to use some samples ? ;)

Test, modify, correct, complete, improve and share your discoveries ! (!)

--------
== Sample one ==
{{attachment:img_sample_one.png}}

{{{#!python
# sample_one.py

"""

Author : Jan Bodnar
Website : zetcode.com

"""

import wx
import random

# class MyDialog
# class MyApp

#---------------------------------------------------------------------------

class MyDialog(wx.Dialog):
    def __init__(self, parent, id, title):
        wx.Dialog.__init__(self, parent, id, title, size=(260, 300))

        self.SetIcon(wx.Icon('./icons/icon_wxWidgets.ico', wx.BITMAP_TYPE_ICO))

        #------------

        panel = wx.Panel(self, -1, (75, 20), (100, 127),  style=wx.SUNKEN_BORDER)

        self.picture = wx.StaticBitmap(panel)
        panel.SetBackgroundColour(wx.WHITE)

        self.images = ['tolstoy.jpg', 'feuchtwanger.jpg', 'balzac.jpg',
                       'pasternak.jpg', 'galsworthy.jpg', 'wolfe.jpg', 'zweig.jpg']

        authors = ['Leo Tolstoy', 'Lion Feuchtwanger', 'Honore de Balzac',
                   'Boris Pasternak', 'John Galsworthy', 'Tom Wolfe', 'Stefan Zweig' ]

        wx.ComboBox(self, -1, pos=(50, 170), size=(150, -1), choices=authors, style=wx.CB_READONLY)

        wx.Button(self, 1, '&Close', (80, 220))

        #------------

        self.Bind(wx.EVT_BUTTON, self.OnClose, id=1)
        self.Bind(wx.EVT_COMBOBOX, self.OnSelect)

        #------------

        self.Centre()

    #-----------------------------------------------------------------------

    def OnClose(self, event):
        self.Close()


    def OnSelect(self, event):
        item = event.GetSelection()
        self.picture.SetFocus()
        self.picture.SetBitmap(wx.Bitmap('bitmaps/' + self.images[item]))

#---------------------------------------------------------------------------

class MyApp(wx.App):
    def OnInit(self):
        dlg = MyDialog(None, -1, 'wx.ComboBox')
        dlg.ShowModal()
        dlg.Destroy()

        return True

#---------------------------------------------------------------------------

app = MyApp(0)
app.MainLoop()
}}}
--------
= Download source =
[[attachment:source.zip]]

--------
= Additional Information =
'''Link :'''

- - - - -

https://wiki.wxpython.org/TitleIndex

https://docs.wxpython.org/

--------
= Thanks to =
Jan Bodnar (sample_one.py coding), the wxPython community...

--------
= About this page =
Date(d/m/y)     Person (bot)    Comments :

15/12/20 - Ecco (Created page for wxPython Phoenix).

--------
= Comments =
- blah, blah, blah....