[wxPython-users] wx.ComboBox SetSelection on ClientData
Raffaello Barella
barbarossa.platz at gmail.com
Sun Dec 30 06:55:26 PST 2007
Surely your idea of using a dictionary is more elegant, and since you have
made up a numeric dict the additional memory cost is trivial. Beyond the
inquiry is made in C++, not Python, so much faster: and the combo content
might become very long. Thank you for your suggestion.
2007/12/30, Giuseppe Costanzi <g.costanzi at idi.it>:
>
> Ciao Raffaello, you have suggest me to use a dictionary.
> On combo data load function I make
>
> for j in range(self.cbCategory.GetCount()):
> a=3Dself.cbCategory.GetClientData(j)
> print j,a
> x=3Dint(a[0])
> dct_Categories[x]=3Dj
>
> print j,a return
>
> 0 (2, 'AGGLUTINATION')
> 1 (27, 'ELISA')
> 2 (52, 'VARIOUS')
> 3 (53, 'VIDAS')
> 4 (59, 'TO ASSIGN')
>
> now the dictionary (dct_Categories) will be
>
> {59: 4, 2: 0, 27: 1, 52: 2, 53: 3}
>
> So I populate the dictionary,notice that I've use for the key the
> dataclient value(x) instead
> of the combo index...
> than to point on ClientData for example i can do
> CategoriesID =3D 53
> it means that
> dct_Categories[CategoriesID] return 3, so
> self.cbCategory.SetSelection(dct_Categories[CategoriesID])
> that finally selects on combo the item with index=3D3
> It work but there is a more elegant mode to do this?
>
> Thanks Raffaello
>
> buon anno anche a te!
>
> Giuseppe
> Python-it.org <http://Python-it.org>
>
>
> Raffaello Barella ha scritto:
> > Scrolling the whole content of ClientData could do:
> >
> > for j in range(wxCB.GetCount()):
> > if wxCB.GetClientData(j) =3D=3D x:
> > wxCB.SetSelection(j)
> > break
> >
> > Buon anno
> >
> > 2007/12/29, Giuseppe Costanzi <g.costanzi at email.it
> > <mailto:g.costanzi at email.it>>:
> >
> > There is a way to point to an item of a wx.ComboBox using
> SetSelection
> > method on ClientData insted of index?
> >
> > Giuseppe
> > Python-it.org <http://Python-it.org>
> >
> >
> ---------------------------------------------------------------------
> > To unsubscribe, e-mail:
> > wxPython-users-unsubscribe at lists.wxwidgets.org
> > <mailto:wxPython-users-unsubscribe at lists.wxwidgets.org>
> > For additional commands, e-mail:
> > wxPython-users-help at lists.wxwidgets.org
> > <mailto:wxPython-users-help at lists.wxwidgets.org>
> >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: wxPython-users-unsubscribe at lists.wxwidgets.org
> For additional commands, e-mail: wxPython-users-help at lists.wxwidgets.org
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.wxwidgets.org/pipermail/wxpython-users/attachments/200712=
30/9a0e8664/attachment.htm
More information about the wxpython-users
mailing list