I am writing a Tkinter program. The main class is MainFrame()
class MainFrame(Frame):
def __init__(self, master=None):
Frame.__init__(self, master)
self.grid()
# sets up the tab bar
self.tabbar = TabBar(self, 'File Tabe Bar')
self.tabs = []
self.add_tab(self.tabbar, 'Hello Tab') # add a new tab to self.tabs
self.tabbar.pack() # make it visible
def add_tab(self, parent, name='Default'):
tab = Tab(parent, name)
self.tabs.append(tab)
Will each of the tab variable created by invoking add_tab persist throughout the life time of the main frame (until it is destroyed)? Thanks.
Each variable is bind to an object
Tab. EachTabhas a parent. The variable local to the function will be gone once the function exists – that is, the binding is lost, but you have the reference to the objectTab(each of them) in the listself.tabswhich persist throughout the life time of the objectMyFrame.Each object
Tabwill live until the parent class (and / or the parents of the parent class) are destroyed (or by invoking a destroy method onTab)Just my wild guess ::(