46 char **argv =
nullptr;
48 if (ignoreCmdLineOpts) {
49 argv =
new char *[argc];
52 PyObject *argl = PySys_GetObject(
"argv");
54 if (argl && 0 < PyList_Size(argl))
55 argc = (
int)PyList_GET_SIZE(argl);
57 argv =
new char *[argc];
58 for (
int i = 1; i < argc; ++i) {
59 char *argi =
const_cast<char *
>(PyUnicode_AsUTF8(PyList_GET_ITEM(argl, i)));
60 if (strcmp(argi,
"-") == 0 || strcmp(argi,
"--") == 0) {
69 argv[0] = (
char *)
"python";
109 static const char *emptyString =
"";
111 location = emptyString;
119 PyErr_WarnExplicit(NULL, (
char *)msg, (
char *)location, 0, (
char *)
"ROOT", NULL);
142 int argc = PyTuple_GET_SIZE(args);
144 PyObject *ignoreCmdLineOpts = PyTuple_GetItem(args, 0);
146 if (!PyBool_Check(ignoreCmdLineOpts)) {
147 PyErr_SetString(PyExc_TypeError,
"Expected boolean type as argument.");
151 if (CreateApplication(PyObject_IsTrue(ignoreCmdLineOpts))) {
153 InitROOTMessageCallback();
156 PyErr_Format(PyExc_TypeError,
"Expected 1 argument, %d passed.", argc);
176 Gl_histinit((
char *)
"-");
183static int (*sOldInputHook)() =
nullptr;
184static PyThreadState *sInputHookEventThreadState =
nullptr;
186static int EventInputHook()
190 PyEval_RestoreThread(sInputHookEventThreadState);
197 return sOldInputHook();
210 if (PyOS_InputHook && PyOS_InputHook != &EventInputHook)
211 sOldInputHook = PyOS_InputHook;
213 sInputHookEventThreadState = PyThreadState_Get();
215 PyOS_InputHook = (
int (*)()) & EventInputHook;
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.
RPyROOTApplication(const char *name, int *argc, char **argv)
Construct a TApplication for PyROOT.
static PyObject * InitApplication(PyObject *self, PyObject *args)
Initialize an RPyROOTApplication.
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).