in reply to string alignment

If the listbox is using a proportional font, then sprintf alignment (which is based on equal width characters) will not do the job.

Three possibilities:

  1. Set the font in the listbox to a fixed pitch font.
  2. Investigate the font metrics tools available in the toolkit you are using.

    Eg. If you are using Tk, take a look at $widget->fontMeasure(font, text).

  3. Use a more sophisticated widget setup.

    Eg. use a Tk::Table (or equivalent for your toolkit).


With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.

The start of some sanity?