From: W. Trevor King Date: Mon, 2 Aug 2010 01:47:43 +0000 (-0400) Subject: Added axes-selection choice widgets to gui.panel.plot's navbar. X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=4405a6acd76687d40f3eea45e4b2cec4bb44ab65;p=hooke.git Added axes-selection choice widgets to gui.panel.plot's navbar. --- diff --git a/hooke/ui/gui/panel/plot.py b/hooke/ui/gui/panel/plot.py index ab81c60..a6349e0 100644 --- a/hooke/ui/gui/panel/plot.py +++ b/hooke/ui/gui/panel/plot.py @@ -111,6 +111,17 @@ class PlotPanel (Panel, wx.Panel): def _setup_toolbar(self, sizer): self._c['toolbar'] = NavToolbar(self._c['canvas']) + self._c['x column'] = wx.Choice( + parent=self._c['toolbar'], choices=[]) + self._c['x column'].SetToolTip(wx.ToolTip('x column')) + self._c['toolbar'].AddControl(self._c['x column']) + self._c['x column'].Bind(wx.EVT_CHOICE, self._on_x_column) + self._c['y column'] = wx.Choice( + parent=self._c['toolbar'], choices=[]) + self._c['y column'].SetToolTip(wx.ToolTip('y column')) + self._c['toolbar'].AddControl(self._c['y column']) + self._c['y column'].Bind(wx.EVT_CHOICE, self._on_y_column) + self._c['toolbar'].Realize() # call after putting items in the toolbar if wx.Platform == '__WXMAC__': # Mac platform (OSX 10.3, MacPython) does not seem to cope with @@ -173,10 +184,12 @@ class PlotPanel (Panel, wx.Panel): #self.SetStatusText(coordinateString) def _on_x_column(self, event): - pass + self._x_column = self._c['x column'].GetStringSelection() + self.update() def _on_y_column(self, event): - pass + self._y_column = self._c['y column'].GetStringSelection() + self.update() def _resize_canvas(self): w,h = self.GetClientSize() @@ -195,7 +208,7 @@ class PlotPanel (Panel, wx.Panel): super(PlotPanel, self).OnPaint(event) self._c['canvas'].draw() - def set_curve(self, curve, config={}): + def set_curve(self, curve, config=None): self._curve = curve columns = set() for data in curve.data: @@ -205,9 +218,23 @@ class PlotPanel (Panel, wx.Panel): self._x_column = self._columns[0] if self._y_column not in self._columns: self._y_column = self._columns[-1] + if 'x column' in self._c: + for i in range(self._c['x column'].GetCount()): + self._c['x column'].Delete(0) + self._c['x column'].AppendItems(self._columns) + self._c['x column'].SetStringSelection(self._x_column) + if 'y column' in self._c: + for i in range(self._c['y column'].GetCount()): + self._c['y column'].Delete(0) + self._c['y column'].AppendItems(self._columns) + self._c['y column'].SetStringSelection(self._y_column) self.update(config=config) - def update(self, config={}): + def update(self, config=None): + if config == None: + config = self._config # use the last cached value + else: + self._config = config # cache for later refreshes self._c['figure'].clear() self._c['figure'].suptitle( self._hooke_frame._file_name(self._curve.name),