Jan-28-2023, 09:18 PM
Hello all
I have posted a code section of a larger program where im trying to populate a a treeview with 2 columns and inset 2 values.
My issue is the treeview will show but the 2 column headers will not display as well as the 2 values.
thank you for any direction
I have posted a code section of a larger program where im trying to populate a a treeview with 2 columns and inset 2 values.
My issue is the treeview will show but the 2 column headers will not display as well as the 2 values.
thank you for any direction
# Introduction to Python Programming
from tkinter import *
import shelve
from tkinter import ttk
class MyFrame (Frame):
def __init__(self):
Frame.__init__(self)
self.master.geometry("600x600")
self.master.title("Student Scores")
self.grid()
#Create and define a TreeView
columns = ("student", "score")
self.treeview = ttk.Treeview(self, columns = columns, show = "headings")
self.treeview.column("student",anchor=CENTER, stretch=NO, width=20)
self.treeview.heading("student", text="Student")
self.treeview.column("score",anchor=CENTER, stretch=NO, width=20)
self.treeview.heading("score", text="Score")
self.treeview = ttk.Treeview(self, height = 15)
self.treeview.grid(padx = 50, pady = 50)
#insert values to column
self.treeview.insert('', 'end', text="Student", values=('Jon', '99'))
asn_frame = MyFrame()
asn_frame.mainloop()
