In this wxPython tutorial let us create a daily combo box beside the hello world button. I will not be going to repeat the previous program again thus if you want to look at the entire program you can refer to it in my previous wxPython article.
The official page of the wxPython Combo Box widget has the below parameters but I am not going to use all of them.
Parameters parent (wx.Window) – Parent window. Must not be None. id (wx.WindowID) – Window identifier. The value wx.ID_ANY indicates a default value. value (string) – Initial selection string. An empty string indicates no selection. pos (wx.Point) – Window position. size (wx.Size) – Window size. If DefaultSize is specified then the window is sized appropriately. choices (list of strings) – An array of strings with which to initialize the control. style (long) – Window style. See wx.ComboBox. validator (wx.Validator) – Window validator. name (string) – Window name.
Here are the lines of python code (including function) to create the Combo Box widget:-
def CreateComboBox(self): # create combo box daily = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"] self.combo1 = wx.ComboBox(parent=self.the_frame, id=3, value="", pos=wx.Point(30, 150), size=wx.Size(width=100, height=100), choices=daily, style=0, name="week day")
You can then call the CreateWidgets function to create the daily combo box likes before.