Added wxPyLog so log targets can be created in Python with the

appropriate callbacks.


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@11851 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Robin Dunn
2001-10-05 18:29:29 +00:00
parent 72594e90b2
commit 76bfdc7816
9 changed files with 582 additions and 45 deletions

View File

@@ -160,6 +160,34 @@ IMP_PYCALLBACK_STRING__pure( wxPyTipProvider, wxTipProvider, GetTip);
#include <wx/generic/dragimgg.h>
// A Log class that can be derived from in wxPython
class wxPyLog : public wxLog {
public:
wxPyLog() : wxLog() {}
virtual void DoLog(wxLogLevel level, const wxChar *szString, time_t t) {
bool found;
wxPyTState* state = wxPyBeginBlockThreads();
if ((found = wxPyCBH_findCallback(m_myInst, "DoLog")))
wxPyCBH_callCallback(m_myInst, Py_BuildValue("(isi)", level, szString, t));
wxPyEndBlockThreads(state);
if (! found)
wxLog::DoLog(level, szString, t);
}
virtual void DoLogString(const wxChar *szString, time_t t) {
bool found;
wxPyTState* state = wxPyBeginBlockThreads();
if ((found = wxPyCBH_findCallback(m_myInst, "DoLogString")))
wxPyCBH_callCallback(m_myInst, Py_BuildValue("(si)", szString, t));
wxPyEndBlockThreads(state);
if (! found)
wxLog::DoLogString(szString, t);
}
PYPRIVATE;
};
// C++ version of wxProcess derived class
class wxPyProcess : public wxProcess {
@@ -4691,6 +4719,58 @@ static PyObject *_wrap_wxLog_RemoveTraceMask(PyObject *self, PyObject *args, PyO
return _resultobj;
}
static PyObject *_wrap_wxLog_ClearTraceMasks(PyObject *self, PyObject *args, PyObject *kwargs) {
PyObject * _resultobj;
char *_kwnames[] = { NULL };
self = self;
if(!PyArg_ParseTupleAndKeywords(args,kwargs,":wxLog_ClearTraceMasks",_kwnames))
return NULL;
{
wxPy_BEGIN_ALLOW_THREADS;
wxLog::ClearTraceMasks();
wxPy_END_ALLOW_THREADS;
} Py_INCREF(Py_None);
_resultobj = Py_None;
return _resultobj;
}
static PyObject *_wrap_wxLog_SetTimestamp(PyObject *self, PyObject *args, PyObject *kwargs) {
PyObject * _resultobj;
wxChar * _arg0;
char *_kwnames[] = { "ts", NULL };
self = self;
if(!PyArg_ParseTupleAndKeywords(args,kwargs,"s:wxLog_SetTimestamp",_kwnames,&_arg0))
return NULL;
{
wxPy_BEGIN_ALLOW_THREADS;
wxLog::SetTimestamp(_arg0);
wxPy_END_ALLOW_THREADS;
} Py_INCREF(Py_None);
_resultobj = Py_None;
return _resultobj;
}
static PyObject *_wrap_wxLog_GetTimestamp(PyObject *self, PyObject *args, PyObject *kwargs) {
PyObject * _resultobj;
wxChar * _result;
char *_kwnames[] = { NULL };
self = self;
if(!PyArg_ParseTupleAndKeywords(args,kwargs,":wxLog_GetTimestamp",_kwnames))
return NULL;
{
wxPy_BEGIN_ALLOW_THREADS;
_result = (wxChar *)wxLog::GetTimestamp();
wxPy_END_ALLOW_THREADS;
} _resultobj = Py_BuildValue("s", _result);
return _resultobj;
}
#define wxLog_GetVerbose(_swigobj) (_swigobj->GetVerbose())
static PyObject *_wrap_wxLog_GetVerbose(PyObject *self, PyObject *args, PyObject *kwargs) {
PyObject * _resultobj;
@@ -4755,6 +4835,42 @@ static PyObject *_wrap_wxLog_IsAllowedTraceMask(PyObject *self, PyObject *args,
return _resultobj;
}
static wxString wxLog_TimeStamp(wxLog *self) {
wxString msg;
wxLog::TimeStamp(&msg);
return msg;
}
static PyObject *_wrap_wxLog_TimeStamp(PyObject *self, PyObject *args, PyObject *kwargs) {
PyObject * _resultobj;
wxString * _result;
wxLog * _arg0;
PyObject * _argo0 = 0;
char *_kwnames[] = { "self", NULL };
self = self;
if(!PyArg_ParseTupleAndKeywords(args,kwargs,"O:wxLog_TimeStamp",_kwnames,&_argo0))
return NULL;
if (_argo0) {
if (_argo0 == Py_None) { _arg0 = NULL; }
else if (SWIG_GetPtrObj(_argo0,(void **) &_arg0,"_wxLog_p")) {
PyErr_SetString(PyExc_TypeError,"Type error in argument 1 of wxLog_TimeStamp. Expected _wxLog_p.");
return NULL;
}
}
{
wxPy_BEGIN_ALLOW_THREADS;
_result = new wxString (wxLog_TimeStamp(_arg0));
wxPy_END_ALLOW_THREADS;
}{
_resultobj = PyString_FromStringAndSize(_result->c_str(), _result->Len());
}
{
delete _result;
}
return _resultobj;
}
static void *SwigwxLogStderrTowxLog(void *ptr) {
wxLogStderr *src;
wxLog *dest;
@@ -5112,6 +5228,272 @@ static PyObject *_wrap_delete_wxLogNull(PyObject *self, PyObject *args, PyObject
return _resultobj;
}
static void *SwigwxLogChainTowxLog(void *ptr) {
wxLogChain *src;
wxLog *dest;
src = (wxLogChain *) ptr;
dest = (wxLog *) src;
return (void *) dest;
}
#define new_wxLogChain(_swigarg0) (new wxLogChain(_swigarg0))
static PyObject *_wrap_new_wxLogChain(PyObject *self, PyObject *args, PyObject *kwargs) {
PyObject * _resultobj;
wxLogChain * _result;
wxLog * _arg0;
PyObject * _argo0 = 0;
char *_kwnames[] = { "logger", NULL };
char _ptemp[128];
self = self;
if(!PyArg_ParseTupleAndKeywords(args,kwargs,"O:new_wxLogChain",_kwnames,&_argo0))
return NULL;
if (_argo0) {
if (_argo0 == Py_None) { _arg0 = NULL; }
else if (SWIG_GetPtrObj(_argo0,(void **) &_arg0,"_wxLog_p")) {
PyErr_SetString(PyExc_TypeError,"Type error in argument 1 of new_wxLogChain. Expected _wxLog_p.");
return NULL;
}
}
{
wxPy_BEGIN_ALLOW_THREADS;
_result = (wxLogChain *)new_wxLogChain(_arg0);
wxPy_END_ALLOW_THREADS;
} if (_result) {
SWIG_MakePtr(_ptemp, (char *) _result,"_wxLogChain_p");
_resultobj = Py_BuildValue("s",_ptemp);
} else {
Py_INCREF(Py_None);
_resultobj = Py_None;
}
return _resultobj;
}
#define wxLogChain_SetLog(_swigobj,_swigarg0) (_swigobj->SetLog(_swigarg0))
static PyObject *_wrap_wxLogChain_SetLog(PyObject *self, PyObject *args, PyObject *kwargs) {
PyObject * _resultobj;
wxLogChain * _arg0;
wxLog * _arg1;
PyObject * _argo0 = 0;
PyObject * _argo1 = 0;
char *_kwnames[] = { "self","logger", NULL };
self = self;
if(!PyArg_ParseTupleAndKeywords(args,kwargs,"OO:wxLogChain_SetLog",_kwnames,&_argo0,&_argo1))
return NULL;
if (_argo0) {
if (_argo0 == Py_None) { _arg0 = NULL; }
else if (SWIG_GetPtrObj(_argo0,(void **) &_arg0,"_wxLogChain_p")) {
PyErr_SetString(PyExc_TypeError,"Type error in argument 1 of wxLogChain_SetLog. Expected _wxLogChain_p.");
return NULL;
}
}
if (_argo1) {
if (_argo1 == Py_None) { _arg1 = NULL; }
else if (SWIG_GetPtrObj(_argo1,(void **) &_arg1,"_wxLog_p")) {
PyErr_SetString(PyExc_TypeError,"Type error in argument 2 of wxLogChain_SetLog. Expected _wxLog_p.");
return NULL;
}
}
{
wxPy_BEGIN_ALLOW_THREADS;
wxLogChain_SetLog(_arg0,_arg1);
wxPy_END_ALLOW_THREADS;
} Py_INCREF(Py_None);
_resultobj = Py_None;
return _resultobj;
}
#define wxLogChain_PassMessages(_swigobj,_swigarg0) (_swigobj->PassMessages(_swigarg0))
static PyObject *_wrap_wxLogChain_PassMessages(PyObject *self, PyObject *args, PyObject *kwargs) {
PyObject * _resultobj;
wxLogChain * _arg0;
bool _arg1;
PyObject * _argo0 = 0;
int tempbool1;
char *_kwnames[] = { "self","bDoPass", NULL };
self = self;
if(!PyArg_ParseTupleAndKeywords(args,kwargs,"Oi:wxLogChain_PassMessages",_kwnames,&_argo0,&tempbool1))
return NULL;
if (_argo0) {
if (_argo0 == Py_None) { _arg0 = NULL; }
else if (SWIG_GetPtrObj(_argo0,(void **) &_arg0,"_wxLogChain_p")) {
PyErr_SetString(PyExc_TypeError,"Type error in argument 1 of wxLogChain_PassMessages. Expected _wxLogChain_p.");
return NULL;
}
}
_arg1 = (bool ) tempbool1;
{
wxPy_BEGIN_ALLOW_THREADS;
wxLogChain_PassMessages(_arg0,_arg1);
wxPy_END_ALLOW_THREADS;
} Py_INCREF(Py_None);
_resultobj = Py_None;
return _resultobj;
}
#define wxLogChain_IsPassingMessages(_swigobj) (_swigobj->IsPassingMessages())
static PyObject *_wrap_wxLogChain_IsPassingMessages(PyObject *self, PyObject *args, PyObject *kwargs) {
PyObject * _resultobj;
bool _result;
wxLogChain * _arg0;
PyObject * _argo0 = 0;
char *_kwnames[] = { "self", NULL };
self = self;
if(!PyArg_ParseTupleAndKeywords(args,kwargs,"O:wxLogChain_IsPassingMessages",_kwnames,&_argo0))
return NULL;
if (_argo0) {
if (_argo0 == Py_None) { _arg0 = NULL; }
else if (SWIG_GetPtrObj(_argo0,(void **) &_arg0,"_wxLogChain_p")) {
PyErr_SetString(PyExc_TypeError,"Type error in argument 1 of wxLogChain_IsPassingMessages. Expected _wxLogChain_p.");
return NULL;
}
}
{
wxPy_BEGIN_ALLOW_THREADS;
_result = (bool )wxLogChain_IsPassingMessages(_arg0);
wxPy_END_ALLOW_THREADS;
} _resultobj = Py_BuildValue("i",_result);
return _resultobj;
}
#define wxLogChain_GetOldLog(_swigobj) (_swigobj->GetOldLog())
static PyObject *_wrap_wxLogChain_GetOldLog(PyObject *self, PyObject *args, PyObject *kwargs) {
PyObject * _resultobj;
wxLog * _result;
wxLogChain * _arg0;
PyObject * _argo0 = 0;
char *_kwnames[] = { "self", NULL };
char _ptemp[128];
self = self;
if(!PyArg_ParseTupleAndKeywords(args,kwargs,"O:wxLogChain_GetOldLog",_kwnames,&_argo0))
return NULL;
if (_argo0) {
if (_argo0 == Py_None) { _arg0 = NULL; }
else if (SWIG_GetPtrObj(_argo0,(void **) &_arg0,"_wxLogChain_p")) {
PyErr_SetString(PyExc_TypeError,"Type error in argument 1 of wxLogChain_GetOldLog. Expected _wxLogChain_p.");
return NULL;
}
}
{
wxPy_BEGIN_ALLOW_THREADS;
_result = (wxLog *)wxLogChain_GetOldLog(_arg0);
wxPy_END_ALLOW_THREADS;
} if (_result) {
SWIG_MakePtr(_ptemp, (char *) _result,"_wxLog_p");
_resultobj = Py_BuildValue("s",_ptemp);
} else {
Py_INCREF(Py_None);
_resultobj = Py_None;
}
return _resultobj;
}
static void *SwigwxPyLogTowxLog(void *ptr) {
wxPyLog *src;
wxLog *dest;
src = (wxPyLog *) ptr;
dest = (wxLog *) src;
return (void *) dest;
}
#define new_wxPyLog() (new wxPyLog())
static PyObject *_wrap_new_wxPyLog(PyObject *self, PyObject *args, PyObject *kwargs) {
PyObject * _resultobj;
wxPyLog * _result;
char *_kwnames[] = { NULL };
char _ptemp[128];
self = self;
if(!PyArg_ParseTupleAndKeywords(args,kwargs,":new_wxPyLog",_kwnames))
return NULL;
{
wxPy_BEGIN_ALLOW_THREADS;
_result = (wxPyLog *)new_wxPyLog();
wxPy_END_ALLOW_THREADS;
} if (_result) {
SWIG_MakePtr(_ptemp, (char *) _result,"_wxPyLog_p");
_resultobj = Py_BuildValue("s",_ptemp);
} else {
Py_INCREF(Py_None);
_resultobj = Py_None;
}
return _resultobj;
}
#define wxPyLog__setSelf(_swigobj,_swigarg0,_swigarg1) (_swigobj->_setSelf(_swigarg0,_swigarg1))
static PyObject *_wrap_wxPyLog__setSelf(PyObject *self, PyObject *args, PyObject *kwargs) {
PyObject * _resultobj;
wxPyLog * _arg0;
PyObject * _arg1;
PyObject * _arg2;
PyObject * _argo0 = 0;
PyObject * _obj1 = 0;
PyObject * _obj2 = 0;
char *_kwnames[] = { "self","self","_class", NULL };
self = self;
if(!PyArg_ParseTupleAndKeywords(args,kwargs,"OOO:wxPyLog__setSelf",_kwnames,&_argo0,&_obj1,&_obj2))
return NULL;
if (_argo0) {
if (_argo0 == Py_None) { _arg0 = NULL; }
else if (SWIG_GetPtrObj(_argo0,(void **) &_arg0,"_wxPyLog_p")) {
PyErr_SetString(PyExc_TypeError,"Type error in argument 1 of wxPyLog__setSelf. Expected _wxPyLog_p.");
return NULL;
}
}
{
_arg1 = _obj1;
}
{
_arg2 = _obj2;
}
{
wxPy_BEGIN_ALLOW_THREADS;
wxPyLog__setSelf(_arg0,_arg1,_arg2);
wxPy_END_ALLOW_THREADS;
} Py_INCREF(Py_None);
_resultobj = Py_None;
return _resultobj;
}
static void wxPyLog_Destroy(wxPyLog *self) { delete self; }
static PyObject *_wrap_wxPyLog_Destroy(PyObject *self, PyObject *args, PyObject *kwargs) {
PyObject * _resultobj;
wxPyLog * _arg0;
PyObject * _argo0 = 0;
char *_kwnames[] = { "self", NULL };
self = self;
if(!PyArg_ParseTupleAndKeywords(args,kwargs,"O:wxPyLog_Destroy",_kwnames,&_argo0))
return NULL;
if (_argo0) {
if (_argo0 == Py_None) { _arg0 = NULL; }
else if (SWIG_GetPtrObj(_argo0,(void **) &_arg0,"_wxPyLog_p")) {
PyErr_SetString(PyExc_TypeError,"Type error in argument 1 of wxPyLog_Destroy. Expected _wxPyLog_p.");
return NULL;
}
}
{
wxPy_BEGIN_ALLOW_THREADS;
wxPyLog_Destroy(_arg0);
wxPy_END_ALLOW_THREADS;
} Py_INCREF(Py_None);
_resultobj = Py_None;
return _resultobj;
}
static void *SwigwxProcessEventTowxEvent(void *ptr) {
wxProcessEvent *src;
wxEvent *dest;
@@ -7101,6 +7483,14 @@ static PyMethodDef misc2cMethods[] = {
{ "wxProcessEvent_GetExitCode", (PyCFunction) _wrap_wxProcessEvent_GetExitCode, METH_VARARGS | METH_KEYWORDS },
{ "wxProcessEvent_GetPid", (PyCFunction) _wrap_wxProcessEvent_GetPid, METH_VARARGS | METH_KEYWORDS },
{ "new_wxProcessEvent", (PyCFunction) _wrap_new_wxProcessEvent, METH_VARARGS | METH_KEYWORDS },
{ "wxPyLog_Destroy", (PyCFunction) _wrap_wxPyLog_Destroy, METH_VARARGS | METH_KEYWORDS },
{ "wxPyLog__setSelf", (PyCFunction) _wrap_wxPyLog__setSelf, METH_VARARGS | METH_KEYWORDS },
{ "new_wxPyLog", (PyCFunction) _wrap_new_wxPyLog, METH_VARARGS | METH_KEYWORDS },
{ "wxLogChain_GetOldLog", (PyCFunction) _wrap_wxLogChain_GetOldLog, METH_VARARGS | METH_KEYWORDS },
{ "wxLogChain_IsPassingMessages", (PyCFunction) _wrap_wxLogChain_IsPassingMessages, METH_VARARGS | METH_KEYWORDS },
{ "wxLogChain_PassMessages", (PyCFunction) _wrap_wxLogChain_PassMessages, METH_VARARGS | METH_KEYWORDS },
{ "wxLogChain_SetLog", (PyCFunction) _wrap_wxLogChain_SetLog, METH_VARARGS | METH_KEYWORDS },
{ "new_wxLogChain", (PyCFunction) _wrap_new_wxLogChain, METH_VARARGS | METH_KEYWORDS },
{ "delete_wxLogNull", (PyCFunction) _wrap_delete_wxLogNull, METH_VARARGS | METH_KEYWORDS },
{ "new_wxLogNull", (PyCFunction) _wrap_new_wxLogNull, METH_VARARGS | METH_KEYWORDS },
{ "wxLogWindow_PassMessages", (PyCFunction) _wrap_wxLogWindow_PassMessages, METH_VARARGS | METH_KEYWORDS },
@@ -7112,9 +7502,13 @@ static PyMethodDef misc2cMethods[] = {
{ "new_wxLogGui", (PyCFunction) _wrap_new_wxLogGui, METH_VARARGS | METH_KEYWORDS },
{ "new_wxLogTextCtrl", (PyCFunction) _wrap_new_wxLogTextCtrl, METH_VARARGS | METH_KEYWORDS },
{ "new_wxLogStderr", (PyCFunction) _wrap_new_wxLogStderr, METH_VARARGS | METH_KEYWORDS },
{ "wxLog_TimeStamp", (PyCFunction) _wrap_wxLog_TimeStamp, METH_VARARGS | METH_KEYWORDS },
{ "wxLog_IsAllowedTraceMask", (PyCFunction) _wrap_wxLog_IsAllowedTraceMask, METH_VARARGS | METH_KEYWORDS },
{ "wxLog_GetTraceMask", (PyCFunction) _wrap_wxLog_GetTraceMask, METH_VARARGS | METH_KEYWORDS },
{ "wxLog_GetVerbose", (PyCFunction) _wrap_wxLog_GetVerbose, METH_VARARGS | METH_KEYWORDS },
{ "wxLog_GetTimestamp", (PyCFunction) _wrap_wxLog_GetTimestamp, METH_VARARGS | METH_KEYWORDS },
{ "wxLog_SetTimestamp", (PyCFunction) _wrap_wxLog_SetTimestamp, METH_VARARGS | METH_KEYWORDS },
{ "wxLog_ClearTraceMasks", (PyCFunction) _wrap_wxLog_ClearTraceMasks, METH_VARARGS | METH_KEYWORDS },
{ "wxLog_RemoveTraceMask", (PyCFunction) _wrap_wxLog_RemoveTraceMask, METH_VARARGS | METH_KEYWORDS },
{ "wxLog_AddTraceMask", (PyCFunction) _wrap_wxLog_AddTraceMask, METH_VARARGS | METH_KEYWORDS },
{ "wxLog_SetTraceMask", (PyCFunction) _wrap_wxLog_SetTraceMask, METH_VARARGS | METH_KEYWORDS },
@@ -7273,6 +7667,8 @@ static struct { char *n1; char *n2; void *(*pcnv)(void *); } _swig_mapping[] = {
{ "_wxPrintQuality","_EBool",0},
{ "_wxPrintQuality","_size_t",0},
{ "_wxPrintQuality","_time_t",0},
{ "_wxLog","_wxPyLog",SwigwxPyLogTowxLog},
{ "_wxLog","_wxLogChain",SwigwxLogChainTowxLog},
{ "_wxLog","_wxLogWindow",SwigwxLogWindowTowxLog},
{ "_wxLog","_wxLogGui",SwigwxLogGuiTowxLog},
{ "_wxLog","_wxLogTextCtrl",SwigwxLogTextCtrlTowxLog},