def __init__(self, parent): self.parent = parent self.controller = DataPanelController(self) wx.Panel.__init__(self, id=wx.ID_ANY, name='', parent=self.parent) self.init_ui() module_logger.info("Successfully initialized DataPanel.") self.populate()
class DataPanel(wx.Panel): """Defines the wxPython panel used to display NDE Data""" def __init__(self, parent): self.parent = parent self.controller = DataPanelController(self) wx.Panel.__init__(self, id=wx.ID_ANY, name='', parent=self.parent) self.init_ui() module_logger.info("Successfully initialized DataPanel.") self.populate() @property def data(self): return self.controller.data def populate(self): """Retrieves the list of data files""" module_logger.info("Retrieving list of data files from controller.") self.controller.populate_tree() def init_ui(self): """Generates the data panel""" self.panel_sizer = wx.BoxSizer(wx.VERTICAL) self.data_tree = wx.TreeCtrl(self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize) self.data_tree_root = self.data_tree.AddRoot(pathfinder.data_path()) self.Bind(wx.EVT_TREE_SEL_CHANGED, self.controller.on_tree_selection_changed, self.data_tree) self.data_tree.Bind(wx.EVT_RIGHT_DOWN, self.init_popup_menu) self.panel_sizer.Add(self.data_tree, ui_defaults.ctrl_pct, ui_defaults.sizer_flags, ui_defaults.widget_margin) self.figure_bmp = wx.StaticBitmap(self, wx.ID_ANY, bitmap=wx.NullBitmap, pos=wx.DefaultPosition, size=wx.DefaultSize) self.panel_sizer.Add(self.figure_bmp, ui_defaults.lbl_pct, ui_defaults.lblsizer_flags, ui_defaults.widget_margin) self.SetSizer(self.panel_sizer) def init_popup_menu(self, evt): """Generates the contextual (right-click) menu""" self.PopupMenu(DataPanelContextMenu(self), evt.GetPosition())