Restored the playlist panel + cleanups now that I can load stuff into it ;).
authorW. Trevor King <wking@drexel.edu>
Fri, 30 Jul 2010 01:51:26 +0000 (21:51 -0400)
committerW. Trevor King <wking@drexel.edu>
Fri, 30 Jul 2010 01:51:26 +0000 (21:51 -0400)
hooke/ui/gui/__init__.py
hooke/ui/gui/panel/__init__.py
hooke/ui/gui/panel/playlist.py

index 48bf62d8517967f14e69a3284f23752b2a7d08d1..120d36af147b140d7bbaa5b6535b59897b1a30e0 100644 (file)
@@ -116,13 +116,14 @@ class HookeFrame (wx.Frame):
 #                    style=wx.DIRCTRL_SHOW_FILTERS,\r
 #                    filter=self.gui.config['folders-filters'],\r
 #                    defaultFilter=int(self.gui.config['folders-filter-index'])), 'left'),  #HACK: config should convert\r
-#            ('playlists', panel.PANELS['playlist'](\r
-#                    callbacks={},\r
-#                    config=self.gui.config,\r
-#                    parent=self,\r
-#                    style=wx.WANTS_CHARS|wx.NO_BORDER,\r
-#                    # WANTS_CHARS so the panel doesn't eat the Return key.\r
-#                    size=(160, 200)), 'left'),\r
+            ('playlists', panel.PANELS['playlist'](\r
+                    callbacks={},\r
+                    config=self.gui.config,\r
+                    parent=self,\r
+                    style=wx.WANTS_CHARS|wx.NO_BORDER,\r
+                    # WANTS_CHARS so the panel doesn't eat the Return key.\r
+#                    size=(160, 200),\r
+                    ), 'left'),\r
 #            ('note', panel.note.Note(\r
 #                    parent=self\r
 #                    style=wx.WANTS_CHARS|wx.NO_BORDER,\r
@@ -145,8 +146,8 @@ class HookeFrame (wx.Frame):
                     parent=self,\r
                     style=wx.WANTS_CHARS|wx.NO_BORDER,\r
                     # WANTS_CHARS so the panel doesn't eat the Return key.\r
-#                    size=(160, 200)\r
-                    ), 'center'),\r
+#                    size=(160, 200),\r
+                    ), 'right'),\r
             ('property', panel.PANELS['propertyeditor2'](\r
                     callbacks={},\r
                     parent=self,\r
@@ -338,36 +339,29 @@ class HookeFrame (wx.Frame):
                 self._c['output'].write(result.__class__.__name__+'\n')\r
             self._c['output'].write(str(result).rstrip()+'\n')\r
 \r
-    def _postprocess_get_curve(self, command, results):\r
-        """Update `self` to show the curve.\r
+    def _postprocess_text(self, command, results):\r
+        """Print the string representation of the results to the Results window.\r
+\r
+        This is similar to :class:`~hooke.ui.commandline.DoCommand`'s\r
+        approach, except that :class:`~hooke.ui.commandline.DoCommand`\r
+        doesn't print some internally handled messages\r
+        (e.g. :class:`~hooke.interaction.ReloadUserInterfaceConfig`).\r
+        """\r
+        for result in results:\r
+            if isinstance(result, CommandExit):\r
+                self._c['output'].write(result.__class__.__name__+'\n')\r
+            self._c['output'].write(str(result).rstrip()+'\n')\r
+\r
+    def _postprocess_load_playlist(self, command, results):\r
+        """Update `self` to show the playlist.\r
         """\r
         if not isinstance(results[-1], Success):\r
-            return  # error executing 'get curve'\r
+            return  # error executing 'load playlist'\r
         assert len(results) == 2, results\r
-        curve = results[0]\r
-        print curve\r
-\r
-        selected_item = self._c['playlists']._c['tree'].GetSelection()\r
-        if self._c['playlists']._c['tree'].ItemHasChildren(selected_item):\r
-            #GetFirstChild returns a tuple\r
-            #we only need the first element\r
-            next_item = self._c['playlists']._c['tree'].GetFirstChild(selected_item)[0]\r
-        else:\r
-            next_item = self._c['playlists']._c['tree'].GetNextSibling(selected_item)\r
-            if not next_item.IsOk():\r
-                parent_item = self._c['playlists']._c['tree'].GetItemParent(selected_item)\r
-                #GetFirstChild returns a tuple\r
-                #we only need the first element\r
-                next_item = self._c['playlists']._c['tree'].GetFirstChild(parent_item)[0]\r
-        self._c['playlists']._c['tree'].SelectItem(next_item, True)\r
-        if not self._c['playlists']._c['tree'].ItemHasChildren(selected_item):\r
-            playlist = self.GetActivePlaylist()\r
-            if playlist.count > 1:\r
-                playlist.next()\r
-                self._c['status bar'].set_playlist(playlist)\r
-                self.UpdateNote()\r
-                self.UpdatePlot()\r
+        playlist = results[0]\r
+        print playlist\r
 \r
+        self._c['playlists']._c['tree'].add_playlist(playlist)\r
 \r
 \r
     # TODO: cruft\r
index 2457f5c60e162615f792a200b3826dd5669d47c5..4a2a8daeff0a58d4ff0fd5640e9aeca3f3e2d9f5 100644 (file)
@@ -8,7 +8,7 @@ PANEL_MODULES = [
 #    'note',\r
 #    'notebook',\r
     'output',\r
-#    'playlist',\r
+    'playlist',\r
 #    'plot',\r
 #    'propertyeditor',\r
     'propertyeditor2',\r
index f0532641d6593616c2e78311ecd0beaa3e954a1d..b0c837d43f5e64abfbfe4b3eda7352222cc7e0c2 100644 (file)
@@ -118,8 +118,9 @@ class Tree (wx.TreeCtrl):
         event.Skip()\r
 \r
     def _on_left_doubleclick(self, event):\r
-        playlist.index = index\r
-        event.Skip()\r
+        pass\r
+        #playlist.index = index\r
+        #event.Skip()\r
 \r
     def _on_context_menu(self, event):\r
         """Launch a popup :class:`Menu` with per-playlist/curve activities.\r
@@ -127,8 +128,8 @@ class Tree (wx.TreeCtrl):
         hit_id,hit_flags = self.HitTest(event.GetPosition())\r
         if (hit_flags & wx.TREE_HITTEST_ONITEM) != 0:\r
             self._hit_id = self._canonical_id(hit_id)  # store for callbacks\r
-            self.PopupMenu(\r
-                Menu(self._on_delete), event.GetPoint())\r
+            menu = Menu(self._on_delete)\r
+            self.PopupMenu(menu, event.GetPosition())\r
             menu.Destroy()\r
 \r
     def _on_delete(self, event):\r
@@ -176,12 +177,13 @@ class Tree (wx.TreeCtrl):
         """Add a :class:`hooke.curve.Curve` to a curently loaded playlist.\r
         """\r
         p = self._playlists[playlist_name]\r
-        p.append(curve)\r
-        c_id = AppendItem(\r
+        if curve not in p:\r
+            p.append(curve)\r
+        c_id = self.AppendItem(\r
             parent=self._id_for_name[playlist_name],\r
             text=self._name(curve.name),\r
             image=self.image['curve'])\r
-        self._id_for_name[(playlist.name, curve.name)] = c_id\r
+        self._id_for_name[(p.name, curve.name)] = c_id\r
         in_callback(self, p, curve)\r
 \r
     def delete_playlist(self, name):\r