Hi,
I needed a wxChoice (or wxComboBox) multicolumn, but i realized that
wxPython doesn't have it.
So I decide to make a more simple control that help me to show to
the user a description of the code that it selects from a wxChoice.
Now that I have a wxDialog with many controls in it and some of them
are instances of my custom control, all the controls works and receive
the focus with the mouse.
My problem is that I don't understand why my custom controls doesn't
receive the focus with the tab key.
Here I've included a very little demostration for the problem.
my system: win2000, python 2.2.1, wxPython 2.3.2.
Sorry for my bad english.
Thanks.
Gabriele.
from wxPython.wx import *
class ChoiceDesc(wxWindow):
def __init__(self, parent, listChoices, select=None, id=-1):
wxWindow.__init__(self, parent, -1)
self.choices=listChoices
self.keys=map(lambda x: x[0], listChoices)
self.C=wxChoice(self, -1, choices=self.keys)
if select==None or select not in self.keys:
select=self.keys[0]
self.C.SetStringSelection(select)
self.T=wxStaticText(self, -1, self.goto(select))
EVT_CHOICE(self, self.C.GetId(), self.evt_select)
s=wxBoxSizer(wxHORIZONTAL)
s.Add(self.C); s.Add(self.T)
s.Layout()
self.SetSizer(s)
s.Fit(self)
self.SetAutoLayout(true)
def evt_select(self, event):
element=event.GetString()
self.T.SetLabel(self.goto(element))
def goto(self, element):
i=self.keys.index(element)
return self.choices[i][1]
a=wxPySimpleApp()
d=wxDialog(None, -1, title="test",
style=wxDEFAULT_DIALOG_STYLE|wxDIALOG_NO_PARENT)
t1=wxTextCtrl(d, -1); t2=wxTextCtrl(d, -1)
t3=ChoiceDesc(d, (('1', 'one'), ('2', 'two')))
t1.SetFocus()
s=wxBoxSizer(wxVERTICAL)
s.Add(t1); s.Add(t2); s.Add(t3)
d.SetSizer(s)
s.Fit(d)
d.Layout()
d.SetAutoLayout(true)
d.ShowModal()
d.Destroy()
a.MainLoop()