0

I am outputting a list of data in various labels inside my tkinter window. My problem is that I want to space out the data in columns but when outputting the data, it is skewed and out of place, even when using ljust. It appears that the characters are all different in size therefore ljust doesn't work.

I'm wondering if there is any way to change the actual width of the characters so that they can all be the same size, maybe if there is a font with equal sized characters that anybody knows about ?

David Buck
  • 3,752
  • 35
  • 31
  • 35
kylebotha
  • 25
  • 5
  • Maybe this can help you? It's about min / max - width / height. [https://stackoverflow.com/a/4399545/12488560](https://stackoverflow.com/a/4399545/12488560) – JaFizz Dec 06 '19 at 12:38
  • 1
    Does this answer your question: [pretty-print-data-in-tkinter-label](https://stackoverflow.com/questions/58658656/pretty-print-data-in-tkinter-label) – stovfl Dec 06 '19 at 13:07

1 Answers1

0

This will output the names of the fonts for your system:

import sys
from   Tkinter import Tk
import tkFont
root = Tk()
fnames = list(tkFont.families())
fnames = sorted(fnames)
k = 0
for s in fnames:
    k=k+1
    sys.stdout.write(str(k)+'\t'+s+'\n')
Marichyasana
  • 2,966
  • 1
  • 19
  • 20