A Simple GUI Example.
7 arg1 = (x[0]-par[1])/par[2]
8 arg2 = (0.01*0.39894228)/par[2]
9 arg3 = par[0]/(1+par[3])
11 gauss = arg3*arg2*math.exp(-0.5*arg1*arg1)
17 tpygaus = ROOT.TF1(
'pygaus', pygaus, -4, 4, 4 )
18 tpygaus.SetParameters( 1., 0., 1. )
21 btn = ROOT.BindObject( ROOT.gTQSender, ROOT.TGTextButton )
22 if btn.WidgetId() == 10:
23 global tpygaus, window
27 m = ROOT.TPyDispatcher( MyDraw )
30 class pMainFrame( ROOT.TGMainFrame ):
31 def __init__( self, parent, width, height ):
32 ROOT.TGMainFrame.__init__( self, parent, width, height )
34 self.Canvas = ROOT.TRootEmbeddedCanvas(
'Canvas', self, 200, 200 )
35 self.AddFrame( self.Canvas, ROOT.TGLayoutHints() )
36 self.ButtonsFrame = ROOT.TGHorizontalFrame( self, 200, 40 )
38 self.DrawButton = ROOT.TGTextButton( self.ButtonsFrame,
'&Draw', 10 )
39 self.DrawButton.Connect(
'Clicked()',
"TPyDispatcher", m,
'Dispatch()' )
40 self.ButtonsFrame.AddFrame( self.DrawButton, ROOT.TGLayoutHints() )
42 self.ExitButton = ROOT.TGTextButton( self.ButtonsFrame,
'&Exit', 20 )
43 self.ExitButton.SetCommand(
'TPython::Exec( "raise SystemExit" )' )
44 self.ButtonsFrame.AddFrame( self.ExitButton, ROOT.TGLayoutHints() )
46 self.AddFrame( self.ButtonsFrame, ROOT.TGLayoutHints() )
48 self.SetWindowName(
'My first GUI' )
50 self.Resize( self.GetDefaultSize() )
57 if __name__ ==
'__main__':
58 window = pMainFrame( ROOT.gClient.GetRoot(), 200, 200 )