Hi there daniweb, im looking for some help. I have two classes MainWindow(wx.Frame), and AddTask(wx.Dialog). MainWindow contains a listbox called task_list. When AddTask is created I want the user to fill out the required info and and then click a button activating an on_click event. In that event I want to update the list in MainWindow. How ever when I try to do so I get and error: 'MainWindow' object has no attribute task_list.
Here is what I have tried so far (not full code):
class MainWindow(wx.Frame):
def __init__(self, *args, **kwds):
kwds["style"] = wx.DEFAULT_FRAME_STYLE
wx.Frame.__init__(self, *args, **kwds)
self.create_tasklist()
self.create_toolbar()
self.set_properties()
self.do_layout()
self.bind_events()
def create_tasklist(self):
choice_list = ["TaskOne", "TaskTwo", "TaskThree"]
self.task_list = wx.ListBox(self, -1, choices = choice_list)
......
def on_add(self, event):
'''Adds new task to task_list.'''
add_task = AddTask(None, -1, "Add Task")
add_task.ShowModal()
add_task.Destroy()
......
class AddTask(wx.Dialog):
'''Custom dialog to add tasks to task list.'''
def __init__(self, *args, **kwds):
kwds["style"] = wx.DEFAULT_DIALOG_STYLE
wx.Dialog.__init__(self, *args, **kwds)
self.create_widgets()
self.set_properties()
self.do_layout()
self.bind_events()
......
def on_add_button_click(self, event):
# Adds task_name to task_list
MainWindow.task_list.Insert(self.task_name_text.GetValue())
I have also tried other variations though I think this one shows what I am trying to do the best.