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
  align frame inside canvas ro_btz 1 110 Sep-11-2020, 04:38 PM
Last Post: Larz60+
  [Kivy] Kivy text label won't shows up! AVD_01 1 517 Jun-21-2020, 04:01 PM
Last Post: AVD_01
  [Tkinter] Python 3 change label text gw1500se 6 969 May-08-2020, 05:47 PM
Last Post: deanhystad
  [Tkinter] how to update label text from list Roshan 8 593 Apr-25-2020, 08:04 AM
Last Post: Roshan
  [Tkinter] Align the width of the entrys with the column captions Particledust 0 222 Apr-23-2020, 08:32 AM
Last Post: Particledust
  [PyQt] Python PyQt5 - Change label text dynamically based on user Input ppel123 1 1,512 Mar-20-2020, 07:21 AM
Last Post: deanhystad
  Make Label Text background (default color) transparent using tkinter in python barry76 1 7,931 Nov-28-2019, 10:19 AM
Last Post: Larz60+
  Update a label text from subprocess jim53 3 1,299 Aug-19-2019, 08:21 PM
Last Post: Denni
  Unable to update or refresh label text in tkinter jenkins43 3 2,441 Jul-24-2019, 02:09 PM
Last Post: Friend
  [Tkinter] Having trouble updating the text in a label microphone_head 3 893 May-02-2019, 08:44 AM
Last Post: microphone_head

Forum Jump:

Users browsing this thread: 1 Guest(s)