[wxPython-users] Dynamically updating GridCellChoiceEditor combo-box contents?

Raffaello Barella barbarossa.platz at gmail.com
Tue Mar 11 07:54:07 PDT 2008


Try to make your own GridCellChoiceEditor (look at chapter 14th in "
wxPython in Action" by Noel Rappin and Robin Dunn, or at my attached code if
you do not know how). Create as a variable of the editor  the choice-list of
the inner wx.Choice, and then a method as follows:
    def  MakeChoiceList(self, choicelist =3D []):
        self.choice_list =3D choicelist


2008/3/11, Tim van der Leeuw <tnleeuw at gmail.com>:
>
> Hi,
>
> I have a grid containing some data. In one of the columns, the data is
> selected from a predefined list using a GridCellChoiceEditor.
>
> However, I want to be able to dynamically add items to, and remove items
> from, this choice-list, and I'm not finding a reliable way to do so.
>
> The GridCellChoiceEditor has a Control, wich is a wx.Choice control. I can
> manipulate the contents of that control to my hearts content and the list
> with choices is updated. Great.
>
> However, there are a couple of caveats:
> 1. The Control is not created before the user first invokes the
> cell-editor. So before the user does that, I can not add or remove items.
> 2. Sometimes, the GridCellChoiceEditor itself is already deleted while I'm
> trying to add/remove items! I don't know how/when that can happen. (Shoul=
d I
> manually increase/decrease the ref-count to it in my program, to let WX k=
now
> that I'm keeping a reference to it?)
> 3. There's a method SetControl() on the GridCellChoiceEditor, but invoking
> the editor after using this method with a manually-created wx.Choicecontr=
ol just crashes the program, hard.
> 4. There's a method Create() on the GridCellChoiceEditor which creates the
> Control, but it needs an EvtHandler instance, and I don't know where to g=
et
> the proper one. I've tried a couple of things more-or-less at random, but=
 it
> just leads to crashes.
> 5. I could perhaps create a new GridCellChoiceEditor and call
> grid.SetCellEditor() again for the cells involved, but I tried that, it
> crashed too.
>
>
> Does anyone have any helpful clues for me?
>
> Regards,
>
> --Tim
>
>
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.wxwidgets.org/pipermail/wxpython-users/attachments/200803=
11/83316e70/attachment.htm


More information about the wxpython-users mailing list