From: W. Trevor King Date: Tue, 10 Aug 2010 20:16:37 +0000 (-0400) Subject: Adjust GUI initialization to handle already loaded playlists (via --command-no-exit... X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=907e8b93aae50c57ac40d43ddb2b31cf3618e3c9;p=hooke.git Adjust GUI initialization to handle already loaded playlists (via --command-no-exit, etc.) --- diff --git a/hooke/ui/gui/__init__.py b/hooke/ui/gui/__init__.py index 38bf191..b8a8133 100644 --- a/hooke/ui/gui/__init__.py +++ b/hooke/ui/gui/__init__.py @@ -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)