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

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Hendrik van Rooyen

    #1

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

    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(tx t) < 350:
    txt = txt + ' '
    txt = txt + str(variable_di ct[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

Working...