How to align a text of a Listbox to the right

S

Sori Schwimmer

Eric Brunel is right in that a Listbox won't provide
any builtin help for this kind of things.

Suppose you can afford a width of 10 chars. Suppose
your lines are stored in the variable Lines - a
sequence. Suppose you use a font with fixed width (the
width occupied by "i" is the same like for "m").

lBox = Listbox(parent, width=10)
for i in Lines:
if len(i) > 10:
lBox.insert(END, i[-10:])
else:
lBox.insert(END, ('%10s' % i))

For more on string formatting, check chapter 2.3.6.2
in Python's documentation.

Good luck!
Sorin Schwimmer

__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,810
Latest member
Kassie0918

Latest Threads

Top