Re: ROOT Gui with pyRoot

From: <WLavrijsen_at_lbl.gov>
Date: Tue, 16 Jan 2007 19:34:35 -0800 (PST)


Johan,

ok, finally got around to install Qt and PyQt. :) I have not been able to do very much, but just a straightforward embedding works (this is w/o use of any QtRoot, mind). See below for code.

Ok, that's the ugly way. :) Tomorrow I'll see whether clean works as well.

Best regards,

           Wim

import qt, ROOT

class MainWindow( qt.QMainWindow ):

   def __init__( self ):

      qt.QMainWindow.__init__( self )
      self.resize( 350, 350 )
   
      wid = ROOT.gVirtualX.AddWindow( self.handle(), 350, 350 )
      self.canvas = ROOT.TCanvas( "my canvas", 350, 350, wid )
      self.hist = ROOT.TH1F( "h","Gauss", 100, -4, 4 )
      self.hist.FillRandom( "gaus", 200000 )
      self.hist.Draw()

   def paintEvent( self, event ):
      self.canvas.Modified()
      self.canvas.Update()

   def resizeEvent(self, event):
      self.canvas.Resize()

if __name__ == '__main__':

   import sys
   application = qt.QApplication(sys.argv)    w = MainWindow()
   w.show()
   w.canvas.Resize()
   application.exec_loop()    

--
Wim.Lavrijsen_at_cern.ch   --   WLavrijsen_at_lbl.gov   --   www.lavrijsen.net

"Stop making excuses for your software."    --first step towards quality
   "GIGO is not a valid design pattern."         --corollary
Received on Wed Jan 17 2007 - 04:34:44 CET

This archive was generated by hypermail 2.2.0 : Wed Jan 17 2007 - 05:50:00 CET