How to update a panel

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):

Andy,

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...

You should be able to get to any widget that's been made into an attribute. So if you have something like this:

self.myCheckBox

on the left, the button on the right should still be able to call self.myCheckBox.GetValue() or whatever.

An alternative would be pubsub. You could have the left side "subscribe" to changes in the right side and update as necessary. See the following links for more info on pubsub:

http://wiki.wxpython.org/PubSub
http://www.wxpython.org/docs/api/wx.lib.pubsub-module.html

HTH

···

-------------------
Mike Driscoll

Blog: http://blog.pythonlibrary.org
Python Extension Building Network: http://www.pythonlibrary.org

Mike Driscoll skrev:

Andy,

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...

You should be able to get to any widget that's been made into an attribute. So if you have something like this:

self.myCheckBox

on the left, the button on the right should still be able to call self.myCheckBox.GetValue() or whatever.

An alternative would be pubsub. You could have the left side "subscribe" to changes in the right side and update as necessary. See the following links for more info on pubsub:

http://wiki.wxpython.org/PubSub
wxPython API Documentation — wxPython Phoenix 4.2.2 documentation

HTH

-------------------
Mike Driscoll

Well, these classes are in separate modules, so I guess they are not that easy accessible...

I will look into pubsub...

/Andy

andy wrote:

Mike Driscoll skrev:

Andy,

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...

You should be able to get to any widget that's been made into an attribute. So if you have something like this:

self.myCheckBox

on the left, the button on the right should still be able to call self.myCheckBox.GetValue() or whatever.

An alternative would be pubsub. You could have the left side "subscribe" to changes in the right side and update as necessary. See the following links for more info on pubsub:

http://wiki.wxpython.org/PubSub
wxPython API Documentation — wxPython Phoenix 4.2.2 documentation

HTH

-------------------
Mike Driscoll

Well, these classes are in separate modules, so I guess they are not that easy accessible...

I will look into pubsub...

/Andy
_________

That shouldn't matter...instead of self, use myModuleName.mycheckBox.GetValue()

Of course, without some code, it's difficult to really say.

Mike

Mike Driscoll skrev:

andy wrote:

Mike Driscoll skrev:

Andy,

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...

You should be able to get to any widget that's been made into an attribute. So if you have something like this:

self.myCheckBox

on the left, the button on the right should still be able to call self.myCheckBox.GetValue() or whatever.

An alternative would be pubsub. You could have the left side "subscribe" to changes in the right side and update as necessary. See the following links for more info on pubsub:

http://wiki.wxpython.org/PubSub
wxPython API Documentation — wxPython Phoenix 4.2.2 documentation

HTH

-------------------
Mike Driscoll

Well, these classes are in separate modules, so I guess they are not that easy accessible...

I will look into pubsub...

/Andy
_________

That shouldn't matter...instead of self, use myModuleName.mycheckBox.GetValue()

Of course, without some code, it's difficult to really say.

Mike
_______________________________________________

Here is my createLeftPanel class (adding/deleting elements from a list directly, not via a txt file). I assume this is somehow some overkill, by Detaching and Destroying to many elements. Well, it works at least.

Still, I have trouble with updating the left Panel from a right Panel.

Suggestions are welcome...

/Andy

import wx

class createLeftPanel(wx.Panel):
    def __init__(self, parent):
        wx.Panel.__init__(self, parent)

        #Initialization
        self.SetBackgroundColour('White')
        self.aList = ['alfa', 'bravo', 'ekko'] #For this testing routine only!
               #Boxes
        self.mainBox = wx.BoxSizer(wx.VERTICAL)
        self.listSizer = self.MakeListSizer(self.aList)
               #Adding 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):
        newList =
        for counter in range(0, len(self.elementList)):
            if self.elementList[counter][0].GetValue() != True:
                newList.append(self.elementList[counter][1])

        #Remove and create new listSizer
        self.RemoveListSizer()
        self.aList = newList
        self.listSizer = self.MakeListSizer(self.aList)

        #Adding to mainBox and updating layout
        self.mainBox.Add(self.listSizer, 0, wx.RIGHT | wx.LEFT, 3)
        self.mainBox.Fit(self)
        self.Layout()

    def OnAdd(self, event):
        self.aList.append(self.addText.GetValue())

        #Remove and create new listSizer
        self.RemoveListSizer()
        self.listSizer = self.MakeListSizer(self.aList)

        #Adding to mainBox and updating layout
        self.mainBox.Add(self.listSizer, 0, wx.RIGHT | wx.LEFT, 3)
        self.mainBox.Fit(self)
        self.Layout()
           def RemoveListSizer(self):
        self.sizer.Detach(self.deleteBox)
        self.sizer.Detach(self.addBox)
        self.mainBox.Detach(self.sizer)

        self.sizer.Destroy()
        self.deleteBox.Destroy()
        self.addBox.Destroy()

        for item in self.elementList:
            item[0].Destroy()
        self.elementList =

        self.deleteText.Destroy()
        self.deleteButton.Destroy()
        self.addText.Destroy()
        self.addButton.Destroy()
           def MakeListSizer(self, inputList):
        self.listBox = wx.StaticBox(self, -1, 'List')
        self.sizer = wx.StaticBoxSizer(self.listBox, wx.VERTICAL)

        self.elementList =
        for item in inputList:
            self.element = wx.CheckBox(self, -1, item, pos=wx.DefaultPosition, \
                                  size=wx.DefaultSize)
            self.elementList.append((self.element, item))
            self.sizer.Add(self.element, 0, wx.ALL, 5)

        #Delete button
        self.deleteBox = wx.BoxSizer(wx.HORIZONTAL)
        self.deleteText = wx.StaticText(self, -1, '', size=(125,-1))
        self.deleteButton = wx.Button(self, -1, 'Delete')
        self.deleteBox.Add(self.deleteText, 0, wx.ALL, 1)
        self.deleteBox.Add(self.deleteButton, 0, wx.ALL, 1)
        self.Bind(wx.EVT_BUTTON, self.OnDelete, self.deleteButton)

        #Add element + add button
        self.addBox = wx.BoxSizer(wx.HORIZONTAL)
        self.addText = wx.TextCtrl(self, -1, value='', size = (125, -1), \
                                         validator=wx.DefaultValidator)
        self.addText.SetMaxLength(12)
        self.addButton = wx.Button(self, -1, 'Add')
        self.addBox.Add(self.addText, 0, wx.ALL, 1)
        self.addBox.Add(self.addButton, 0, wx.ALL, 1)
        self.Bind(wx.EVT_BUTTON, self.OnAdd, self.addButton)
               #Add to sizer
        self.sizer.Add(self.deleteBox, 0, wx.EXPAND, 0)
        self.sizer.Add(self.addBox, 0, wx.EXPAND, 0)
        self.Fit()

        return self.sizer
   """ Testing routines for testing this module only"""
class Frame(wx.Frame):
    def __init__(self, parent):
        wx.Frame.__init__(self, parent=None, id=-1)
        self.panel = createLeftPanel(self)
        self.statusbar = self.CreateStatusBar()

class App(wx.App):
    def OnInit(self):
        wx.App.__init__(self)
        self.frame = Frame(-1)
        self.frame.Show()
        self.SetTopWindow(self.frame)
        return True

    def OnExit(self):
        pass

if __name__ == '__main__':
    app = App()
    import wx.lib.inspection
    wx.lib.inspection.InspectionTool().Show()
    app.MainLoop()

Let's simplify this:

Which widget(s) in the right panel should cause what change in which widget
in the left panel?

···

On Fri, Oct 24, 2008 at 2:41 PM, andy <postinger@start.no> wrote:

Mike Driscoll skrev:

andy wrote:

Mike Driscoll skrev:

Andy,

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...

You should be able to get to any widget that's been made into an
attribute. So if you have something like this:

self.myCheckBox

on the left, the button on the right should still be able to call
self.myCheckBox.GetValue() or whatever.

An alternative would be pubsub. You could have the left side "subscribe"
to changes in the right side and update as necessary. See the following
links for more info on pubsub:

http://wiki.wxpython.org/PubSub
wxPython API Documentation — wxPython Phoenix 4.2.2 documentation

HTH

-------------------
Mike Driscoll

Well, these classes are in separate modules, so I guess they are not that
easy accessible...

I will look into pubsub...

/Andy
_________

That shouldn't matter...instead of self, use
myModuleName.mycheckBox.GetValue()

Of course, without some code, it's difficult to really say.

Mike
_______________________________________________

Here is my createLeftPanel class (adding/deleting elements from a list
directly, not via a txt file). I assume this is somehow some overkill, by
Detaching and Destroying to many elements. Well, it works at least.

Still, I have trouble with updating the left Panel from a right Panel.

Suggestions are welcome...

/Andy

import wx

class createLeftPanel(wx.Panel):
  def __init__(self, parent):
      wx.Panel.__init__(self, parent)

      #Initialization
      self.SetBackgroundColour('White')
      self.aList = ['alfa', 'bravo', 'ekko'] #For this testing routine
only!
            #Boxes
      self.mainBox = wx.BoxSizer(wx.VERTICAL)
      self.listSizer = self.MakeListSizer(self.aList)
            #Adding 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):
      newList =
      for counter in range(0, len(self.elementList)):
          if self.elementList[counter][0].GetValue() != True:
              newList.append(self.elementList[counter][1])

      #Remove and create new listSizer
      self.RemoveListSizer()
      self.aList = newList
      self.listSizer = self.MakeListSizer(self.aList)

      #Adding to mainBox and updating layout
      self.mainBox.Add(self.listSizer, 0, wx.RIGHT | wx.LEFT, 3)
      self.mainBox.Fit(self)
      self.Layout()

  def OnAdd(self, event):
      self.aList.append(self.addText.GetValue())

      #Remove and create new listSizer
      self.RemoveListSizer()
      self.listSizer = self.MakeListSizer(self.aList)

      #Adding to mainBox and updating layout
      self.mainBox.Add(self.listSizer, 0, wx.RIGHT | wx.LEFT, 3)
      self.mainBox.Fit(self)
      self.Layout()
        def RemoveListSizer(self):
      self.sizer.Detach(self.deleteBox)
      self.sizer.Detach(self.addBox)
      self.mainBox.Detach(self.sizer)

      self.sizer.Destroy()
      self.deleteBox.Destroy()
      self.addBox.Destroy()

      for item in self.elementList:
          item[0].Destroy()
      self.elementList =

      self.deleteText.Destroy()
      self.deleteButton.Destroy()
      self.addText.Destroy()
      self.addButton.Destroy()
        def MakeListSizer(self, inputList):
      self.listBox = wx.StaticBox(self, -1, 'List')
      self.sizer = wx.StaticBoxSizer(self.listBox, wx.VERTICAL)

      self.elementList =
      for item in inputList:
          self.element = wx.CheckBox(self, -1, item, pos=wx.DefaultPosition,
\
                                size=wx.DefaultSize)
          self.elementList.append((self.element, item))
          self.sizer.Add(self.element, 0, wx.ALL, 5)

      #Delete button
      self.deleteBox = wx.BoxSizer(wx.HORIZONTAL)
      self.deleteText = wx.StaticText(self, -1, '', size=(125,-1))
      self.deleteButton = wx.Button(self, -1, 'Delete')
      self.deleteBox.Add(self.deleteText, 0, wx.ALL, 1)
      self.deleteBox.Add(self.deleteButton, 0, wx.ALL, 1)
      self.Bind(wx.EVT_BUTTON, self.OnDelete, self.deleteButton)

      #Add element + add button
      self.addBox = wx.BoxSizer(wx.HORIZONTAL)
      self.addText = wx.TextCtrl(self, -1, value='', size = (125, -1), \
                                       validator=wx.DefaultValidator)
      self.addText.SetMaxLength(12)
      self.addButton = wx.Button(self, -1, 'Add')
      self.addBox.Add(self.addText, 0, wx.ALL, 1)
      self.addBox.Add(self.addButton, 0, wx.ALL, 1)
      self.Bind(wx.EVT_BUTTON, self.OnAdd, self.addButton)
            #Add to sizer
      self.sizer.Add(self.deleteBox, 0, wx.EXPAND, 0)
      self.sizer.Add(self.addBox, 0, wx.EXPAND, 0)
      self.Fit()

      return self.sizer
""" Testing routines for testing this module only"""
class Frame(wx.Frame):
  def __init__(self, parent):
      wx.Frame.__init__(self, parent=None, id=-1)
      self.panel = createLeftPanel(self)
      self.statusbar = self.CreateStatusBar()

class App(wx.App):
  def OnInit(self):
      wx.App.__init__(self)
      self.frame = Frame(-1)
      self.frame.Show()
      self.SetTopWindow(self.frame)
      return True

  def OnExit(self):
      pass

if __name__ == '__main__':
  app = App()
  import wx.lib.inspection
  wx.lib.inspection.InspectionTool().Show()
  app.MainLoop()

C M skrev:

  

Mike Driscoll skrev:
    

andy wrote:
      

Mike Driscoll skrev:
        

Andy,

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...

You should be able to get to any widget that's been made into an
attribute. So if you have something like this:

self.myCheckBox

on the left, the button on the right should still be able to call
self.myCheckBox.GetValue() or whatever.

An alternative would be pubsub. You could have the left side "subscribe"
to changes in the right side and update as necessary. See the following
links for more info on pubsub:

http://wiki.wxpython.org/PubSub
wxPython API Documentation — wxPython Phoenix 4.2.2 documentation

HTH

-------------------
Mike Driscoll
          

Well, these classes are in separate modules, so I guess they are not that
easy accessible...

I will look into pubsub...

/Andy
_________
        

That shouldn't matter...instead of self, use
myModuleName.mycheckBox.GetValue()

Of course, without some code, it's difficult to really say.

Mike
_______________________________________________
      

Here is my createLeftPanel class (adding/deleting elements from a list
directly, not via a txt file). I assume this is somehow some overkill, by
Detaching and Destroying to many elements. Well, it works at least.

Still, I have trouble with updating the left Panel from a right Panel.

Suggestions are welcome...

/Andy

import wx

class createLeftPanel(wx.Panel):
  def __init__(self, parent):
      wx.Panel.__init__(self, parent)

      #Initialization
      self.SetBackgroundColour('White')
      self.aList = ['alfa', 'bravo', 'ekko'] #For this testing routine
only!
            #Boxes
      self.mainBox = wx.BoxSizer(wx.VERTICAL)
      self.listSizer = self.MakeListSizer(self.aList)
            #Adding 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):
      newList =
      for counter in range(0, len(self.elementList)):
          if self.elementList[counter][0].GetValue() != True:
              newList.append(self.elementList[counter][1])

      #Remove and create new listSizer
      self.RemoveListSizer()
      self.aList = newList
      self.listSizer = self.MakeListSizer(self.aList)

      #Adding to mainBox and updating layout
      self.mainBox.Add(self.listSizer, 0, wx.RIGHT | wx.LEFT, 3)
      self.mainBox.Fit(self)
      self.Layout()

  def OnAdd(self, event):
      self.aList.append(self.addText.GetValue())

      #Remove and create new listSizer
      self.RemoveListSizer()
      self.listSizer = self.MakeListSizer(self.aList)

      #Adding to mainBox and updating layout
      self.mainBox.Add(self.listSizer, 0, wx.RIGHT | wx.LEFT, 3)
      self.mainBox.Fit(self)
      self.Layout()
        def RemoveListSizer(self):
      self.sizer.Detach(self.deleteBox)
      self.sizer.Detach(self.addBox)
      self.mainBox.Detach(self.sizer)

      self.sizer.Destroy()
      self.deleteBox.Destroy()
      self.addBox.Destroy()

      for item in self.elementList:
          item[0].Destroy()
      self.elementList =

      self.deleteText.Destroy()
      self.deleteButton.Destroy()
      self.addText.Destroy()
      self.addButton.Destroy()
        def MakeListSizer(self, inputList):
      self.listBox = wx.StaticBox(self, -1, 'List')
      self.sizer = wx.StaticBoxSizer(self.listBox, wx.VERTICAL)

      self.elementList =
      for item in inputList:
          self.element = wx.CheckBox(self, -1, item, pos=wx.DefaultPosition,
\
                                size=wx.DefaultSize)
          self.elementList.append((self.element, item))
          self.sizer.Add(self.element, 0, wx.ALL, 5)

      #Delete button
      self.deleteBox = wx.BoxSizer(wx.HORIZONTAL)
      self.deleteText = wx.StaticText(self, -1, '', size=(125,-1))
      self.deleteButton = wx.Button(self, -1, 'Delete')
      self.deleteBox.Add(self.deleteText, 0, wx.ALL, 1)
      self.deleteBox.Add(self.deleteButton, 0, wx.ALL, 1)
      self.Bind(wx.EVT_BUTTON, self.OnDelete, self.deleteButton)

      #Add element + add button
      self.addBox = wx.BoxSizer(wx.HORIZONTAL)
      self.addText = wx.TextCtrl(self, -1, value='', size = (125, -1), \
                                       validator=wx.DefaultValidator)
      self.addText.SetMaxLength(12)
      self.addButton = wx.Button(self, -1, 'Add')
      self.addBox.Add(self.addText, 0, wx.ALL, 1)
      self.addBox.Add(self.addButton, 0, wx.ALL, 1)
      self.Bind(wx.EVT_BUTTON, self.OnAdd, self.addButton)
            #Add to sizer
      self.sizer.Add(self.deleteBox, 0, wx.EXPAND, 0)
      self.sizer.Add(self.addBox, 0, wx.EXPAND, 0)
      self.Fit()

      return self.sizer
""" Testing routines for testing this module only"""
class Frame(wx.Frame):
  def __init__(self, parent):
      wx.Frame.__init__(self, parent=None, id=-1)
      self.panel = createLeftPanel(self)
      self.statusbar = self.CreateStatusBar()

class App(wx.App):
  def OnInit(self):
      wx.App.__init__(self)
      self.frame = Frame(-1)
      self.frame.Show()
      self.SetTopWindow(self.frame)
      return True

  def OnExit(self):
      pass

if __name__ == '__main__':
  app = App()
  import wx.lib.inspection
  wx.lib.inspection.InspectionTool().Show()
  app.MainLoop()

Let's simplify this:

Which widget(s) in the right panel should cause what change in which widget
in the left panel?
_______________________________________________

When a BlockWindow (according to the wxPython book) is doubleclicked, a method OnDClickBx is called via binding an event to the double click: Bind(wx.EVT_LEFT_DCLICK, self.OnDClickBx).

def OnDClickBx(self, event):
        ident = event.GetId()
        index = self.bwIdList.index(ident)
        label = self.labelList[index]
             #I lave a list self.bwIdList of buttons, button IDs and labels, and the label is what I want to be added to the checkbox list in the left Panel.
             #Presumably, I must Detach the left panel sizer, add the label to the list and then add the new sizer to the left Panel again?

···

On Fri, Oct 24, 2008 at 2:41 PM, andy <postinger@start.no> wrote:

C M skrev:

  

Mike Driscoll skrev:
    

andy wrote:
      

Mike Driscoll skrev:
        

Andy,

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...

You should be able to get to any widget that's been made into an
attribute. So if you have something like this:

self.myCheckBox

on the left, the button on the right should still be able to call
self.myCheckBox.GetValue() or whatever.

An alternative would be pubsub. You could have the left side "subscribe"
to changes in the right side and update as necessary. See the following
links for more info on pubsub:

http://wiki.wxpython.org/PubSub
wxPython API Documentation — wxPython Phoenix 4.2.2 documentation

HTH

-------------------
Mike Driscoll
          

Well, these classes are in separate modules, so I guess they are not that
easy accessible...

I will look into pubsub...

/Andy
_________
        

That shouldn't matter...instead of self, use
myModuleName.mycheckBox.GetValue()

Of course, without some code, it's difficult to really say.

Mike
_______________________________________________
      

Here is my createLeftPanel class (adding/deleting elements from a list
directly, not via a txt file). I assume this is somehow some overkill, by
Detaching and Destroying to many elements. Well, it works at least.

Still, I have trouble with updating the left Panel from a right Panel.

Suggestions are welcome...

/Andy

import wx

class createLeftPanel(wx.Panel):
  def __init__(self, parent):
      wx.Panel.__init__(self, parent)

      #Initialization
      self.SetBackgroundColour('White')
      self.aList = ['alfa', 'bravo', 'ekko'] #For this testing routine
only!
            #Boxes
      self.mainBox = wx.BoxSizer(wx.VERTICAL)
      self.listSizer = self.MakeListSizer(self.aList)
            #Adding 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):
      newList =
      for counter in range(0, len(self.elementList)):
          if self.elementList[counter][0].GetValue() != True:
              newList.append(self.elementList[counter][1])

      #Remove and create new listSizer
      self.RemoveListSizer()
      self.aList = newList
      self.listSizer = self.MakeListSizer(self.aList)

      #Adding to mainBox and updating layout
      self.mainBox.Add(self.listSizer, 0, wx.RIGHT | wx.LEFT, 3)
      self.mainBox.Fit(self)
      self.Layout()

  def OnAdd(self, event):
      self.aList.append(self.addText.GetValue())

      #Remove and create new listSizer
      self.RemoveListSizer()
      self.listSizer = self.MakeListSizer(self.aList)

      #Adding to mainBox and updating layout
      self.mainBox.Add(self.listSizer, 0, wx.RIGHT | wx.LEFT, 3)
      self.mainBox.Fit(self)
      self.Layout()
        def RemoveListSizer(self):
      self.sizer.Detach(self.deleteBox)
      self.sizer.Detach(self.addBox)
      self.mainBox.Detach(self.sizer)

      self.sizer.Destroy()
      self.deleteBox.Destroy()
      self.addBox.Destroy()

      for item in self.elementList:
          item[0].Destroy()
      self.elementList =

      self.deleteText.Destroy()
      self.deleteButton.Destroy()
      self.addText.Destroy()
      self.addButton.Destroy()
        def MakeListSizer(self, inputList):
      self.listBox = wx.StaticBox(self, -1, 'List')
      self.sizer = wx.StaticBoxSizer(self.listBox, wx.VERTICAL)

      self.elementList =
      for item in inputList:
          self.element = wx.CheckBox(self, -1, item, pos=wx.DefaultPosition,
\
                                size=wx.DefaultSize)
          self.elementList.append((self.element, item))
          self.sizer.Add(self.element, 0, wx.ALL, 5)

      #Delete button
      self.deleteBox = wx.BoxSizer(wx.HORIZONTAL)
      self.deleteText = wx.StaticText(self, -1, '', size=(125,-1))
      self.deleteButton = wx.Button(self, -1, 'Delete')
      self.deleteBox.Add(self.deleteText, 0, wx.ALL, 1)
      self.deleteBox.Add(self.deleteButton, 0, wx.ALL, 1)
      self.Bind(wx.EVT_BUTTON, self.OnDelete, self.deleteButton)

      #Add element + add button
      self.addBox = wx.BoxSizer(wx.HORIZONTAL)
      self.addText = wx.TextCtrl(self, -1, value='', size = (125, -1), \
                                       validator=wx.DefaultValidator)
      self.addText.SetMaxLength(12)
      self.addButton = wx.Button(self, -1, 'Add')
      self.addBox.Add(self.addText, 0, wx.ALL, 1)
      self.addBox.Add(self.addButton, 0, wx.ALL, 1)
      self.Bind(wx.EVT_BUTTON, self.OnAdd, self.addButton)
            #Add to sizer
      self.sizer.Add(self.deleteBox, 0, wx.EXPAND, 0)
      self.sizer.Add(self.addBox, 0, wx.EXPAND, 0)
      self.Fit()

      return self.sizer
""" Testing routines for testing this module only"""
class Frame(wx.Frame):
  def __init__(self, parent):
      wx.Frame.__init__(self, parent=None, id=-1)
      self.panel = createLeftPanel(self)
      self.statusbar = self.CreateStatusBar()

class App(wx.App):
  def OnInit(self):
      wx.App.__init__(self)
      self.frame = Frame(-1)
      self.frame.Show()
      self.SetTopWindow(self.frame)
      return True

  def OnExit(self):
      pass

if __name__ == '__main__':
  app = App()
  import wx.lib.inspection
  wx.lib.inspection.InspectionTool().Show()
  app.MainLoop()

Let's simplify this:

Which widget(s) in the right panel should cause what change in which widget
in the left panel?
_______________________________________________
wxpython-users mailing list
wxpython-users@lists.wxwidgets.org
http://lists.wxwidgets.org/mailman/listinfo/wxpython-users
  

I could try to place the OnDClickBx(self, event) method in the createLeftPanel module, and do a
.Bind(wx.EVT_LEFT_DCLICK, createLeftPanel().OnDClickBx) from the right Panel.

Hower, this returns an error message TypeError:__init__() takes exactly 2 arguments (1 given) because of the wx.Panel.__init__ call for parent:

class createLeftPanel(wx.Panel):
  def __init__(self, parent):
      wx.Panel.__init__(self, parent)

Could I solve this by specifying the parent of the createLeftPanel. Or would this result in that yet another wx.Panel is created? And what would that parent be? See the code for the MainFrame in my first posting if that would help...

···

On Fri, Oct 24, 2008 at 2:41 PM, andy <postinger@start.no> wrote:

I don't think so. If you just want to add another item to a checklistbox,
in this case the label mentioned above, just use checkListBox.Append(label)
and it will just appear.

There's more to say, but can I suggest a few simplifying things?

1) Instead of posting a fair bit of (at least to me) sort of hard to
read code, post
a small runnable sample if you can. Then point out where that sample code is
not doing what you want. See here: http://wiki.wxpython.org/MakingSampleApps
I found your code kind of hard to dig into since I wasn't sure where
to start, what
to ignore, etc.

2) Maybe not a good idea to name your classes like they are functions, such
as your class called "createLeftPanel". I find it easier to represent
it in my mind
if I see it named LeftPanel--I know immediately that it IS that. And
the style is
supposed to be for classes LeadingUpperMixedCase. So it strikes me as better
to just name it LeftPanel.

3) Don't forget sizers are smart--if you add, remove, insert, hide, or
show widgets to/in
them, they know about it. Just call .Layout() on the parent panel.
And, as I said
above, many widgets repaint themselves when changed, so no need to remake them.

···

On Sat, Oct 25, 2008 at 2:55 AM, andy <postinger@start.no> wrote:

C M skrev:

On Fri, Oct 24, 2008 at 2:41 PM, andy <postinger@start.no> wrote:

Mike Driscoll skrev:

andy wrote:

Mike Driscoll skrev:

Andy,

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...

You should be able to get to any widget that's been made into an
attribute. So if you have something like this:

self.myCheckBox

on the left, the button on the right should still be able to call
self.myCheckBox.GetValue() or whatever.

An alternative would be pubsub. You could have the left side
"subscribe"
to changes in the right side and update as necessary. See the
following
links for more info on pubsub:

http://wiki.wxpython.org/PubSub
wxPython API Documentation — wxPython Phoenix 4.2.2 documentation

HTH

-------------------
Mike Driscoll

Well, these classes are in separate modules, so I guess they are not
that
easy accessible...

I will look into pubsub...

/Andy
_________

That shouldn't matter...instead of self, use
myModuleName.mycheckBox.GetValue()

Of course, without some code, it's difficult to really say.

Mike
_______________________________________________

Here is my createLeftPanel class (adding/deleting elements from a list
directly, not via a txt file). I assume this is somehow some overkill, by
Detaching and Destroying to many elements. Well, it works at least.

Still, I have trouble with updating the left Panel from a right Panel.

Suggestions are welcome...

/Andy

import wx

class createLeftPanel(wx.Panel):
def __init__(self, parent):
     wx.Panel.__init__(self, parent)

     #Initialization
     self.SetBackgroundColour('White')
     self.aList = ['alfa', 'bravo', 'ekko'] #For this testing routine
only!
           #Boxes
     self.mainBox = wx.BoxSizer(wx.VERTICAL)
     self.listSizer = self.MakeListSizer(self.aList)
           #Adding 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):
     newList =
     for counter in range(0, len(self.elementList)):
         if self.elementList[counter][0].GetValue() != True:
             newList.append(self.elementList[counter][1])

     #Remove and create new listSizer
     self.RemoveListSizer()
     self.aList = newList
     self.listSizer = self.MakeListSizer(self.aList)

     #Adding to mainBox and updating layout
     self.mainBox.Add(self.listSizer, 0, wx.RIGHT | wx.LEFT, 3)
     self.mainBox.Fit(self)
     self.Layout()

def OnAdd(self, event):
     self.aList.append(self.addText.GetValue())

     #Remove and create new listSizer
     self.RemoveListSizer()
     self.listSizer = self.MakeListSizer(self.aList)

     #Adding to mainBox and updating layout
     self.mainBox.Add(self.listSizer, 0, wx.RIGHT | wx.LEFT, 3)
     self.mainBox.Fit(self)
     self.Layout()
       def RemoveListSizer(self):
     self.sizer.Detach(self.deleteBox)
     self.sizer.Detach(self.addBox)
     self.mainBox.Detach(self.sizer)

     self.sizer.Destroy()
     self.deleteBox.Destroy()
     self.addBox.Destroy()

     for item in self.elementList:
         item[0].Destroy()
     self.elementList =

     self.deleteText.Destroy()
     self.deleteButton.Destroy()
     self.addText.Destroy()
     self.addButton.Destroy()
       def MakeListSizer(self, inputList):
     self.listBox = wx.StaticBox(self, -1, 'List')
     self.sizer = wx.StaticBoxSizer(self.listBox, wx.VERTICAL)

     self.elementList =
     for item in inputList:
         self.element = wx.CheckBox(self, -1, item,
pos=wx.DefaultPosition,
\
                               size=wx.DefaultSize)
         self.elementList.append((self.element, item))
         self.sizer.Add(self.element, 0, wx.ALL, 5)

     #Delete button
     self.deleteBox = wx.BoxSizer(wx.HORIZONTAL)
     self.deleteText = wx.StaticText(self, -1, '', size=(125,-1))
     self.deleteButton = wx.Button(self, -1, 'Delete')
     self.deleteBox.Add(self.deleteText, 0, wx.ALL, 1)
     self.deleteBox.Add(self.deleteButton, 0, wx.ALL, 1)
     self.Bind(wx.EVT_BUTTON, self.OnDelete, self.deleteButton)

     #Add element + add button
     self.addBox = wx.BoxSizer(wx.HORIZONTAL)
     self.addText = wx.TextCtrl(self, -1, value='', size = (125, -1), \
                                      validator=wx.DefaultValidator)
     self.addText.SetMaxLength(12)
     self.addButton = wx.Button(self, -1, 'Add')
     self.addBox.Add(self.addText, 0, wx.ALL, 1)
     self.addBox.Add(self.addButton, 0, wx.ALL, 1)
     self.Bind(wx.EVT_BUTTON, self.OnAdd, self.addButton)
           #Add to sizer
     self.sizer.Add(self.deleteBox, 0, wx.EXPAND, 0)
     self.sizer.Add(self.addBox, 0, wx.EXPAND, 0)
     self.Fit()

     return self.sizer
""" Testing routines for testing this module only"""
class Frame(wx.Frame):
def __init__(self, parent):
     wx.Frame.__init__(self, parent=None, id=-1)
     self.panel = createLeftPanel(self)
     self.statusbar = self.CreateStatusBar()

class App(wx.App):
def OnInit(self):
     wx.App.__init__(self)
     self.frame = Frame(-1)
     self.frame.Show()
     self.SetTopWindow(self.frame)
     return True

def OnExit(self):
     pass

if __name__ == '__main__':
app = App()
import wx.lib.inspection
wx.lib.inspection.InspectionTool().Show()
app.MainLoop()

Let's simplify this:

Which widget(s) in the right panel should cause what change in which
widget
in the left panel?
_______________________________________________

When a BlockWindow (according to the wxPython book) is doubleclicked, a
method OnDClickBx is called via binding an event to the double click:
Bind(wx.EVT_LEFT_DCLICK, self.OnDClickBx).

def OnDClickBx(self, event):
      ident = event.GetId()
      index = self.bwIdList.index(ident)
      label = self.labelList[index]
         #I lave a list self.bwIdList of buttons, button IDs and labels, and
the label is what I want to be added to the checkbox list in the left Panel.
         #Presumably, I must Detach the left panel sizer, add the label to
the list and then add the new sizer to the left Panel again?

C M skrev:

  

C M skrev:
    

Mike Driscoll skrev:

andy wrote:

Mike Driscoll skrev:

Andy,

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...

You should be able to get to any widget that's been made into an
attribute. So if you have something like this:

self.myCheckBox

on the left, the button on the right should still be able to call
self.myCheckBox.GetValue() or whatever.

An alternative would be pubsub. You could have the left side
"subscribe"
to changes in the right side and update as necessary. See the
following
links for more info on pubsub:

http://wiki.wxpython.org/PubSub
wxPython API Documentation — wxPython Phoenix 4.2.2 documentation

HTH

-------------------
Mike Driscoll

Well, these classes are in separate modules, so I guess they are not
that
easy accessible...

I will look into pubsub...

/Andy
_________

That shouldn't matter...instead of self, use
myModuleName.mycheckBox.GetValue()

Of course, without some code, it's difficult to really say.

Mike
_______________________________________________

Here is my createLeftPanel class (adding/deleting elements from a list
directly, not via a txt file). I assume this is somehow some overkill, by
Detaching and Destroying to many elements. Well, it works at least.

Still, I have trouble with updating the left Panel from a right Panel.

Suggestions are welcome...

/Andy

import wx

class createLeftPanel(wx.Panel):
def __init__(self, parent):
     wx.Panel.__init__(self, parent)

     #Initialization
     self.SetBackgroundColour('White')
     self.aList = ['alfa', 'bravo', 'ekko'] #For this testing routine
only!
           #Boxes
     self.mainBox = wx.BoxSizer(wx.VERTICAL)
     self.listSizer = self.MakeListSizer(self.aList)
           #Adding 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):
     newList =
     for counter in range(0, len(self.elementList)):
         if self.elementList[counter][0].GetValue() != True:
             newList.append(self.elementList[counter][1])

     #Remove and create new listSizer
     self.RemoveListSizer()
     self.aList = newList
     self.listSizer = self.MakeListSizer(self.aList)

     #Adding to mainBox and updating layout
     self.mainBox.Add(self.listSizer, 0, wx.RIGHT | wx.LEFT, 3)
     self.mainBox.Fit(self)
     self.Layout()

def OnAdd(self, event):
     self.aList.append(self.addText.GetValue())

     #Remove and create new listSizer
     self.RemoveListSizer()
     self.listSizer = self.MakeListSizer(self.aList)

     #Adding to mainBox and updating layout
     self.mainBox.Add(self.listSizer, 0, wx.RIGHT | wx.LEFT, 3)
     self.mainBox.Fit(self)
     self.Layout()
       def RemoveListSizer(self):
     self.sizer.Detach(self.deleteBox)
     self.sizer.Detach(self.addBox)
     self.mainBox.Detach(self.sizer)

     self.sizer.Destroy()
     self.deleteBox.Destroy()
     self.addBox.Destroy()

     for item in self.elementList:
         item[0].Destroy()
     self.elementList =

     self.deleteText.Destroy()
     self.deleteButton.Destroy()
     self.addText.Destroy()
     self.addButton.Destroy()
       def MakeListSizer(self, inputList):
     self.listBox = wx.StaticBox(self, -1, 'List')
     self.sizer = wx.StaticBoxSizer(self.listBox, wx.VERTICAL)

     self.elementList =
     for item in inputList:
         self.element = wx.CheckBox(self, -1, item,
pos=wx.DefaultPosition,
\
                               size=wx.DefaultSize)
         self.elementList.append((self.element, item))
         self.sizer.Add(self.element, 0, wx.ALL, 5)

     #Delete button
     self.deleteBox = wx.BoxSizer(wx.HORIZONTAL)
     self.deleteText = wx.StaticText(self, -1, '', size=(125,-1))
     self.deleteButton = wx.Button(self, -1, 'Delete')
     self.deleteBox.Add(self.deleteText, 0, wx.ALL, 1)
     self.deleteBox.Add(self.deleteButton, 0, wx.ALL, 1)
     self.Bind(wx.EVT_BUTTON, self.OnDelete, self.deleteButton)

     #Add element + add button
     self.addBox = wx.BoxSizer(wx.HORIZONTAL)
     self.addText = wx.TextCtrl(self, -1, value='', size = (125, -1), \
                                      validator=wx.DefaultValidator)
     self.addText.SetMaxLength(12)
     self.addButton = wx.Button(self, -1, 'Add')
     self.addBox.Add(self.addText, 0, wx.ALL, 1)
     self.addBox.Add(self.addButton, 0, wx.ALL, 1)
     self.Bind(wx.EVT_BUTTON, self.OnAdd, self.addButton)
           #Add to sizer
     self.sizer.Add(self.deleteBox, 0, wx.EXPAND, 0)
     self.sizer.Add(self.addBox, 0, wx.EXPAND, 0)
     self.Fit()

     return self.sizer
""" Testing routines for testing this module only"""
class Frame(wx.Frame):
def __init__(self, parent):
     wx.Frame.__init__(self, parent=None, id=-1)
     self.panel = createLeftPanel(self)
     self.statusbar = self.CreateStatusBar()

class App(wx.App):
def OnInit(self):
     wx.App.__init__(self)
     self.frame = Frame(-1)
     self.frame.Show()
     self.SetTopWindow(self.frame)
     return True

def OnExit(self):
     pass

if __name__ == '__main__':
app = App()
import wx.lib.inspection
wx.lib.inspection.InspectionTool().Show()
app.MainLoop()

Let's simplify this:

Which widget(s) in the right panel should cause what change in which
widget
in the left panel?
_______________________________________________
      

When a BlockWindow (according to the wxPython book) is doubleclicked, a
method OnDClickBx is called via binding an event to the double click:
Bind(wx.EVT_LEFT_DCLICK, self.OnDClickBx).

def OnDClickBx(self, event):
      ident = event.GetId()
      index = self.bwIdList.index(ident)
      label = self.labelList[index]
         #I lave a list self.bwIdList of buttons, button IDs and labels, and
the label is what I want to be added to the checkbox list in the left Panel.
         #Presumably, I must Detach the left panel sizer, add the label to
the list and then add the new sizer to the left Panel again?
    
I don't think so. If you just want to add another item to a checklistbox,
in this case the label mentioned above, just use checkListBox.Append(label)
and it will just appear.

There's more to say, but can I suggest a few simplifying things?

1) Instead of posting a fair bit of (at least to me) sort of hard to
read code, post
a small runnable sample if you can. Then point out where that sample code is
not doing what you want. See here: http://wiki.wxpython.org/MakingSampleApps
I found your code kind of hard to dig into since I wasn't sure where
to start, what
to ignore, etc.

2) Maybe not a good idea to name your classes like they are functions, such
as your class called "createLeftPanel". I find it easier to represent
it in my mind
if I see it named LeftPanel--I know immediately that it IS that. And
the style is
supposed to be for classes LeadingUpperMixedCase. So it strikes me as better
to just name it LeftPanel.

3) Don't forget sizers are smart--if you add, remove, insert, hide, or
show widgets to/in
them, they know about it. Just call .Layout() on the parent panel.
And, as I said
above, many widgets repaint themselves when changed, so no need to remake them.
_______________________________________________
wxpython-users mailing list
wxpython-users@lists.wxwidgets.org
http://lists.wxwidgets.org/mailman/listinfo/wxpython-users
  

Thank you for tips - I will try this when I find time. I am a newbie when it comes to wx and Python - I tried to remove as much stuff as possible from the original code before posting . but I guess my code is that cumbersome...

"Sizers are smart" - I will remember that one. Hopefully they are not too smart for me :wink:

/Andy

···

On Sat, Oct 25, 2008 at 2:55 AM, andy <postinger@start.no> wrote:

On Fri, Oct 24, 2008 at 2:41 PM, andy <postinger@start.no> wrote: