How can I put linux command result on a canvas or GUI?

Hello, Rooters

I’m trying to make a small GUI using TControlBar & Addbutton function.
If I want to put a linux commnd result (let’s say, something like “date”)
on a canvas, what should I do? For example, In root tutorial, there is demos.C in which first button(“Help on Demos”) makes a canvas showing some infos.
I want to show the result of “date” command on it.

After some struggling, I came up with something like below without success(date.C : this is the content of a macro to be run when I click a button named “date”):
char date = gSystem->Exec(“date”);
date = new TPaveText(.1,.8,.9,.97)

Could you help me to fix this one?
Another small question, How can I change the size of the buttons of TControBar frame?

bar = new TControlBar(“vertical”, “Date GUI example”, 400,400);

In this example I found changing 400 didn’t help.
Could anyone have any idea how to solve these problems?
Thank you!


Hi Jin,

To display the date on the canvas you can use TStyle::SetOptDate method (see for more details at … SetOptDate )

The TControlBar constructor you have used: bar = new TControlBar("vertical", "Date GUI example", 400,400); will move the control bar to the specified position (x,y) on your screen. All buttons will have default height and width based on the largest assigned text label.

I can add the possibility for setting the width of the TControlBar. The height will be according to the number of buttons you have created.

Cheers, Ilka

Hi Jin,

A new method SetButtonWidth(UInt_t buttonWidth) for setting the button width in pixels is available in CVS head. Invoke this method before calling the TControlbar::Show() if you want to specify the button width for all control bar buttons. For example:bar->SetButtonWidth(90); bar->Show(); will set the button width to 90 pixels for all control bar buttons.

Best regards, Ilka