From: W. Trevor King Date: Thu, 19 Aug 2010 17:47:56 +0000 (-0400) Subject: Patch GUI to handle 'new playlist' and 'glob curves to playlist' X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=bd0bf27039dabe308cc4985c9835881c476c5838;p=hooke.git Patch GUI to handle 'new playlist' and 'glob curves to playlist' --- diff --git a/hooke/ui/gui/__init__.py b/hooke/ui/gui/__init__.py index 271b00a..034003b 100644 --- a/hooke/ui/gui/__init__.py +++ b/hooke/ui/gui/__init__.py @@ -417,6 +417,19 @@ class HookeFrame (wx.Frame): else: self._c['playlist'].add_playlist(playlist) + def _postprocess_new_playlist(self, command, args={}, results=None): + """Update `self` to show the new playlist. + """ + if not isinstance(results[-1], Success): + self._postprocess_text(command, results=results) + return + assert len(results) == 2, results + playlist = results[0] + if 'playlist' in self._c: + loaded = self._c['playlist'].is_playlist_loaded(playlist) + assert loaded == False, loaded + self._c['playlist'].add_playlist(playlist) + def _postprocess_load_playlist(self, command, args={}, results=None): """Update `self` to show the playlist. """ @@ -433,7 +446,10 @@ class HookeFrame (wx.Frame): return assert len(results) == 2, results playlist = results[0] - self._c['playlist'].update_playlist(playlist) + if 'playlist' in self._c: + loaded = self._c['playlist'].is_playlist_loaded(playlist) + assert loaded == True, loaded + self._c['playlist'].update_playlist(playlist) def _postprocess_get_curve(self, command, args={}, results=[]): """Update `self` to show the curve. @@ -451,7 +467,7 @@ class HookeFrame (wx.Frame): else: raise NotImplementedError() if 'note' in self._c: - self._c['note'].set_text(curve.info['note']) + self._c['note'].set_text(curve.info.get('note', '')) if 'playlist' in self._c: self._c['playlist'].set_selected_curve( playlist, curve) @@ -468,6 +484,25 @@ class HookeFrame (wx.Frame): """ pass + def _postprocess_glob_curves_to_playlist( + self, command, args={}, results=[]): + """Update `self` to show new curves. + """ + if not isinstance(results[-1], Success): + self._postprocess_text(command, results=results) + return + if 'playlist' in self._c: + if args.get('playlist', None) != None: + playlist = args['playlist'] + pname = playlist.name + loaded = self._c['playlist'].is_playlist_name_loaded(pname) + assert loaded == True, loaded + for curve in results[:-1]: + self._c['playlist']._add_curve(pname, curve) + else: + self.execute_command( + command=self._command_by_name('get playlist')) + def _postprocess_zero_block_surface_contact_point( self, command, args={}, results=[]): """Update the curve, since the available columns may have changed. diff --git a/hooke/ui/gui/panel/playlist.py b/hooke/ui/gui/panel/playlist.py index a863dca..e69f248 100644 --- a/hooke/ui/gui/panel/playlist.py +++ b/hooke/ui/gui/panel/playlist.py @@ -334,11 +334,36 @@ class Tree (wx.TreeCtrl): """Absorb changed `.index()`, etc. """ self._playlists[playlist.name] = playlist + cnames = [] + for curve in playlist: + if (playlist.name, curve.name) not in self._id_for_name: + self._add_curve(playlist.name, curve) + cnames.append(curve.name) + dc = self._callbacks['delete_curve'] + _dc = self._callbacks['_delete_curve'] + self._callbacks['delete_curve'] = None + self._callbacks['_delete_curve'] = None + for name in self._id_for_name.keys(): + if not self._is_curve(name): + continue + pname,cname = name + if pname != playlist.name: + continue + if cname not in cnames: + self.delete_curve(playlist.name, cname) + self._callbacks['delete_curve'] = dc + self._callbacks['_delete_curve'] = _dc def is_playlist_loaded(self, playlist): - """Return `True` if a playlist is loaded, `False` otherwise. + """Return `True` if `playlist` is loaded, `False` otherwise. + """ + return self.is_playlist_name_loaded(playlist.name) + + def is_playlist_name_loaded(self, name): + """Return `True` if a playlist named `name` is loaded, `False` + otherwise. """ - return playlist.name in self._playlists + return name in self._playlists class Playlist (Panel, wx.Panel): diff --git a/hooke/ui/gui/panel/propertyeditor.py b/hooke/ui/gui/panel/propertyeditor.py index 95233fc..b991c81 100644 --- a/hooke/ui/gui/panel/propertyeditor.py +++ b/hooke/ui/gui/panel/propertyeditor.py @@ -41,7 +41,7 @@ def props_from_argument(argument, curves=None, playlists=None): :class:`Property`\s. """ type = argument.type - if type in ['driver']: # intentionally not handled (yet) + if type in ['driver', 'dict']: # intentionally not handled (yet) return None count = argument.count if count == -1: