All:
When I run this script, the choice control does not respond visually to button clicks, which is what I want, but the combo box does. You can select items on the combo box, while the choice is completely inert. Is there another event I need to capture or turn off for the combo box in order to make it inert?
Craig
from wxPython.wx import *
class panel(wxPanel):
def __init__(self, parent):
wxPanel.__init__(self, parent, -1)
ItemList = 'item1', 'item2', 'item3'
b1 = wxComboBox(self, 20, ItemList[1], (10, 10), (90, 40), ItemList, wxCB_SIMPLE)
b2 = wxChoice(self, 20, (10, 110), (90, 40), ItemList)
self.Disconnect(-1, -1, wxEVT_COMMAND_COMBOBOX_SELECTED)
self.Disconnect(-1, -1, wxEVT_COMMAND_CHOICE_SELECTED)
self.Disconnect(-1, -1, wxEVT_COMMAND_TEXT_UPDATED)
self.Disconnect(-1, -1, wxEVT_COMMAND_TEXT_ENTER)
b1.Connect(-1, -1, wxEVT_LEFT_DOWN, self.OnRunEvent)
b2.Connect(-1, -1, wxEVT_LEFT_DOWN, self.OnRunEvent)
b1.Connect(-1, -1, wxEVT_LEFT_DCLICK, self.OnRunEvent)
b2.Connect(-1, -1, wxEVT_LEFT_DCLICK, self.OnRunEvent)
def OnRunEvent(self, event):
type = event.GetEventType()
if type == wxEVT_COMMAND_COMBOBOX_SELECTED:
print 'wxEVT_COMMAND_COMBOBOX_SELECTED'
elif type == wxEVT_COMMAND_CHOICE_SELECTED:
print 'wxEVT_COMMAND_CHOICE_SELECTED'
elif type == wxEVT_COMMAND_TEXT_UPDATED:
print 'wxEVT_COMMAND_TEXT_UPDATED'
elif type == wxEVT_COMMAND_TEXT_ENTER:
print 'wxEVT_COMMAND_TEXT_ENTER'
elif type == wxEVT_LEFT_DOWN:
print 'wxEVT_LEFT_DOWN'
elif type == wxEVT_LEFT_DCLICK:
print 'wxEVT_LEFT_DCLICK'
else:
print 'cannot find event type'
app = wxPySimpleApp()
f = wxFrame(None, -1,'ComboBox Test', (200, 200), (350, 200))
p = panel(f)
f.Show()
app.MainLoop()