0

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.

Ganton
  • 13
  • 2
  • Based on what you want, I see no advantage to using the code that you got from that other answer. That is not good code to use if you don't understand how it works. – Bryan Oakley May 23 '18 at 16:02
  • @bryan-oakley I found one of your older post that discuss how to access variable from a different class - [link](https://stackoverflow.com/a/33650527/6620144) I was wondering whether that would be applicable to my situation? – Ganton May 23 '18 at 17:14
  • If it involves this architecture, I would say no. That architecture was designed for distinct pages that are independent. While you can make it work, it's too complex for such a simple problem. – Bryan Oakley May 23 '18 at 17:32

0 Answers0