Skip to content Skip to sidebar Skip to footer

How Do I Make Data Orderly On The Message Box? Python-tkinter

My current goal is to display data onto a message box. As this picture shows, the data is all over the place, but if I send it to Excel it looks perfectly fine whereas the message

Solution 1:

I have good experience using pandas with tabulate and then inserting in Tkinter window with tkinterhtml.

You have "stralign" and "numalign" in tabulate and even "floatfmt" for all sorts of formats and alignment while creating tables.

example for usage:

from tabulate import tabulate
from tkinterhtml importHtmlFrame

html = tabulate(df, 
                headers='keys',
                floatfmt=",.1f", tablefmt='html',
                numalign='center', stralign='center')
top = tk.Toplevel()
hf = HtmlFrame(top)
hf.pack()
hf.set_content(html)

Post a Comment for "How Do I Make Data Orderly On The Message Box? Python-tkinter"