45 char **argv =
nullptr;
47 if (ignoreCmdLineOpts) {
48 argv =
new char *[argc];
51 PyObject *argl = PySys_GetObject(
const_cast<char *
>(
"argv"));
53 if (argl && 0 < PyList_Size(argl))
54 argc = (
int)PyList_GET_SIZE(argl);
56 argv =
new char *[argc];
57 for (
int i = 1; i < argc; ++i) {
59 if (strcmp(argi,
"-") == 0 || strcmp(argi,
"--") == 0) {
68#if PY_VERSION_HEX < 0x03000000
69 if (Py_GetProgramName() && strlen(Py_GetProgramName()) != 0)
70 argv[0] = Py_GetProgramName();
72 argv[0] = (
char *)
"python";
74 argv[0] = (
char *)
"python";
97#if PY_VERSION_HEX < 0x03000000
119 static const char *emptyString =
"";
121 location = emptyString;
129 PyErr_WarnExplicit(NULL, (
char *)msg, (
char *)location, 0, (
char *)
"ROOT", NULL);
152 int argc = PyTuple_GET_SIZE(args);
154 PyObject *ignoreCmdLineOpts = PyTuple_GetItem(args, 0);
156 if (!PyBool_Check(ignoreCmdLineOpts)) {
157 PyErr_SetString(PyExc_TypeError,
"Expected boolean type as argument.");
161 if (CreateApplication(PyObject_IsTrue(ignoreCmdLineOpts))) {
163 InitROOTMessageCallback();
166 PyErr_Format(PyExc_TypeError,
"Expected 1 argument, %d passed.", argc);
185 Gl_histinit((
char *)
"-");
192static int (*sOldInputHook)() =
nullptr;
193static PyThreadState *sInputHookEventThreadState =
nullptr;
195static int EventInputHook()
199 PyEval_RestoreThread(sInputHookEventThreadState);
204 return sOldInputHook();
217 if (PyOS_InputHook && PyOS_InputHook != &EventInputHook)
218 sOldInputHook = PyOS_InputHook;
220 sInputHookEventThreadState = PyThreadState_Get();
222 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)
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).