class FSBrowserController(wx.EvtHandler):
    """Widget-specific controller for filesystem browsers.
    :ivar parent: Parent controller -- useful when UI-wide control is
        necessary to respond to an event.
    """

def __init__(self, parent, frame, tree_ctrl, base_dirs):
    self.parent = parent
self.frame = frame
self.tree_ctrl = tree_ctrl
self.base_dirs = base_dirs
frame.Bind(EVT_FS_REFRESH, self.refresh)
frame.Bind(wx.EVT_WINDOW_DESTROY, self._unregister)
self.refresh()
self._register()

def _register(self):
    """Register self with parent controller."""
self.parent._fsb_controllers.append(self)

def _unregister(self, event):
    """Unregister self with parent controller."""
if event.GetEventObject() == self.frame:
    self.parent._fsb_controllers.remove(self)

def refresh(self, event=None):
    """Refresh the :ivar:`tree_ctrl` using :ivar:`base_dirs`."""
raise NotImplementedError


class Controller(wx.EvtHandler):
    """Main controller for the application.
    Handles UI-wide behaviors.
    """

def __init__(self):
    self._fsb_controllers = []
fsb_frame = FSBrowserFrame(parent=None)
FSBrowserController(self, fsb_frame, fsb_frame.tree_ctrl, initial_base_dirs)
fsb_frame.Show()
wxPython: How should I organize per-widget data in the controller?