mirror of
https://github.com/wxWidgets/Phoenix.git
synced 2026-01-05 03:20:08 +01:00
Some tweaks and code reorg, and a note about why it isn't working so far...
This commit is contained in:
@@ -38,15 +38,17 @@ def run():
|
|||||||
module.find('wxFileSelectorDefaultWildcardStr').ignore()
|
module.find('wxFileSelectorDefaultWildcardStr').ignore()
|
||||||
|
|
||||||
c.find('ExtraControlCreatorFunction').ignore()
|
c.find('ExtraControlCreatorFunction').ignore()
|
||||||
c.find('SetExtraControlCreator').ignore()
|
|
||||||
|
|
||||||
c.addHeaderCode("""\
|
c.addCppCode("""\
|
||||||
wxWindow* _callPythonExtraControlCreator(wxWindow* w)
|
#define ECCF_ATTR_NAME "_wxExtraControlCreatorFunction"
|
||||||
|
static
|
||||||
|
wxWindow* wxFileDialog_CallPythonExtraControlCreator(wxWindow* w)
|
||||||
{
|
{
|
||||||
wxPyThreadBlocker blocker;
|
wxPyThreadBlocker blocker;
|
||||||
wxWindow* cw = NULL;
|
wxWindow* cw = NULL;
|
||||||
PyObject* pyw = sipGetPyObject(w, sipType_wxWindow);
|
PyObject* pyw = sipGetPyObject(w, sipType_wxWindow);
|
||||||
PyObject* ccf = PyObject_GetAttrString(pyw, "_wxExtraControlCreatorFunction");
|
|
||||||
|
PyObject* ccf = PyObject_GetAttrString(pyw, ECCF_ATTR_NAME);
|
||||||
if (ccf == NULL)
|
if (ccf == NULL)
|
||||||
PyErr_SetString(PyExc_RuntimeError,
|
PyErr_SetString(PyExc_RuntimeError,
|
||||||
"extra control creator function disappeared");
|
"extra control creator function disappeared");
|
||||||
@@ -73,27 +75,31 @@ def run():
|
|||||||
}
|
}
|
||||||
""")
|
""")
|
||||||
|
|
||||||
c.addCppMethod('bool', 'SetExtraControlCreator', '(PyObject* ccf)',
|
# NOTE: The creator function may be called with a window other than this dialog
|
||||||
doc="""\
|
# (at least on Windows) So we will need a new way to store and find the PyObject
|
||||||
Set extra control creator function to be called during dialog creation""",
|
# for the creator function.
|
||||||
body="""\
|
|
||||||
bool status = true;
|
secc = c.find('SetExtraControlCreator')
|
||||||
{
|
secc.find('creator').type = 'PyObject*'
|
||||||
wxPyThreadBlocker blocker;
|
secc.argsString = '(PyObject* creator)'
|
||||||
PyObject* pySelf = sipGetPyObject(self, sipType_wxWindow);
|
secc.setCppCode("""\
|
||||||
if (pySelf == NULL) {
|
bool status;
|
||||||
PyErr_SetString(PyExc_ValueError, "expecting wxWindow object");
|
wxPyThreadBlocker blocker;
|
||||||
status = false;
|
PyObject* pySelf = sipGetPyObject(self, sipType_wxFileDialog);
|
||||||
}
|
|
||||||
else if (!PyCallable_Check(ccf)) {
|
if (pySelf == NULL) {
|
||||||
PyErr_SetString(PyExc_ValueError, "expecting function or callable object");
|
// This should not ever happen, but just in case...
|
||||||
status = false;
|
PyErr_SetString(PyExc_ValueError, "expecting wxFileDialog object");
|
||||||
}
|
status = false;
|
||||||
else if (PyObject_SetAttrString(pySelf, "_wxExtraControlCreatorFunction", ccf) < 0)
|
|
||||||
status = false;
|
|
||||||
else
|
|
||||||
self->SetExtraControlCreator(_callPythonExtraControlCreator);
|
|
||||||
}
|
}
|
||||||
|
else if (!PyCallable_Check(creator)) {
|
||||||
|
PyErr_SetString(PyExc_ValueError, "expecting function or callable object");
|
||||||
|
status = false;
|
||||||
|
}
|
||||||
|
else if (PyObject_SetAttrString(pySelf, ECCF_ATTR_NAME, creator) != 0)
|
||||||
|
status = false;
|
||||||
|
else
|
||||||
|
status = self->SetExtraControlCreator(wxFileDialog_CallPythonExtraControlCreator);
|
||||||
return status;
|
return status;
|
||||||
""")
|
""")
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user