So you want to test drive some wxPython widgets without all that OOP stuff, here are some examples how to do this:
# test a wxPython combobox selection
import wx
def combo_select(event):
color = combo.GetValue()
frame.SetTitle(color)
app = wx.App(0)
frame = wx.Frame(None, -1, "wx.ComboBox", size=(220, 40))
# set up the choices for the listbox part of the combobox
choice_list = ['red', 'green', 'blue', 'yellow','white', 'magenta']
# create a combobox widget
combo = wx.ComboBox( frame, -1, choices=choice_list)
# set initial value
combo.SetValue('red')
# click on a dropdown choice to select it
combo.Bind(wx.EVT_COMBOBOX, combo_select)
frame.Center()
frame.Show()
app.MainLoop()
One more for the Gipper:
# test wxPython checkbox selections
import wx
def on_action(event):
s = ""
if cb1.IsChecked():
s += "cb1 (red) is checked "
if cb2.IsChecked():
s += "cb2 (blue) is checked "
if not cb1.IsChecked() and not cb2.IsChecked():
s = "none is checked"
frame.SetTitle(s)
app = wx.App(0)
frame = wx.Frame(None, -1, "wx.CheckBox", size=(450, 79))
cb1 = wx.CheckBox(frame, -1, 'red', pos=(10, 10))
cb2 = wx.CheckBox(frame, -1, 'blue', pos=(10, 40))
# set checkbox cb1 to checked
cb1.SetValue(True)
# bind checkbox mouse click to an action
cb1.Bind(wx.EVT_CHECKBOX, on_action)
cb2.Bind(wx.EVT_CHECKBOX, on_action)
# initial call
on_action(None)
frame.Center()
frame.Show()
app.MainLoop()