Tkinter Listbox string formatting question - how to kill a dancingsnake ?

H

Hendrik van Rooyen

I am populating a listbox from a directory that looks like this:

variable_dict = {"funny_long_or_short_variable_name_as_key": (2,45),......

the tuple represents a "card, line" pair.
medf is a font object and a forward reference here.

I write:

for x in variable_dict:
txt = x
while medf.measure(txt) < 350:
txt = txt + ' '
txt = txt + str(variable_dict[x])

and I use the txt string to populate the list box.

At first glance, it seems to work, as the names are on the left, and the tuples
are in a column...

But if you scroll the listbox, the inherent error makes it appear as if the
tuple column is a snake doing the twist.

I tried using a tab but got a backslash - t in the text, and simply counting
spaces is worse than useless.

Is there a way to format this so it will line up with *any* font ?

I would prefer not to give up and use a fixed width font - it looks so
teletypish...

A blank char of one pixel width would sort this nicely - but as the hilbilly
said when he first saw a rhinoceros: " There aint no such animal! " - or is
there?

- Hendrik
 

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,769
Messages
2,569,582
Members
45,066
Latest member
VytoKetoReviews

Latest Threads

Top