Cannot insert data from one frame into a treeview in another frame

31 views Asked by At

I try to use data from my ProfilePage class as data in the plans_table which is a treeview in my PlanningPage class but insert() doesnt insert the data into the treeview.

class ProfilePage(PlanningPage, ttk.Frame ):
    def __init__(self, parent, controller,): 
        PlanningPage.__init__(self, parent, controller,style='PlanningPage.TFrame')
        ttk.Frame.__init__(self, parent,)

        def update_treeview():
                    for row in AppData.data:
                        self.plans_table.insert("", "end", values=row)
                

class PlanningPage(ttk.Frame):
    def __init__(self, parent, controller, style): 
        ttk.Frame.__init__(self, parent)
        self.root = tkinterApp
        self.plans_table = ttk.Treeview(self, columns=("Date Created", "Weight to Lose", "Type", "Daily Calories Needed", "Completion Date"), show="headings")
        self.plans_table.pack(pady=20, padx=(self.winfo_screenwidth() * 1 / 5) / 2)  

        self.plans_table.heading("Date Created", text="Date Created")
        self.plans_table.heading("Weight to Lose", text="Weight to Lose")
        self.plans_table.heading("Type", text="Type")
        self.plans_table.heading("Daily Calories Needed", text="Daily Calories Needed Per Day")
        self.plans_table.heading("Completion Date", text="Completion Date")


        self.plans_table.column("Date Created", width=150)
        self.plans_table.column("Weight to Lose", width=100)
        self.plans_table.column("Type", width=100)
        self.plans_table.column("Completion Date", width=150)
        self.plans_table.column("Daily Calories Needed", width=150)

        rel_width_plans_table = 3 / 5
        self.plans_table.place(relx=0.5, rely=0.5, anchor=tk.CENTER, relwidth=rel_width_plans_table)
0

There are 0 answers