My tk has 2 frames, each has a treeview, build from a custom treeview object. when a row in 1st frame treeview is selected, it is saved to a variable. when user switches to 2nd frame by clicking on a button, the value saved from 1st frame will be used as a condition and filter out the treeview in 2nd frame.
I built tried to build my tkinter based the class structure here: https://stackoverflow.com/a/7557028/6620144
I added a custom treeview object that is called by both frames.
main_tree_selected=None
class program(tk.Tk):
def __init__(self, *args, **kwargs):
...
for F in (mainpage, editpage):
frame = F(container, self)
.....
class mastertreeview(object):
def __init__(self, connection, sel_statement, cond_clause=None, cond_value = None)):
....
def populate_tree(self)
....
class mainpage(tk.Frame):
def __init__(self, parent, controller):
main_tree = mastertreeview(connection, sql_statement, where_clause)
switch_button = tk.Button(command=lambda: self.controller.show_frame(editpage)
....
class editpage(tk.Frame):
def __init__(self, parent, controller):
edit_tree = mastertreeview(connection, sql_statement, where_clause, cond_value)
....
I understand that both frames are setup and build at the same time, including the child widget. I was wondering whether there is a way I can call the edit_tree
treeview, and repopulate the tree when switch_button
is clicked.