13class pMyMainFrame(ROOT.TGMainFrame):
14 def __init__(self, parent, width, height):
15 ROOT.TGMainFrame.__init__(self, parent, width, height)
17 self.fHor1 = ROOT.TGHorizontalFrame(self, 60, 20, ROOT.kFixedWidth)
18 self.fExit = ROOT.TGTextButton(self.fHor1,
"&Exit",
"gApplication->Terminate(0)")
19 self.fExit.SetCommand(
'TPython::Exec( "raise SystemExit" )')
20 self.fHor1.AddFrame(self.fExit, ROOT.TGLayoutHints(
21 ROOT.kLHintsTop | ROOT.kLHintsLeft | ROOT.kLHintsExpandX, 4, 4, 4, 4))
22 self.AddFrame(self.fHor1, ROOT.TGLayoutHints(ROOT.kLHintsBottom | ROOT.kLHintsRight, 2, 2, 5, 1))
24 self.fNumber = ROOT.TGNumberEntry(self, 0, 9, 999, ROOT.TGNumberFormat.kNESInteger,
25 ROOT.TGNumberFormat.kNEANonNegative,
26 ROOT.TGNumberFormat.kNELLimitMinMax,
28 self.fLabelDispatch = ROOT.TPyDispatcher(self.DoSetlabel)
29 self.fNumber.Connect(
"ValueSet(Long_t)",
"TPyDispatcher", self.fLabelDispatch,
"Dispatch()")
30 self.fNumber.GetNumberEntry().Connect(
"ReturnPressed()",
"TPyDispatcher", self.fLabelDispatch,
"Dispatch()")
31 self.AddFrame(self.fNumber, ROOT.TGLayoutHints(ROOT.kLHintsTop | ROOT.kLHintsLeft, 5, 5, 5, 5))
32 self.fGframe = ROOT.TGGroupFrame(self,
"Value")
33 self.fLabel = ROOT.TGLabel(self.fGframe,
"No input.")
34 self.fGframe.AddFrame(self.fLabel, ROOT.TGLayoutHints(ROOT.kLHintsTop | ROOT.kLHintsLeft, 5, 5, 5, 5))
35 self.AddFrame(self.fGframe, ROOT.TGLayoutHints(ROOT.kLHintsExpandX, 2, 2, 1, 1))
37 self.SetCleanup(ROOT.kDeepCleanup)
38 self.SetWindowName(
"Number Entry")
40 self.Resize(self.GetDefaultSize())
47 self.fLabel.SetText(ROOT.Form(
"%d" % self.fNumber.GetNumberEntry().GetIntNumber()))
51if __name__ ==
"__main__":
52 window = pMyMainFrame(ROOT.gClient.GetRoot(), 50, 50)