47 char **argv =
nullptr;
49 if (ignoreCmdLineOpts) {
50 argv =
new char *[argc];
53 PyObject *argl = PySys_GetObject(
const_cast<char *
>(
"argv"));
55 if (argl && 0 < PyList_Size(argl))
56 argc = (
int)PyList_GET_SIZE(argl);
58 argv =
new char *[argc];
59 for (
int i = 1; i < argc; ++i) {
61 if (strcmp(argi,
"-") == 0 || strcmp(argi,
"--") == 0) {
70#if PY_VERSION_HEX < 0x03000000
71 if (Py_GetProgramName() && strlen(Py_GetProgramName()) != 0)
72 argv[0] = Py_GetProgramName();
74 argv[0] = (
char *)
"python";
76 argv[0] = (
char *)
"python";
99#if PY_VERSION_HEX < 0x03000000
121 static const char *emptyString =
"";
123 location = emptyString;
131 PyErr_WarnExplicit(NULL, (
char *)msg, (
char *)location, 0, (
char *)
"ROOT", NULL);
154 int argc = PyTuple_GET_SIZE(args);
156 PyObject *ignoreCmdLineOpts = PyTuple_GetItem(args, 0);
158 if (!PyBool_Check(ignoreCmdLineOpts)) {
159 PyErr_SetString(PyExc_TypeError,
"Expected boolean type as argument.");
163 if (CreateApplication(PyObject_IsTrue(ignoreCmdLineOpts))) {
165 InitROOTMessageCallback();
168 PyErr_Format(PyExc_TypeError,
"Expected 1 argument, %d passed.", argc);
187 Gl_histinit((
char *)
"-");
194static int (*sOldInputHook)() =
nullptr;
195static PyThreadState *sInputHookEventThreadState =
nullptr;
197static int EventInputHook()
201 PyEval_RestoreThread(sInputHookEventThreadState);
208 return sOldInputHook();
221 if (PyOS_InputHook && PyOS_InputHook != &EventInputHook)
222 sOldInputHook = PyOS_InputHook;
224 sInputHookEventThreadState = PyThreadState_Get();
226 PyOS_InputHook = (
int (*)()) & EventInputHook;
#define CPyCppyy_PyText_AsString
static void ErrMsgHandler(int level, Bool_t abort, const char *location, const char *msg)
Translate ROOT error/warning to Python.
R__EXTERN TApplication * gApplication
R__EXTERN TBenchmark * gBenchmark
void DefaultErrorHandler(Int_t level, Bool_t abort_bool, const char *location, const char *msg)
The default error handler function.
void(* ErrorHandlerFunc_t)(int level, Bool_t abort, const char *location, const char *msg)
Int_t gErrorIgnoreLevel
Error handling routines.
ErrorHandlerFunc_t SetErrorHandler(ErrorHandlerFunc_t newhandler)
Set an errorhandler function. Returns the old handler.
R__EXTERN TStyle * gStyle
R__EXTERN const char * gProgName
R__EXTERN TSystem * gSystem
R__EXTERN TVirtualMutex * gGlobalMutex
Interactive application for Python.
static PyObject * InstallGUIEventInputHook(PyObject *self, PyObject *args)
Install a method hook for sending events to the GUI.
static void InitROOTMessageCallback()
Install the ROOT message handler which will turn ROOT error messages into Python exceptions.
static PyObject * InitApplication(PyObject *self, PyObject *args)
Initialize an RPyROOTApplication.
RPyROOTApplication(const char *acn, int *argc, char **argv)
Construct a TApplication for PyROOT.
static void InitROOTGlobals()
Setup the basic ROOT globals gBenchmark, gStyle and gProgname, if not already set.
This class creates the ROOT Application Environment that interfaces to the windowing system eventloop...
void SetReturnFromRun(Bool_t ret)
static void CreateApplication()
Static function used to create a default application environment.
This class is a ROOT utility to help benchmarking applications.
TStyle objects may be created to define special styles.
virtual void SetProgname(const char *name)
Set the application name (from command line, argv[0]) and copy it in gProgName.
virtual Bool_t ProcessEvents()
Process pending events (GUI, timers, sockets).