1

This is my code. As you can see bellow I am trying to display small data in Treeview. But I don't know how can i change the width of the first column without a name that represents index in pandas dataframe. Also showing in img how it looks in app.

import pandas as pd
from tkinter import *
from tkinter import ttk

df = pd.read_csv("Employees_data", index_col=0)

root = Tk()
root. geometry("760x450")

tree1 = ttk.Treeview(root)
tree1.pack()
tree1['columns'] = df.columns.values.tolist()

for i in df.columns.values.tolist():
    tree1.column(i, width=50)
    tree1.heading(i, text=i)
for index, row in df.iterrows():
    tree1.insert("", 'end', text=index, values=list(row))
print(df.iterrows())

root.mainloop()
      Name  work hours     specialization
1    Zosia          12  Pracownik biurowy
2   Maciek           7  Pracownik biurowy
3   Jakcek          10         Sprzątanie
4  Ryszard          10         Magazynier
5  Mateusz          14         Magazynier

enter image description here

1 Answer 1

1

Try access to first column via name '#0'. This works for me:

tree.column('#0', width = 80, anchor="w")
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.