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