On Thursday 03 December 2009 08:38:20 pm Mike wrote:
> Firstly thanks John for pointing me in the right direction
> So far I have managed to get assign a drop down box (ValueMode = 'key')
> as the Editor for a column in my grid and populate it with choices and
> keys from my database
> However I have a number of issues
> 1) The grid column shows the "key" and only changes to a dropdownlist
> when selected. So I tried to assign the same class to the
> CustomRendererClass (and also the base class dabo.ui.dDropdownList) as I
> had used for the Editor class. Both produced an error of the type below
>
> Traceback (most recent call last):
>   File
> "/usr/lib/python2.6/dist-packages/wx-2.8-gtk2-unicode/wx/_core.py", line
> 14614, in <lambda>
>     lambda event: event.callable(*event.args, **event.kw) )
>   File
> "/usr/local/lib/python2.6/dist-packages/Dabo-0.9.2-py2.6.egg/dabo/ui/uiwx/d
>PemMixin.py", line 330, in _afterInitAll self.afterInitAll()
>   File "/tmp/tmpwqAzvM.py", line 145, in afterInitAll
>     acol.CustomRendererClass = keycol
>   File
> "/usr/local/lib/python2.6/dist-packages/Dabo-0.9.2-py2.6.egg/dabo/ui/uiwx/d
>Grid.py", line 906, in _setCustomRendererClass self._updateRenderer()
>   File
> "/usr/local/lib/python2.6/dist-packages/Dabo-0.9.2-py2.6.egg/dabo/ui/uiwx/d
>Grid.py", line 775, in _updateRenderer renderer = rendClass()
> TypeError: __init__() takes at least 2 arguments (1 given)
>
> The dDropdownList produced the same final error but at a different place
> in the code
> I can find no equivalent to makeGridEditor for the renderer
>
> 2) Although the choices and keys used will update the record when used
> in a dropdownlist on the form no update takes place when an item is
> selected from the dropdown in the grid. All fields are marked as
> editable
>
> 3) For some reason adding the CustomEditorClass slows everything in the
> grid down to a snails pace. The form takes about 45 seconds to load and
> changing rows in the grid takes 30 seconds ? Any thoughts.
> Also having run the form several times the whole Classdesigner go slow
> in the area of saving and accessing menus?
>
> 4) < None > values When the key field is empty the cell shows < None >
> trying to select the cell produces the following error
>
> Traceback (most recent call last):
>   File
> "/usr/local/lib/python2.6/dist-packages/Dabo-0.9.2-py2.6.egg/dabo/ui/uiwx/_
>_init__.py", line 1265, in BeginEdit self._control.Value = self.startValue
>   File
> "/usr/local/lib/python2.6/dist-packages/Dabo-0.9.2-py2.6.egg/dabo/ui/uiwx/d
>ControlItemMixin.py", line 380, in _setValue self.KeyValue = value
>   File
> "/usr/local/lib/python2.6/dist-packages/Dabo-0.9.2-py2.6.egg/dabo/ui/uiwx/d
>ControlItemMixin.py", line 239, in _setKeyValue raise ValueError(_("Trying
> to set %s.Value to these invalid
> selections: %s") % (self.Name, invalidSelections))
> ValueError: Trying to set keycol.Value to these invalid selections: [u'<
> None >'
>
> How can these empty values be handled both to set to another value and
> to set to empty . It appears as if the dropdownlist is picking up the
> displayed string value rather than the DataField?
>
> Any help will be greatly appreciated.


Mike,

What you're seeing is the correct behavior of a cell editor.  It only edits 
when the cell is selected.   I also believe the editor you have choosen is a 
wx.Choice and is in fact a list and not a dict so you need to change to a 
different class to accept keys ( I think you are using 
the "ListEditorChoices")  

I gather that you always want the choice control to display in the grid.  
Personally I don't like the idea of seeing a column of dropdowns and much 
prefer the default (the editor) way of displaying the data and then allowing 
an editor to change when the cell is selected.  But if I had to - I'd follow 
these steps.  

First I'd check the wx demo app to see what if anything might be available 
(dabo does not prevent you from using wx controls directly).  I'd also google 
for different wx grids cell editors and anything else I could find on the 
subject.

Second, I would consider creating my own.  I think I'd make an effort to code 
both the renderer and the editor.  The renderer only displays when the a draw 
is issued and the editor only works when the cell is selected.  So the draw 
routine would draw a fake choice control and the editor would be the real 
thing.  I'm not sure but it sounds like it might work.

One last thought,  you can always fake a grid with list controls and somewhere 
I saw a list control that contained edit controls.  Sorry I can't recall 
where?  But I'd check Andrea Gavana website (I don't have the link at the 
moment) and if you need to create a custom widget try 
http://zetcode.com/wxpython/customwidgets/ for a tutorial.

The performance issues are above me.  Those types of questions are best 
answered by Ed and Paul.

Johnf





_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-users
Searchable Archives: http://leafe.com/archives/search/dabo-users
This message: 
http://leafe.com/archives/byMID/[email protected]

Reply via email to