ROOT  6.07/01
Reference Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
draw.py
Go to the documentation of this file.
1 # -*- coding:utf-8 -*-
2 #-----------------------------------------------------------------------------
3 # Copyright (c) 2015, ROOT Team.
4 #
5 # Authors: Danilo Piparo <Danilo.Piparo@cern.ch> CERN
6 # Enric Tejedor enric.tejedor.saavedra@cern.ch> CERN
7 # Modified by: Omar Zapata <Omar.Zapata@cern.ch> http://oproject.org
8 # website: http://oproject.org/ROOT+Jupyter+Kernel (information only for ROOT kernel)
9 # Distributed under the terms of the Modified LGPLv3 License.
10 #
11 # The full license is in the file COPYING.rst, distributed with this software.
12 #-----------------------------------------------------------------------------
13 
14 from metakernel.display import display,HTML
15 
16 import ROOT
17 
18 try:
19  from JupyROOT.utils import CanvasDrawer as CanvasDrawerCore
20  from JupyROOT.utils import enhanceROOTModule
21 except ImportError:
22  raise Exception("Error: JupyROOT not found")
23 
24 class CanvasDrawer(CanvasDrawerCore):
25  '''
26  Capture the canvas which is drawn and decide if it should be displayed using
27  jsROOT with metakernel.
28  '''
29  def __init__(self, canvas):
30  CanvasDrawerCore.__init__(self,canvas)
31 
32  def _jsDisplay(self):
33  '''Overloaded method to display with metakernel.display'''
34  display(HTML(self.getJsCode()))
35 
36 
37  def _pngDisplay(self):
38  display(self.getPngImage())
39 
40 #required to display using metakernel.display instead IPython.display
41 def _PyDraw(thePad):
42  """
43  Invoke the draw function and intercept the graphics
44  """
45  drawer = CanvasDrawer(thePad)
46  drawer.Draw()
47 
48 def LoadDrawer():
50  ROOT.TCanvas.Draw = _PyDraw
ROOT::R::TRInterface & Exception()
Definition: Exception.C:4
def enhanceROOTModule
Definition: utils.py:390