Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
TreeView column headers
#1
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

# 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()
Reply


Messages In This Thread
TreeView column headers - by TWB - Jan-28-2023, 09:18 PM
RE: TreeView column headers - by BashBedlam - Jan-29-2023, 04:19 AM
RE: TreeView column headers - by TWB - Jan-29-2023, 02:13 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  How to store columns of a .csv in variables (when the .csv has no headers) ? hobbyist 6 1,372 Aug-18-2023, 02:06 PM
Last Post: deanhystad
  export sql table to csv using BCP with headers mg24 0 746 Jan-19-2023, 05:36 AM
Last Post: mg24
  Code changing rder of headers Led_Zeppelin 0 932 Jul-13-2022, 05:38 PM
Last Post: Led_Zeppelin
  Request Headers (scheme) JohnnyCoffee 0 1,945 Mar-31-2021, 09:17 PM
Last Post: JohnnyCoffee
  Reading csv with multiple "headers" Clives 3 2,567 Dec-31-2020, 09:25 AM
Last Post: Ana_junior
  Code snippets for building multi column Listviews and or Treeview KevinBrown 3 3,352 Apr-14-2019, 06:50 PM
Last Post: Yoriz

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020