[wxpython-users] wxListBox and non-selectable item
Raffaello Barella
barbarossa.platz at gmail.com
Mon Mar 24 13:23:07 PDT 2008
wx.ListBox does not allow different fonts for different items, and I don't
know enough of wx.ListBox to advise you. My crude solution, with wx,ListBox,
would be to add to the wx.ListBox a tooltip (see wx.ToolTip) saying "The
item x cannot be selected". Bye
2008/3/24, Martin Landa <landa.martin at gmail.com>:
>
> Hi,
>
> thanks, works like a charm. I forgot to mention that I would like to
> visually separate selectable and non-selectable items, e.g. grey
> coloured font for non-selectable items. I wonder if wx.ListBox enables
> that, or do I need wx.ListCtrl instead?
>
> Thanks, Martin
>
> 2008/3/24, Raffaello Barella <barbarossa.platz at gmail.com>:
>
> > Possible. You declare at the beginning of the frame class a general
> > variable:
> > FormerSelection =3D wx.NOT_FOUND
> >
> > Intercept in __init__ the event wx.EVT_LISTBOX with the code:
> > myListBox.Bind(wx.EVT_LISTBOX, self OnEVT_LISTBOX)
> >
> > Then you add:
> >
> > def OnEVT_LISTBOX(self, event):
> > if event.GetSelection() =3D=3D non-selectable: # the int ind=
ex of
> the
> > forbidden item
> > myListBox.SetSelection(self.FormerSelection)
> > else:
> > self.FormerSelection =3D event.GetSelection()
> > event.Skip()
> >
> >
> >
> >
> > 2008/3/24, Martin Landa <landa.martin at gmail.com>:
> > >
> > > Hi all,
> > >
> > > sorry for a newbie question, is there a way how to make item in
> > > wxListBox non-selectable, to disable an item? I checked
> > > SetItemState(), but I haven't found how this could be implemented.
> > >
> > > Thanks in advance! Martin
> > >
> > >
> > > --
> > > Martin Landa <landa.martin gmail.com> * http://gama.fsv.cvut.cz/~land=
a*
> > > _______________________________________________
> > > wxpython-users mailing list
> > > wxpython-users at lists.wxwidgets.org
> > >
> > http://lists.wxwidgets.org/mailman/listinfo/wxpython-users
> > >
> >
> >
> > _______________________________________________
> > wxpython-users mailing list
> > wxpython-users at lists.wxwidgets.org
> > http://lists.wxwidgets.org/mailman/listinfo/wxpython-users
> >
> >
>
>
>
> --
>
> Martin Landa <landa.martin gmail.com> * http://gama.fsv.cvut.cz/~landa *
> _______________________________________________
> wxpython-users mailing list
> wxpython-users at lists.wxwidgets.org
> http://lists.wxwidgets.org/mailman/listinfo/wxpython-users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.wxwidgets.org/pipermail/wxpython-users/attachments/200803=
24/d3b89a52/attachment-0001.htm
More information about the wxpython-users
mailing list