Sorry. The attachment…
2011/2/21 woss <wosstemp@gmail.com mailto:wosstemp@gmail.com>
Hi All,
(1st: sorry for my english)
I have problems with DataViewCtrl.
What I want:
- different backgroundcolour for different classes,
- click on bitmap (where he is), and use class-specific method.
The attached sample (modified demo) has two dataviewctrl:
The 1st only with 'model' without 'renderer'.
Here the problems:
- the 'attr' object has not 'SetBackgroundColour' method (GetAttr),
Correct. I’m not sure the reasoning behind this, perhaps the native widget’s renderer types do not support custom background colors.
I’m sad
- I can’t handle LeftClick event.
Would using the selection event instead meet your needs?
It would be nice, but evt.GetColumn() and evt.GetDataViewColumn() do not work.
The 2nd with 'model' and 'renderer's.
Here the problems:
- I can't different BackgroundColour setting for different
classes.
What do you mean by different classes? Different renderers or different types of data rows? If the latter then I don’t think the renderers are supposed to care about the type of data in the row, they are column centric and all values in the column are supposed to be the same type of value, or empty regardless of what is in the rest of the row.
Of course: different types of data rows. Even, for example:
if node.date > ‘2010-01-01’:
BackgroundColour of the whole row = red
else:
BackgroundColour of the whole row = grey
I admit, this is not the place here, but there is no other option.
And column separator is ugly.
You can probably just extend your rectangle to fill the extra space.
I can’t.
The empty vertical separator over paint it.
-
in the LeftClick method the ‘model’ is not ‘MyModel’, This has
not ‘ItemToObject’ method. I can’t decide ‘item’ classes.
This is a shortcoming of SWIG. By default it will create a new proxy object to wrap around pointers but since the pointer type is of a base class it uses that instead of the real class. For classes derived from wxWindow and some others I’m able to implement my own typemap that returns the original Python proxy object instead of making a new one, but it relies on some extra stuff in the C++ class to do it, and I haven’t been able to work out how to do it for the dataview model classes yet. You’ll probably need to save a reference to the model in the renderer when you create it, or something like that.
OK, I understand.
class MyBitmapRenderer(dv.PyDataViewCustomRenderer):
def init(self, log, model, *args, **kw):
dv.PyDataViewCustomRenderer.init(self, *args, **kw)
self.log = log
self.myModel = model
self.value = None
def LeftClick(self, pos, cellRect, model, item, col):
node = self.myModel.ItemToObject(item)
It works.
And one another question:
>>>self.dvc.AssociateModel(self.model)
>>>print self.model
<DVC_DataViewModel.MyModel; proxy of <Swig Object of type
'wxPyDataViewModel *' at 0x244b0b0> >
>>>print self.dvc.GetModel()
<wx.dataview.DataViewModel; proxy of <Swig Object of type
'wxDataViewModel *' at 0x244b0b0> >
Different classes. Why?
Same as above.
–
Robin Dunn
Software Craftsman
http://wxPython.org
–
To unsubscribe, send email to wxPython-users+unsubscribe@googlegroups.com
or visit http://groups.google.com/group/wxPython-users?hl=en
The BackgroundColour problem I give up.
Thanks Robin.
···
2011/2/22 Robin Dunn robin@alldunn.com
On 2/21/11 11:21 AM, woss wrote: