I am not quite sure what you are trying to accomplish, but I agree
that you don't need the EVT_COMBOBOX. Does the following code do
enough of what you want to get you started? Sorry about all the
sizer stuff, but it was the easiest way to lay out the components.
You can ignore it if you wish.
#!/usr/bin/env python
from wxPython.wx import *
class MyPanel(wxPanel):
def __init__(self, parent):
# create panel
wxPanel.__init__(self, parent, id=-1)
# create the controls
text1 = wxStaticText(self, -1, 'First pick command:')
self.combo1 = wxComboBox(self, -1, choices = ,
style=wxCB_READONLY)
self.combo1.Append("AaCommand","Aa")
self.combo1.Append("AbCommand","Ab")
self.combo1.Append("BaCommand","Ba")
self.combo1.Append("BbCommand","Bb")
self.combo1.Append("CcCommand","Cc")
self.combo1.SetSelection(0)
self.button1 = wxButton(self, -1, 'then do it')
EVT_BUTTON(self, self.button1.GetId(), self.onStatDisp)
# create the sizers
sizer1 = wxBoxSizer(wxVERTICAL)
sizer2 = wxBoxSizer(wxHORIZONTAL)
# add controls to sizers
sizer2.Add(text1, 1, wxEXPAND)
sizer2.Add(self.combo1, 1, wxEXPAND)
sizer1.Add(sizer2, 0, wxEXPAND|wxALL, border=10)
sizer1.Add(self.button1, 1, wxEXPAND|wxALL, border=10)
# enable sizers
self.SetSizer(sizer1)
self.SetAutoLayout(1)
sizer1.Fit(self)
sizer1.SetSizeHints(self)
def onStatDisp(self,event):
print self.combo1.GetValue()
sel = self.combo1.GetSelection()
print self.combo1.GetString(sel)
print self.combo1.GetClientData(sel)
class MyFrame(wxFrame):
def __init__(self):
wxFrame.__init__(self, None, -1, 'Demo')
panel1 = MyPanel(self)
sizer = wxBoxSizer()
sizer.Add(panel1, 1, wxEXPAND)
self.SetSizer(sizer)
self.SetAutoLayout(1)
sizer.Fit(self)
sizer.SetSizeHints(self)
class MyApp(wxApp):
def OnInit(self):
frame = MyFrame()
frame.Show(1)
return 1
app = MyApp(0)
app.MainLoop()
···
--- David <decibel8@charter.net> wrote:
This works for the combobox working on. But then noticed that
one of the other comboboxes value is changing also.
Looks like it is the 's=event.GetString' cause everything else
is using the combobox's ID. Nothing else I seem to do works
though. Out of ideas for now.
EVT_COMBOBOX(self,ID_ComboStats,self.onComboPick)
EVT_BUTTON(self,ID_StatDisp_button,self.onStatDisp)
def onComboPick(self,event):
s = event.GetString()
cmd = self.frame.combo_box_7.SetValue(s)
return
def onStatDisp(self,event): #new keep
cmd = self.frame.combo_box_7.GetValue()
.....
-> Works, but changes another comboboxes string, even if isn't
in the list. Not the other way around though since haven't setup
code for the other combobox yet.
=====
Donnal Walter
Arkansas Children's Hospital