I have a GUI with a splitted panel, where the left panel shows a Checkbox-list of words from a txt-file. In the class createLeftPanel I manage to add and delete words from the txtfile and then update the GUI to show the added elements and where the deleted elements are removed. Deletion is done by selecting one or more checkboxes and pushing a delete button and adding is done by a TextCtrl and an Add button.
However, the right panel contains a notebook, and in one of these tabs I also add words to the txtfile. However, I also want to update the left panel, so that the change in the txt-file is changed in the GUI. I have tried a wx.GetApp().GetTopWindow().leftPanel.Layout() but that does not work. I tried to call wx.GetApp().GetTopWindow().leftPanel.__init__() but I need to specify the parent of the leftpanel again...
Help is appreciated! Below is sections from the MainFrame of the program and pseudocode/code from the createLeftPanel class...
class MainFrame(wx.Frame):
def __init__(self, parent=None, id=-1, pos=wx.DefaultPosition,
title=_('Program name here')):
wx.Frame.__init__(self, parent, id, title, pos, (1100, 600))
#Creating Menu and Statusbar:
self.createMenuBar()
self.statusbar = self.CreateStatusBar()
#Creating the splitter with two panels
self.initpos = 245
self.splitter = wx.SplitterWindow(self)
self.leftPanel = wx.Panel(self.splitter, style = wx.SP_3D)
self.rightPanel = wx.Panel(self.splitter, style = wx.SP_3D)
self.leftPanel.SetBackgroundColour('White')
self.rightPanel.SetBackgroundColour('White')
self.splitter.Initialize(self.leftPanel)
self.splitter.Initialize(self.rightPanel)
self.splitter.SetMinimumPaneSize(100)
self.splitter.SplitVertically(self.leftPanel, self.rightPanel, self.initpos)
#Leftpanel
createLeftPanel(self.leftPanel)
#Rightpanel contains a notebook
createNotebook(self.rightPanel)
self.leftPanel.Fit()
self.rightPanel.Fit()
self.Centre()
self.Layout()
class createLeftPanel(wx.Panel):
def __init__(self, parent):
wx.Panel.__init__(self, parent)
#Initialization
self.SetBackgroundColour('White')
self.filename = Settings().defaultFileName
initList = Project(self.filename).readProject()
#Boxes
self.mainbox = wx.BoxSizer(wx.VERTICAL)
try:
self.RemoveListSizer() #If exist: detach/destroy the ListSizer
except:
pass
self.listSizer = self.MakeListSizer(initList)
#Adding everything to mainbox
self.mainbox.Add(self.listSizer, 0, wx.RIGHT | wx.LEFT, 3)
self.mainbox.Fit(self)
self.SetSizer(self.mainbox)
self.Layout()
def OnDelete(self, event):
#If deletebutton is pressed, one or several elements is added to file,
#GUI is updated by calling RemoveListSizer and then the MakeListSizer is called based on a new list read from the file
def OnAdd(self, event):
#If addbutton is pressed, a new element is added to file,
#GUI is updated by calling RemoveListSizer and then the MakeListSizer is called based on a new list read from the file
def RemoveListSizer(self):
def MakeListSizer(self, inputList):