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 box is just not even.
How can I even out the displayed data on messagebox just to look like the excel?
Here is my code:
import tkinter as tk
import tkinter.messagebox as tm
import pandas
import datetime
def currency_rate():
dfs=pandas.read_html('https://rate.bot.com.tw/xrt?Lang=en-US')
currency=dfs[1]
currency= currency.iloc[:,0:5]
currency.columns=['currency','cash-buying','cash-selling','spot-buying','spot-selliing']
currency['currency'] =currency['currency'].str.extract('((w+))')
date=datetime.datetime.now()
result_date="Update: Date {:4}.{:02}.{:02}-Time {:02}:{:02}:{:02}".format(date.year,date.month,date.day,date.hour,date.minute,date.second)
tm.showinfo(title =str(result_date), message =str(currency))
def currency_rate_import():
dfs=pandas.read_html('https://rate.bot.com.tw/xrt?Lang=en-US')
currency=dfs[1]
currency= currency.iloc[:,0:5]
currency.columns=['currency','cash-buying','cash
selling','spot
buying','spot-selliing']
currency['currency'] =currency['currency'].str.extract('((w+))')
date=datetime.datetime.now()
currency.to_excel('Currency Rate{:4}{:02}{:02}-Daily.xlsx'.format(date.year,date.month,date.day))
my_window=tk.Tk()
btn2=tk.Button(my_window,text="Export (Excel)",font="Calibri 14",width=25,height=1,command=currency_rate_import)
btn2.pack(side=tk.BOTTOM)
btn1=tk.Button(my_window,text="Today's exchange rate",font="Calibri 14",background="yellow",width=25,height=1,command=currency_rate)
btn1.pack(side=tk.BOTTOM)
my_window.mainloop()
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…