Adjust GUI initialization to handle already loaded playlists (via --command-no-exit...
authorW. Trevor King <wking@drexel.edu>
Tue, 10 Aug 2010 20:16:37 +0000 (16:16 -0400)
committerW. Trevor King <wking@drexel.edu>
Tue, 10 Aug 2010 20:16:37 +0000 (16:16 -0400)
hooke/ui/gui/__init__.py

index 38bf191d4a2629377bdbec58fff0e1757d1b324b..b8a81336d39e4e2863d07b20760802719aeef5a4 100644 (file)
@@ -115,7 +115,6 @@ class HookeFrame (wx.Frame):
         self._setup_perspectives()
         self._bind_events()
         return # TODO: cleanup
-        self.playlists = self._c['playlist'].Playlists
         self._displayed_plot = None
         #load default list, if possible
         self.do_loadlist(self.GetStringFromConfig('core', 'preferences', 'playlists'))
@@ -199,6 +198,10 @@ class HookeFrame (wx.Frame):
 #            ('results', panel.results.Results(self), 'bottom'),
             ]:
             self._add_panel(p, style)
+        self.execute_command(  # setup already loaded playlists
+            command=self._command_by_name('playlists'))
+        self.execute_command(  # setup already loaded curve
+            command=self._command_by_name('get curve'))
 
     def _add_panel(self, panel, style):
         self._c[panel.name] = panel
@@ -396,6 +399,22 @@ class HookeFrame (wx.Frame):
                 self._c['output'].write(result.__class__.__name__+'\n')
             self._c['output'].write(str(result).rstrip()+'\n')
 
+    def _postprocess_playlists(self, command, args={}, results=None):
+        """Update `self` to show the playlists.
+        """
+        if not isinstance(results[-1], Success):
+            self._postprocess_text(command, results=results)
+            return
+        assert len(results) == 2, results
+        playlists = results[0]
+        loaded_playlists = []  # TODO
+        if 'playlist' in self._c:
+            for playlist in playlists:
+                if playlist in loaded_playlists:
+                    self._c['playlist'].update_playlist(playlist)
+                else:
+                    self._c['playlist'].add_playlist(playlist)
+
     def _postprocess_load_playlist(self, command, args={}, results=None):
         """Update `self` to show the playlist.
         """
@@ -404,7 +423,7 @@ class HookeFrame (wx.Frame):
             return
         assert len(results) == 2, results
         playlist = results[0]
-        self._c['playlist']._c['tree'].add_playlist(playlist)
+        self._c['playlist'].add_playlist(playlist)
 
     def _postprocess_get_playlist(self, command, args={}, results=[]):
         if not isinstance(results[-1], Success):
@@ -412,7 +431,7 @@ class HookeFrame (wx.Frame):
             return
         assert len(results) == 2, results
         playlist = results[0]
-        self._c['playlist']._c['tree'].update_playlist(playlist)
+        self._c['playlist'].update_playlist(playlist)
 
     def _postprocess_get_curve(self, command, args={}, results=[]):
         """Update `self` to show the curve.
@@ -432,7 +451,7 @@ class HookeFrame (wx.Frame):
         if 'note' in self._c:
             self._c['note'].set_text(curve.info['note'])
         if 'playlist' in self._c:
-            self._c['playlist']._c['tree'].set_selected_curve(
+            self._c['playlist'].set_selected_curve(
                 playlist, curve)
         if 'plot' in self._c:
             self._c['plot'].set_curve(curve, config=self.gui.config)