On 11/23/2015 22:17, Dietmar Schwertberger wrote:
Am 20.11.2015 um 00:10 schrieb John Fabiani:
Of course we have. I haven't tested in the last few months but I
still believe the grid is a major issue (but has there been an
updated release). We actually have a git branch with code that
supports python3 and Phoenix but of course only parts of it work.
Believe me if Phoenix ever gets released it won't take long for Dabo
to convert to python 3. We currently have wxPython 3.x working and
working well I might add. Dabo2 (that's what I call it) runs faster
and better with wxPython 3.x than with wxPython 2.8.x
OK, Werner answered that the grid issues were reported on -dev.
I had a quick look at the sources and the demo.
In wxWidgets, for different data types different methods are called:
GetValue for strings, GetValueAsLong for integers and so on.
In the demo there's a comment about this:
# Get/Set values in the table. The Python version of these
# methods can handle any data-type, (as long as the Editor and
# Renderer understands the type too,) not just strings as in the
# C++ version.
This comment is 100% correct. The standard renderer will not cope with
an integer returned by GetValue.
But e.g. the demo GridStdEdRend.py with Python renderers will do.
If I add e.g. a GetValueAs Long method to the demo code with the
standard renderer (GridCustTable.py), things work as expected for the
integer types in Phonix:
def GetValue(self, row, col):
try:
return self.data[row][col]
except IndexError:
return ''
def GetValueAsLong(self, row, col):
try:
return self.data[row][col]
except IndexError:
return 0
In the sources of classic, you can find e.g. the implementation for
GetValueAsLong calling Python GetValue and converting it to Long:
(in src/grid.i)
// Map the Get/Set methods for the standard non-string types to
// the GetValue and SetValue python methods.
long GetValueAsLong( int row, int col ) {
long rval = 0;
wxPyBlock_t blocked = wxPyBeginBlockThreads();
if (wxPyCBH_findCallback(m_myInst, "GetValue")) {
PyObject* ro;
PyObject* num;
ro = wxPyCBH_callCallbackObj(m_myInst,
Py_BuildValue("(ii)", row, col));
if (ro && PyNumber_Check(ro)) {
num = PyNumber_Int(ro);
if (num) {
rval = PyInt_AsLong(num);
Py_DECREF(num);
}
Py_DECREF(ro);
}
}
wxPyEndBlockThreads(blocked);
return rval;
I'm not sure which is the better way: stay compatible with Classic or
use the "standard" way of multiple methods.
The Classic way is probabyl more pythonic.
If I understand this correctly, Dabo has the option of using the
individual methods, then it will work now. Or wait for Robin to do some
magic to handle this as I think he did in Classic or come up with the
magic and do a PR for it.
As I won't get to this for a long time I'll copy the Dabo list, maybe
someone wants to take this on.
Werner
_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://mail.leafe.com/mailman/listinfo/dabo-dev
Searchable Archives: http://leafe.com/archives/search/dabo-dev
This message: http://leafe.com/archives/byMID/[email protected]