Good day Paul
I hope I am doing this correctly. If not, let me know and I will try again.
Basically I want to display, on the screen, a list a list of data defined by the columns I have chosen. I would like to have the rows highlighted for easy of reading.
If you run the script as I have sent you will notice that the data is displayed correctly but without the highlighting the rows. You will also notice that the last few rows
contain the headings, one after the other and beautifully highlighted, which is quite sad really as this is not meant to happen..
If you ignore from line 56 to 70 you will notice that it displays the data correctly without adding the heading at the bottom but still no highlighting.
I have been scratching my head for way too long and am reaching out you for some guidance, if not a solution.
I have also attached the .xlsx and .py files.
All the print statements are to help me keep track of where I have been and done. Fat lot of help that has been.
import pandas as pd
import tkinter as tk
from tkinter import ttk
from openpyxl import load_workbook
from openpyxl.styles import Border, Side
from datetime import datetime
root1 = tk.Tk()
root1.geometry(‘590x900’)
root1.title(‘Jobs for Router department.’)
#Add Style
style = ttk.Style()
##Pick a themestyle.theme_use(‘default’)
1. Load the relevant colomns from the Excel file
path = “C:\Users\Stuart\Documents\Python stuff\info.xlsx”
wb = load_workbook(‘info.xlsx’)
ws = wb[‘Sheet1’]
df = pd.read_excel(‘info.xlsx’, usecols=[0, 1, 2, 3, 8, 15])
df = df.fillna(‘’)
df = df[1:]
print(‘Step 1’)
print(df)
setup treeview
columns = (‘Doc No’, ‘Order Number’, ‘Customer’, ‘Date’, ‘Router’, ‘Complete’)
tree = ttk.Treeview(root1, columns = columns, show = ‘headings’, height = 80)
#tree = ttk.Treeview(root1, columns = columns, height = 80)
#tree = ttk.Treeview(root1, show = “headings”, height = 20)
#tree = ttk.Treeview(root1, show=“headings”)
c = 0
print(‘Step 2’)
for col in df.columns:
tree.heading(col, text=col)
tree.column(col, width=100)
c +=1
print('Col ’ + str(c))
d = 0
for index, row in df.iterrows():
tree.insert(“”, “end”, values=list(row))
d += 1
#tree.pack(expand=True, fill=‘both’)
#tree.pack()
print(‘Step 3’)
print('Row ’ + str(d))
Set up striped effect, Light blue for even numbers and white for odd numbers
global row_count
row_count = 0
tree.tag_configure(‘oddrow’, background = ‘white’)
tree.tag_configure(‘evenrow’, background = ‘lightblue’)
print(df)
(Attachment send-away.py is missing)
(Attachment info.xlsx is missing)