TGListBox entry formatting

Dear ROOTers

I’ve got a problem recently with a nice table like presentation of a text written into a TGListBox by entries.

It looks like the strings that make a TextEntry get reformatted somewhere on fly. So a string by string printout to standard output does look like a nice table, but a TGListBox view is completley not table like.

How do I make it look more like a table? so that a horisontal position of a new colomn would stay same for every single row.

thanks in advance for any usefull comments and help
Igor

Hi Igor,

Please provide a simple macro as an example that shows the problem. For me it is not clear why do you need to use a TGListBox for a table view…

Thank you, Ilka

it’s not easy to provide a code. but i’ll try

the thing is in this loop over rows in the table:

char buf[100];

for (l=0;l<nl;l++) {
if (cnt[l] < 0) continue;
Float_t ctzsz=((Float_t) cnt[l]/( zipsz/100.));
Float_t cttsz=((Float_t) cnt1[l]/( totsz/100.));
Float_t ctfsz=((Float_t) cnt2[l]/( tot_2/100.));
sprintf(buf," %-20s %20d (%5.2f) %20d (%5.2f) %20d (%5.2f)",br->GetName(),cnt[l],ctzsz,cnt1[l],cttsz,cnt2[l],ctfsz);
fRunEventSource->AddEntry(buf,10+l);
cerr << buf << endl;
}

and buf from cerr is a nice table
but the buf in TGListBox is not a nice table :frowning:(

there was some reason to use TGListBox, but since it did not work
I changed to TGTextEdit, which I can not make uneditable :frowning:
so it’s not perfect either

Hi Igor,

Please provide a running macro - there are many unknown variables in the provided code above.

Thank you, Ilka

[quote=“rubinsky”]Dear ROOTers

I’ve got a problem recently with a nice table like presentation of a text written into a TGListBox by entries.

It looks like the strings that make a TextEntry get reformatted somewhere on fly. So a string by string printout to standard output does look like a nice table, but a TGListBox view is completley not table like.

How do I make it look more like a table? so that a horisontal position of a new colomn would stay same for every single row.

thanks in advance for any usefull comments and help
Igor[/quote]

You should use Courier-like font with the fixed width glyph. You should avoid the proporsional fonts becuase each letter there has its own width. The gaps between letter are different also.

Hope this helps

[quote=“fine”][quote=“rubinsky”]Dear ROOTers

I’ve got a problem recently with a nice table like presentation of a text written into a TGListBox by entries.

It looks like the strings that make a TextEntry get reformatted somewhere on fly. So a string by string printout to standard output does look like a nice table, but a TGListBox view is completley not table like.

How do I make it look more like a table? so that a horisontal position of a new colomn would stay same for every single row.

thanks in advance for any usefull comments and help
Igor[/quote]

You should use Courier-like font with the fixed width glyph. You should avoid the proporsional fonts becuase each letter there has its own width. The gaps between letter are different also.

Hope this helps[/quote]

Thanks!
but how do I access the font settings for TGListBox? :blush:
Igor

Hi Igor,

There are two ways to change the font in TGListBox. The faster one is to change the default setting of the GUI default font in your local .rootrc file. For example, to:Gui.DefaultFont: -adobe-courier-medium-r-*-*-12-*-*-*-*-*-iso8859-1
This setting will affect all GUI elements that use the default font (labels, list boxes, combo boxes, etc.). If you want to change the font explicitly for one list box only, please see the attached macro as an example.

With thanks for your patience,
Ilka
lbtext.C (2.68 KB)