[wxPython-users] GridCellChoiceEditor
Mark Erbaugh
mark at microenh.com
Tue Feb 5 22:36:29 PST 2008
On Tue, 2008-02-05 at 14:55 -0800, Robin Dunn wrote:
> Mark Erbaugh wrote:
> > Is is possible to change the values in the drop down list of a
> > GridCellChoiceEditor on the fly?
> >
> > I have two columns in a grid. In the first column, the user selects the
> > category (via a GridCellChoiceEditor), in the second column, they need
> > to select an item within the selected category.
> >
> > I tried using the Editor's SetParameters method in the select cell event
> > handler when the user selects the items column with interesting
> > results. It seems like only the SetParameters calls made the first time
> > the event handler is called are effective. The C++ code shows that
> > SetParameters calls reset the parameters to the new values. In fact, if
> > I call SetParameters twice in the event handler, the values in the drop
> > down list are from the last call.
> >
> > However, SetParameters calls in subsequent calls the the event handler
> > (which I verified are being invoked with print statements) are not
> > showing up in the drop down list.
> >
> > My guess is that the actual control is created before the first time it
> > drops down, using the values from the most recent SetParameters call.
> > Once the control is created, changes to SetParameters don't refresh the
> > values in the control.
>
> The control is created the first time the editor is activated, but after
> that it will be kept around and just hidden until it is needed again.
> IIRC you can destroy the control when the editor is hidden and then the
> next time the editor is activated it will create it again, and so it
> should then use the new parameters you have set. OTOH, once you've got
> a reference to the actual widget then you can change the values yourself.
How would you get a reference to the actual widget? It looks like it is
created in the C++ code (m_control), but it doesn't seem to be available
in Python. I've worked out some convoluted code using the OnEditorShown
and OnEditorCreated events, but that seems awkward.
More information about the wxpython-users
mailing list