Show ROOT files using Jaida
Source code name: "jaida_gui_root_objects.py"
Programming language: Python
Topic: File IO/Root
DMelt Version 1. Last modified: 03/07/2016. License: Free
http://datamelt.org/code/cache/jaida_gui_root_objects_2095.py
To run this script using the DMelt IDE, copy the above URL link to the menu [File]→[Read script from URL] of the DMelt IDE.



# example to show ROOT objects
from javax.swing import JButton, JDialog, JLabel, JPanel, JScrollPane
from java.awt import BorderLayout
from java.io import File
from java.awt.event import ActionListener, KeyEvent, KeyListener, MouseListener
from hep.io.root.util import RootObjectBrowser

import urllib
urllib.urlretrieve ("http://datamelt.org/examples/data/Example.root", "Example.root")


# show ROOT objects
browser = RootObjectBrowser()
browser.setRootFile( File("Example.root")  )

frame =JDialog();
topPanel = JPanel();
lowerPanel = JPanel();

def exitme(event):
       frame.dispose()     
jB3 = JButton("Exit", actionPerformed=exitme)
lowerPanel.add(jB3)
topPanel.setLayout(BorderLayout())

# comments
jScrollPane1 = JScrollPane()
jScrollPane1.getViewport().add( browser );
topPanel.add(jScrollPane1,BorderLayout.CENTER);
frame.add( topPanel,  BorderLayout.CENTER );
frame.add( lowerPanel, BorderLayout.SOUTH );

bounds = view.getBounds()
ww = bounds.width
hh=  bounds.height
xx = bounds.x
yy = bounds.y
  
frame.setLocation(xx+(int)(0.4*ww), yy+(int)(0.1*hh))
frame.pack()
frame.setSize( (int)(0.5*ww),(int)(0.8*hh) );
frame.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE)
frame.setVisible(1)