Displaying a table in a TCanvas

Hello,

I have a very naive question. I would like to display a simple table in a graphical window (TCanvas?) with values(variables) used in a pyroot script.

By “table”, I do not mean a python structure but simply a “table”, just like this for example:
root.cern.ch/root/html/MACRO_TGT … ame384.gif

I tried to search in the site and the forum but given the multiple senses of “table”, it is not that easy. The TGTable seems to a solution but I did not find any simple example.

Please note that I do not want any interactive facilities, just a simple table to be saved in a picture file. Any simple solution in python may be also welcome.

Many thanks for your help,

Benjamin Trocmé
Atlas Grenoble

Is it a TTree you need to visualize that way ?
The is nothing to draw a table in a TCanvas.
You can draw an 2d histogram with the option TEXT…
Although if the tables you want to display are as small at the one you posted it should not be difficult to make a small macro drawing them…

Hello,
Thanks for your answer.
I indeed just want to display several quantities retrieved from different sources (run number, efficiencies, lumi…).
I do agree that writing a small macro should not be complicated; I was asking just in case of something already exists (there are so many useful things in root!).
Best regards

Yes what you want is quite specific. May be a TPaveText can help you because then you will not need to position the text yourself.
root.cern.ch/root/html/TPaveText.html

1 Like

Many thanks for the tip, it was very useful and it worked nicely.

I have been facing a last problem: I had created one TPaveText per column but with the default, the text sizes are different for each column and when trying to change it with a SetTextSize in the script, pyroot seems to be frozen.
Searching in the forum, I found a statement according to which the size can not be changed. Is it really the case? I am a little bit surprised, as it is easily feasible by changing interactively the text attributes in the Canvas.

Regards

The all idea of TPaveText is to avoid dealing with text size and text positioning.
You define a box and put some text in. TPaveText does all the adjustments to make the texts fit inside the box. That’s all automatic.

Hi,

Thanks for clarification. With a little bit of tuning, I managed to et a nice table as I imagined it.

Have a nice evening,

Benjamin

Nice :slight_smile: have a good evening