Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,10 @@ def displayhook(v):
def init_graphics(self, gEnv, gSystem):
"""Configure ROOT graphics to be used interactively"""

# Note that we only end up in this function if gROOT.IsBatch() is false
if getattr(self, "_graphics_initialized", False):
return
self._graphics_initialized = True

import __main__

if self._is_ipython and "IPython" in sys.modules and sys.modules["IPython"].version_info[0] >= 5:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Author: PyROOT Team

################################################################################
# Copyright (C) 1995-2026, Rene Brun and Fons Rademakers. #
# All rights reserved. #
# #
# For the licensing terms see $ROOTSYS/LICENSE. #
# For the list of contributors see $ROOTSYS/README/CREDITS. #
################################################################################

r"""
\pythondoc TROOT

Pythonizations for TROOT class, enabling dynamic batch mode toggling.
"""

from . import pythonization


def _TROOT_SetBatch(self, batch=True):
"""
Sets the batch mode on ROOT.
If batch mode is turned off in the middle of a session, ensure the
interactive graphics environment is initialized.
"""
import ROOT

self._cpp_SetBatch(batch)
if not batch and hasattr(ROOT, "app") and ROOT.PyConfig.StartGUIThread:
ROOT.app.init_graphics(ROOT._cppyy.gbl.gEnv, ROOT._cppyy.gbl.gSystem)


@pythonization("TROOT")
def pythonize_troot(klass):
klass._cpp_SetBatch = klass.SetBatch
klass.SetBatch = _TROOT_SetBatch