Re: [ROOT] Help with GUI elements

From: Andreas Zoglauer (zog@mpe.mpg.de)
Date: Thu Aug 30 2001 - 18:19:03 MEST


On Thu, 30 Aug 2001, Chris Milne wrote:

> Hi there,
>
> I have the following function which produces a TGTransientFrame with a
> TGPictureButton in it. I would like to add a small area below the Picture button
> in which I can add text.
>
> The TGTransientFrame is display whilst some calculations occur in the background
> and I'd like to output what is going on at the bottom, ie. "Loading file xxx"
> etc.


Hi,

The following example is a root macro, which displays an icon (the picture
is from $ROOTSYS/icons) and a text label below.

The label is updated all 200 ms.


-------------------------------------------------------------------------
{
Char_t Text[10];

TGTransientFrame *fMain;

TGIcon *Icon;
TGPicture *IconPicture;
TGLayoutHints *IconLayout;
TGLayoutHints *LabelLayout;

TGLabel *Label;

// Initialize main frame;
fMain = new TGTransientFrame(gClient->GetRoot(),
                             gClient->GetRoot(), 320, 240);
fMain->SetWindowName("Countdown...");
fMain->Move(320, 240);

// Add Icon:
TString IconString("$(ROOTSYS)/icons/root_s.xpm");
gSystem->ExpandPathName(IconString);
IconPicture = gClient->GetPicture(IconString);
Icon = new TGIcon(fMain, IconPicture,
                  IconPicture->GetWidth(),
                  IconPicture->GetHeight());
IconLayout = new TGLayoutHints(kLHintsCenterX, 0, 0, 50, 10);
fMain->AddFrame(Icon, IconLayout);

// Add Label:
Label = new TGLabel(fMain, "Starting countdown...");
LabelLayout = new TGLayoutHints(kLHintsCenterX, 0, 0, 10, 50);
fMain->AddFrame(Label, LabelLayout);

// Bring everything to the screen
fMain->MapSubwindows();
fMain->MapWindow();
fMain->Layout();


// Update the Label periodically
gSystem->ProcessEvents();

for (Int_t i = 60; i > 0; i--) {
  sprintf(Text, "%i", i);
  Label->SetText(Text);
  gSystem->ProcessEvents();
  gSystem->Sleep(200);
}

Label->SetText("Liftoff!");
}
-------------------------------------------------------------------------


Hope this helps,

Andreas



This archive was generated by hypermail 2b29 : Tue Jan 01 2002 - 17:50:59 MET