Added axes-selection choice widgets to gui.panel.plot's navbar.
authorW. Trevor King <wking@drexel.edu>
Mon, 2 Aug 2010 01:47:43 +0000 (21:47 -0400)
committerW. Trevor King <wking@drexel.edu>
Mon, 2 Aug 2010 01:47:43 +0000 (21:47 -0400)
hooke/ui/gui/panel/plot.py

index ab81c6029b5387cd337f33a97ec7769e0a969333..a6349e0ad8e1edf872cb261d9d838a212e98086c 100644 (file)
@@ -111,6 +111,17 @@ class PlotPanel (Panel, wx.Panel):
 \r
     def _setup_toolbar(self, sizer):\r
         self._c['toolbar'] = NavToolbar(self._c['canvas'])\r
+        self._c['x column'] = wx.Choice(\r
+            parent=self._c['toolbar'], choices=[])\r
+        self._c['x column'].SetToolTip(wx.ToolTip('x column'))\r
+        self._c['toolbar'].AddControl(self._c['x column'])\r
+        self._c['x column'].Bind(wx.EVT_CHOICE, self._on_x_column)\r
+        self._c['y column'] = wx.Choice(\r
+            parent=self._c['toolbar'], choices=[])\r
+        self._c['y column'].SetToolTip(wx.ToolTip('y column'))\r
+        self._c['toolbar'].AddControl(self._c['y column'])\r
+        self._c['y column'].Bind(wx.EVT_CHOICE, self._on_y_column)\r
+\r
         self._c['toolbar'].Realize()  # call after putting items in the toolbar\r
         if wx.Platform == '__WXMAC__':\r
             # Mac platform (OSX 10.3, MacPython) does not seem to cope with\r
@@ -173,10 +184,12 @@ class PlotPanel (Panel, wx.Panel):
             #self.SetStatusText(coordinateString)\r
 \r
     def _on_x_column(self, event):\r
-        pass\r
+        self._x_column = self._c['x column'].GetStringSelection()\r
+        self.update()\r
 \r
     def _on_y_column(self, event):\r
-        pass\r
+        self._y_column = self._c['y column'].GetStringSelection()\r
+        self.update()\r
 \r
     def _resize_canvas(self):\r
         w,h = self.GetClientSize()\r
@@ -195,7 +208,7 @@ class PlotPanel (Panel, wx.Panel):
         super(PlotPanel, self).OnPaint(event)\r
         self._c['canvas'].draw()\r
 \r
-    def set_curve(self, curve, config={}):\r
+    def set_curve(self, curve, config=None):\r
         self._curve = curve\r
         columns = set()\r
         for data in curve.data:\r
@@ -205,9 +218,23 @@ class PlotPanel (Panel, wx.Panel):
             self._x_column = self._columns[0]\r
         if self._y_column not in self._columns:\r
             self._y_column = self._columns[-1]\r
+        if 'x column' in self._c:\r
+            for i in range(self._c['x column'].GetCount()):\r
+                self._c['x column'].Delete(0)\r
+            self._c['x column'].AppendItems(self._columns)\r
+            self._c['x column'].SetStringSelection(self._x_column)\r
+        if 'y column' in self._c:\r
+            for i in range(self._c['y column'].GetCount()):\r
+                self._c['y column'].Delete(0)\r
+            self._c['y column'].AppendItems(self._columns)\r
+            self._c['y column'].SetStringSelection(self._y_column)\r
         self.update(config=config)\r
 \r
-    def update(self, config={}):\r
+    def update(self, config=None):\r
+        if config == None:\r
+            config = self._config  # use the last cached value\r
+        else:\r
+            self._config = config  # cache for later refreshes\r
         self._c['figure'].clear()\r
         self._c['figure'].suptitle(\r
             self._hooke_frame._file_name(self._curve.name),\r