Bottom Page

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 [Tkinter] Label, align imported text from pandas

this is my first Python code ever and I'm stuck with imported text alignment. The idea is to load material list from excel sheet into "label". Text has to be clearly visible. I'm using Python 3.8.

"print" command gives aligned table and it looks good:
Column1 Column2 Column3 0 Material blue 2.50 1 1 Material red 1.05 1 2 Profile No.5 0.75 3 3 Material green 11.40 1 4 Profile No.1 2.50 1
But table loaded into "label" looks terrible:

Does anyone have any suggestions how to solve this problem.

My code:
import tkinter as tk
import pandas as pd

HEIGHT = 500
WIDTH = 600

def final_data(df):
    return df

def onReturn(event=None):
    entry.delete(0, 'end')

def sheet_no(entry):
    df = pd.read_excel(open('C:\\Users\\gamybvadas\\Desktop\\Python_apps\\uno.xlsx', 'rb'), sheet_name=entry)
    label['text'] = final_data(df)
final_info = lambda: sheet_no(entry.get())

root = tk.Tk()

root.bind('<Return>', lambda event: sheet_no(entry.get()))

canvas = tk.Canvas(root, height=HEIGHT, width=WIDTH)

frame = tk.Frame(root, bg='black', bd=1), rely=0.1, relwidth=0.75, relheight=0.1, anchor='n')

entry = tk.Entry(frame, font="Calibri 25"), relheight=1)

button = tk.Button(frame, text="Load", font=40), relheight=1, relwidth=0.2)
button.config(command= final_info)

lower_frame = tk.Frame(root, bg='black', bd=1), rely=0.25, relwidth=0.75, relheight=0.6, anchor='n')

label = tk.Label(lower_frame, font="Calibri 15", anchor='nw', justify='left'), relheight=1)

the Text widget-here
instead of a label
So simple.. Blush
Thank You very much joe_momma!

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  Make Label Text background (default color) transparent using tkinter in python barry76 1 2,098 Nov-28-2019, 10:19 AM
Last Post: Larz60+
  Update a label text from subprocess jim53 3 698 Aug-19-2019, 08:21 PM
Last Post: Denni
  Unable to update or refresh label text in tkinter jenkins43 3 1,203 Jul-24-2019, 02:09 PM
Last Post: Friend
  [Tkinter] Having trouble updating the text in a label microphone_head 3 584 May-02-2019, 08:44 AM
Last Post: microphone_head
  Display and update the label text which display the serial value jenkins43 5 1,980 Feb-04-2019, 04:36 AM
Last Post: Larz60+
  [WxPython] bind label and entry text with return key metulburr 1 913 Aug-14-2018, 10:02 PM
Last Post: metulburr
  How to change the text in label? ;/ Dzonzi 3 12,934 Jul-18-2018, 07:26 PM
Last Post: nilamo
  [PyQt] Assign Label Text as number in Hz mekha 17 2,712 Jul-18-2018, 12:47 AM
Last Post: mekha
  [Kivy] AttributeError setting the label text gio123 3 2,061 Mar-15-2018, 09:30 AM
Last Post: buran
  [Tkinter] Problem with changing label text on button press xk2006x 1 3,127 Jun-02-2017, 06:00 PM
Last Post: nilamo

Forum Jump:

Users browsing this thread: 1 Guest(s)