Hi Robin,
thanks for your answer.
1) Regarding CustomRenderer.py:
I’m on linux (ubuntu 12.10) and Python 2.7. After launching the sample program, if you edit and change one of the cells, the exception is triggered when you end the edition. I groped for a solution, and found out that the return value from GetValueFromEditorCtrl could be changed as follows to remove the exception:
class MyCustomRenderer(dv.DataViewCustomRenderer):
…
def GetValueFromEditorControl(self, editor):
...
**return True, value**
(instead of return value). In the C++ code, this function returns a bool (probably a validate/cancel flag?), and the value of the editor control is returned through a parameter passed by reference. Does the solution above make sense?
Also, I get an exception at the beginning of the execution when launching CustomRenderer.py;
NotImplementedError: DataViewIndexListModel.GetColumnType() is abstract and must be overriden
I added to IndexListModel.py the following:
class TestModel(dv.DataViewIndexListModel):
…
def GetColumnType(self, col):
** return “string”**
…
which removed the exception.
2) Regarding the ComboBox as edit control in dataview:
I’ll have a closer look at EditableListBox, but for the time being, the dataview solution, together with a custom renderer seems to better fit my needs (I need multiple columns, and if I can make it work, I will re-use it elsewhere in my app in order to simplify the GUI).
Based on the sample code in CustomRenderer.py (with the corrections above), I tried to use a ComboBox in place of the TextCtrl, but this does not work for now. The control is not properly drawn, the drop down is not displayed correctly, and the focus is not handled correctly (it seems), when you click outside of the drop down control. I’ll do some more experiments to see if I can make it work (though the display does not work properly, keyboard events are handled correctly, and I can change values with up/down arrows and validate with enter).
Can you point me to some direction? Maybe use a ComboCtrl, in order to get more control on the drawing/focus? or maybe look at the similar functionality for grid?
I also noticed that there is a wxDataViewChoiceRenderer in wxWidgets. Is it not present in Phoenix for a good reason, or is it on some Todo List? (I do not know sip at all, but I can try to explore this route, though it probably is a bit difficult for me…)
Thanks for your help.
Vincent
···
On Wednesday, May 15, 2013 7:53:54 PM UTC+2, Robin Dunn wrote:
nolfac_dev wrote:
Hi All,
I need to build a GUI in python, using wx.
Is there a reasonable -I mean, reasonably straightforward- way to have
an editable list-like widget where the editing control would be a combo
box? A ChoiceCtrl could also work for me.
Not out of the box, but EditableListBox is generic code so it probably
would not be too hard to port it to Python and then make it possible to
use different types of widgets for the edit control.
The CustomRenderer.py sample from the source distribution (version
wxPython_Phoenix-2.9.5.81-r73904) does not seem to be working: I get a
"TypeError: invalid result type from
MyCustomRenderer.GetValueFromEditorCtrl() … Unexpected type (“null”)
in wxVariant." when running it.
Which platform? Do you have to do anything to trigger the exception?
–
Robin Dunn
Software Craftsman
http://wxPython.org