Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
gui_simple.py
Go to the documentation of this file.
1## \file
2## \ingroup tutorial_gui
3## A Simple GUI Example
4##
5## \macro_code
6##
7## \author Wim Lavrijsen
8
9import ROOT
10
11
12def pygaus(x, par):
13 import math
14
15 if par[2] != 0.0:
16 arg1 = (x[0] - par[1]) / par[2]
17 arg2 = (0.01 * 0.39894228) / par[2]
18 arg3 = par[0] / (1 + par[3])
19
20 gauss = arg3 * arg2 * math.exp(-0.5 * arg1 * arg1)
21 else:
22 print("returning 0")
23 gauss = 0.0
24 return gauss
25
26
27tpygaus = ROOT.TF1("pygaus", pygaus, -4, 4, 4)
28tpygaus.SetParameters(1.0, 0.0, 1.0)
29
30
31def MyDraw():
33 if btn.WidgetId() == 10:
34 global tpygaus, window
37
38
40 def __init__(self, parent, width, height):
41 ROOT.TGMainFrame.__init__(self, parent, width, height)
42
43 self.Canvas = ROOT.TRootEmbeddedCanvas("Canvas", self, 200, 200)
45 self.ButtonsFrame = ROOT.TGHorizontalFrame(self, 200, 40)
46
47 self.DrawButton = ROOT.TGTextButton(self.ButtonsFrame, "&Draw", 10)
48 self.DrawButton.Connect("Clicked()", MyDraw)
49 self.ButtonsFrame.AddFrame(self.DrawButton, ROOT.TGLayoutHints())
50
51 self.ExitButton = ROOT.TGTextButton(self.ButtonsFrame, "&Exit", 20)
52 self.ExitButton.SetCommand('TPython::Exec( "raise SystemExit" )')
53 self.ButtonsFrame.AddFrame(self.ExitButton, ROOT.TGLayoutHints())
54
55 self.AddFrame(self.ButtonsFrame, ROOT.TGLayoutHints())
56
57 self.SetWindowName("My first GUI")
58 self.MapSubwindows()
59 self.Resize(self.GetDefaultSize())
60 self.MapWindow()
61
62 def __del__(self):
63 self.Cleanup()
64
65
66if __name__ == "__main__":
67 window = pMainFrame(ROOT.gClient.GetRoot(), 200, 200)
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.