from sihippo import *
from random import random
from qt import *
import sys
from time import sleep

app = QApplication(sys.argv)

label1 = ['Hits per Event']
ntc = NTupleController.instance()
ntall = ntc.createNTuple(1)
ntall.setTitle('Hit Multiplicity All Layers')
ntall.setLabels(label1)
ntall.reserve ( 512 )
wc = WindowController.instance()
canvas = CanvasWindow()
canvas = wc.currentCanvas()
dc = DisplayController.instance()
hist = dc.createDisplay ('Histogram', ntall, label1 )
hist.setRange('x', 0 , 30 )
#hist.setRange('y', 0 , 64 )
canvas.addDisplay(hist)
ntall.setIntervalCount ( 1 )
canvas.setIntervalEnabled ( 1 )
canvas.show()

for i in range(100):
  x = int(random()*10)
  ntall.addRow([x])
  app.processEvents()
  sleep(.2)

app.exec_loop()
