Logo ROOT   6.14/05
Reference Guide
numberEntry.py
Go to the documentation of this file.
1 ## \file
2 ## \ingroup tutorial_pyroot
3 ##
4 ## \macro_code
5 ##
6 ## \author Wim Lavrijsen
7 
8 from ROOT import *
9 
10 class pMyMainFrame( TGMainFrame ):
11  def __init__( self, parent, width, height ):
12  TGMainFrame.__init__( self, parent, width, height )
13 
14  self.fHor1 = TGHorizontalFrame( self, 60, 20, kFixedWidth )
15  self.fExit = TGTextButton( self.fHor1, "&Exit", "gApplication->Terminate(0)" )
16  self.fExit.SetCommand( 'TPython::Exec( "raise SystemExit" )' )
17  self.fHor1.AddFrame( self.fExit, TGLayoutHints( kLHintsTop | kLHintsLeft |
18  kLHintsExpandX, 4, 4, 4, 4 ) )
19  self.AddFrame( self.fHor1, TGLayoutHints( kLHintsBottom | kLHintsRight, 2, 2, 5, 1 ) )
20 
21  self.fNumber = TGNumberEntry( self, 0, 9,999, TGNumberFormat.kNESInteger,
22  TGNumberFormat.kNEANonNegative,
23  TGNumberFormat.kNELLimitMinMax,
24  0, 99999 )
25  self.fLabelDispatch = TPyDispatcher( self.DoSetlabel )
26  self.fNumber.Connect(
27  "ValueSet(Long_t)", "TPyDispatcher", self.fLabelDispatch, "Dispatch()" )
28  self.fNumber.GetNumberEntry().Connect(
29  "ReturnPressed()", "TPyDispatcher", self.fLabelDispatch, "Dispatch()" )
30  self.AddFrame( self.fNumber, TGLayoutHints( kLHintsTop | kLHintsLeft, 5, 5, 5, 5 ) )
31  self.fGframe = TGGroupFrame( self, "Value" )
32  self.fLabel = TGLabel( self.fGframe, "No input." )
33  self.fGframe.AddFrame( self.fLabel, TGLayoutHints( kLHintsTop | kLHintsLeft, 5, 5, 5, 5) )
34  self.AddFrame( self.fGframe, TGLayoutHints( kLHintsExpandX, 2, 2, 1, 1 ) )
35 
36  self.SetCleanup( kDeepCleanup )
37  self.SetWindowName( "Number Entry" )
38  self.MapSubwindows()
39  self.Resize( self.GetDefaultSize() )
40  self.MapWindow()
41 
42  def __del__( self ):
43  self.Cleanup()
44 
45  def DoSetlabel( self ):
46  self.fLabel.SetText( Form( "%d" % self.fNumber.GetNumberEntry().GetIntNumber() ) )
47  self.fGframe.Layout()
48 
49 
50 if __name__ == '__main__':
51  window = pMyMainFrame( gClient.GetRoot(), 50, 50 )
52 
char * Form(const char *fmt,...)
RooCmdArg Layout(Double_t xmin, Double_t xmax=0.99, Double_t ymin=0.95)