I'm new using wxpython.
I created some code to generate a splitter window, in the left panel I created a listbox and in the right panel I created a button.
What I would like to do is that when I press my button in the right panel, my list in the left panel display the string "Hello World".
I've tried the following:
import wx
########################################################################
class LeftPanel(wx.Panel):
""""""
#----------------------------------------------------------------------
def __init__(self, parent):
"""Constructor"""
wx.Panel.__init__(self, parent=parent)
self.lizt = wx.ListBox(self, -1, pos = wx.DefaultPosition, size = (300, 120), choices = "", style = wx.LB_SINGLE|wx.LB_HSCROLL|wx.LB_SORT, name = "aDB")
sizer = wx.BoxSizer(wx.VERTICAL)
sizer.Add(self.lizt, 0, wx.EXPAND)
self.SetSizer(sizer)
########################################################################
class RightPanel(wx.Panel):
""""""
#----------------------------------------------------------------------
def __init__(self, parent):
"""Constructor"""
wx.Panel.__init__(self, parent=parent)
txt = wx.Button(self, wx.ID_ANY, "txt")
txt.SetLabel("ALL")
txt.Bind(wx.EVT_BUTTON, self.write, txt)
def write(self, event):
LeftPanel.lizt.Clear()
LeftPanel.lizt.Append("HELLO WORLD")
return
########################################################################
class MyForm(wx.Frame):
#----------------------------------------------------------------------
def __init__(self):
wx.Frame.__init__(self, None, title="Splitter Tutorial")
splitter = wx.SplitterWindow(self)
leftP = LeftPanel(splitter)
rightP = RightPanel(splitter)
# split the window
splitter.SplitVertically(leftP, rightP)
splitter.SetSashGravity(0.5)
sizer = wx.BoxSizer(wx.VERTICAL)
sizer.Add(splitter, 1, wx.EXPAND)
self.SetSizer(sizer)
#----------------------------------------------------------------------
# Run the program
if __name__ == "__main__":
app = wx.App(False)
frame = MyForm()
frame.Show()
app.MainLoop()
But I get this Error: AttributeError: type object 'LeftPanel' has no attribute 'lizt'
What am I doing wrong :(
Thanks in advance