-// Initialize wxWindows and bootstrap the user application by calling the
-// wxApp's OnInit, which is a parameter to this funciton. See wxApp.__init__
-// in _extras.py to learn how the bootstrap is started.
-PyObject* __wxStart(PyObject* /* self */, PyObject* args)
-{
- PyObject* onInitFunc = NULL;
- PyObject* arglist= NULL;
- PyObject* result = NULL;
- PyObject* pyint = NULL;
- long bResult;
-
- if (!PyArg_ParseTuple(args, "O", &onInitFunc))
- return NULL;
-
- // Get any command-line args passed to this program from the sys module
- int argc = 0;
- char** argv = NULL;
- PyObject* sysargv = PySys_GetObject("argv");
- if (sysargv != NULL) {
- argc = PyList_Size(sysargv);
- argv = new char*[argc+1];
- int x;
- for(x=0; x<argc; x++) {
- PyObject *pyArg = PyList_GetItem(sysargv, x);
- argv[x] = PyString_AsString(pyArg);
- }
- argv[argc] = NULL;
- }
-
- if (! wxEntryStart(argc, argv) ) {
- PyErr_SetString(PyExc_SystemError, // is this the right one?
- "wxEntryStart failed!");
- goto error;
- }
- delete [] argv;
-
-
- // The stock objects were all NULL when they were loaded into
- // SWIG generated proxies, so re-init those now...
- wxPy_ReinitStockObjects();
-
-
- // Call the Python wxApp's OnInit function
- arglist = PyTuple_New(0);
- result = PyEval_CallObject(onInitFunc, arglist);
- Py_DECREF(arglist);
- if (!result) { // an exception was raised.
- return NULL;
- }
-
- pyint = PyNumber_Int(result);
- if (! pyint) {
- PyErr_SetString(PyExc_TypeError, "OnInit should return a boolean value");
- goto error;
- }
- bResult = PyInt_AS_LONG(pyint);
- if (! bResult) {
- PyErr_SetString(PyExc_SystemExit, "OnInit returned FALSE, exiting...");
- goto error;
- }
-
-#ifdef __WXGTK__
- wxTheApp->m_initialized = (wxTopLevelWindows.GetCount() > 0);
-#endif
-
- Py_DECREF(result);
- Py_DECREF(pyint);
- Py_INCREF(Py_None);
- return Py_None;
-
- error:
- Py_XDECREF(result);
- Py_XDECREF(pyint);
- return NULL;
-}
-
-
-
-void __wxCleanup() {
- wxPyDoingCleanup = TRUE;
- if (wxPyDoCleanup)