Wie kommen denn in die CSV Leerzeichen?
Komisch Formatiert?
Ich bin immer noch der Meinung, das Listbox hier falsch ist und treeview mehr sinn macht wegen der rows und columns.
Hab ich dir mal schnell gebastelt.
import tkinter as tk
from tkinter import ttk
import csv
# Create the main window
root = tk.Tk()
root.title("CSV Data Display")
# Create a Treeview widget
tree = ttk.Treeview(root, columns=("ID", "Date", "Description", "Type", "RepeatInterval", "RepeatFrom", "RepeatEndDate",
"Amount", "RGBA", "UseGroupColor", "Group", "GroupName", "GroupDescription", "GroupRGBA"))
# Set headings
tree.heading("#1", text="ID")
tree.heading("#2", text="Date")
tree.heading("#3", text="Description")
tree.heading("#4", text="Type")
tree.heading("#5", text="RepeatInterval")
tree.heading("#6", text="RepeatFrom")
tree.heading("#7", text="RepeatEndDate")
tree.heading("#8", text="Amount")
tree.heading("#9", text="RGBA")
tree.heading("#10", text="UseGroupColor")
tree.heading("#11", text="Group")
tree.heading("#12", text="GroupName")
tree.heading("#13", text="GroupDescription")
tree.heading("#14", text="GroupRGBA")
# Set column widths
tree.column("#1", width=50)
tree.column("#2", width=80)
tree.column("#3", width=150)
tree.column("#4", width=50)
tree.column("#5", width=100)
tree.column("#6", width=80)
tree.column("#7", width=100)
tree.column("#8", width=80)
tree.column("#9", width=80)
tree.column("#10", width=100)
tree.column("#11", width=80)
tree.column("#12", width=100)
tree.column("#13", width=150)
tree.column("#14", width=80)
# Read data from the CSV file and insert it into the Treeview
with open("denaro.csv", newline="") as csvfile:
csvreader = csv.reader(csvfile, delimiter=";")
next(csvreader) # Skip the header row
for row in csvreader:
tree.insert("", "end", values=row)
# Pack the Treeview widget
tree.pack()
# Start the main loop
root.mainloop()
Alles anzeigen