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);
153 int argc = PyTuple_GET_SIZE(args);
155 PyObject *ignoreCmdLineOpts = PyTuple_GetItem(args, 0);
157 if (!PyBool_Check(ignoreCmdLineOpts)) {
158 PyErr_SetString(PyExc_TypeError,
"Expected boolean type as argument.");
162 if (CreateApplication(PyObject_IsTrue(ignoreCmdLineOpts))) {
164 InitROOTMessageCallback();
167 PyErr_Format(PyExc_TypeError,
"Expected 1 argument, %d passed.", argc);
186 Gl_histinit((
char *)
"-");
193static int (*sOldInputHook)() =
nullptr;
194static PyThreadState *sInputHookEventThreadState =
nullptr;
196static int EventInputHook()
200 PyEval_RestoreThread(sInputHookEventThreadState);
205 return sOldInputHook();
218 if (PyOS_InputHook && PyOS_InputHook != &EventInputHook)
219 sOldInputHook = PyOS_InputHook;
221 sInputHookEventThreadState = PyThreadState_Get();
223 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)
R__EXTERN Int_t gErrorIgnoreLevel
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).