TGTextEntry or other inputbox/textbox example


I’m a beginning ROOT user, and I need to be able to input numbers or text into three different input boxes, and after pressing a button calling a method using the data from the input boxes as parameters.

Any examples using TGTextEntry that I’ve been able to find have either been incomplete (for example didn’t really describe TGTextEntry at all) or very involved/convoluted.

Could someone please direct me to a simple example using TGTextEntry or something similar?

Thank you very much,

PS: On a completely unrelated note, I have 2 simple little questions:

  1. Does root have a toString function/method that I can use to convert integrers/floats/doubles/etc into strings? (Say TString objects)
  2. Is it possible to run a macro from another macro? That is, how can I do something like this at the root prompt: {… .x macroBlah …} ?

Hi Mikhail,

The macro $ROOTSYS/tutorials/guitest.C contains examples of TGTextEntry and TGNumberEntry widgets. My impression is that you might need to use TGNumberEntry or TGNumberEntryField.

The TGNumberEntry class present number entry widgets Its purpose is to make a selection by either scrolling through a small set of meaningful predefined choices or typing numbers. The TGNumberFormat class contains enum types to specify the numeric format. The number entry widget is based on TGTextEntry, but it allows only numerical input. The widget supports numerous formats including integers, hex numbers, real numbers, fixed fraction real and time/date formats. It also allows to restrict input values to non-negative or positive numbers and to specify explicit limits.

fN1 = new TGNumberEntry(parent, 0.005, 9, kENTRY1, TGNumberFormat::kNESRealThree, //style TGNumberFormat::kNEAAnyNumber, //input value filter TGNumberFormat::kNELLimitMinMax, //specify limits -1.,1.); parent->AddFrame(fN1, new TGLayoutHints(...);TGNumberEntryField is an input widget as TGTextEntry, but allows only numeric values. It has no spin buttons. Its constructor is slightly different:Nent = new TGNumberEntryField(hgrunf2, kNENT_ID, 0.6, TGNumberFormat::kNESRealThree, TGNumberFormat::kNEAAnyNumber); hgrunf2->AddFrane(Nent, ...);

About your additional question: you can use the ProcessLine() method of TROOT or TMacro class. Please see for more details at … rocessLine
I have updated the GUI chapter of User’s Guide with information about TGTextEntry, TGNumberEntry, TGNumberEntyField and some other classes. The new edition will be available on the web next week.
Cheers, Ilka

About your PS, you can do, eg:

Root [1] TString s="hello I am " Root [2] s (class TString)"hello I am " Root [3] s+=35 (class TString)"hello I am 35" Root [4] TString s2=Form("pi = %g",TMath::Pi()) Root [5] s2 (class TString)"pi = 3.14159"