Jonh Smith
Jonh Smith

Reputation: 65

Tkinter listbox not displaying expected string

Here is my question:

Im adding a string to a listbox created using two other strings. This is all taking place in a loop. Simplified code looks like this :

 a = "some string"
 b = "some other string"
 mystring = a.ljust(Some_Number) + " " + b
 print(mystring)
 myListbox.insert(myindex,mystring)

I would like to have something that looks like this in my listbox :

"dfasdfsdf             dfsd"
"sdfsdf                adfsdsfsaf"
"sd                    adfsdf"

Basically the second string always starting at the same index(Some_number + " "). When I print it in the command prompt i get exactly what i want but in the Listbox the spacing is not the same and all over the place. Any thoughts why this happens and how to fix it?

Thanks for any help.

Upvotes: 0

Views: 215

Answers (1)

Jonh Smith
Jonh Smith

Reputation: 65

mylistbox=tk.Listbox(myframe,font="TkFixedFont")

Hey guys the line of code above when initializing the listbox fixed my problem it was indeed a fixed width font problem, bit of a silly question... Thanks for all the help.

Upvotes: 1

Related Questions