X-Git-Url: http://git.tremily.us/?p=hooke.git;a=blobdiff_plain;f=hooke%2Fui%2Fgui%2Finterface.py;h=3ea863153415616c4b859bd1f895cc658decf378;hp=ae1a9a9ed22e5946813a3d377e92553eac955761;hb=26b91a633c6264f2fb11cbb7a418894dbdce4759;hpb=7ca12f79a4a794b081d3b7b49aee62fbbd072f80 diff --git a/hooke/ui/gui/interface.py b/hooke/ui/gui/interface.py index ae1a9a9..3ea8631 100644 --- a/hooke/ui/gui/interface.py +++ b/hooke/ui/gui/interface.py @@ -1,20 +1,19 @@ -# Copyright (C) 2010-2011 W. Trevor King +# Copyright (C) 2010-2012 W. Trevor King # # This file is part of Hooke. # -# Hooke is free software: you can redistribute it and/or modify it -# under the terms of the GNU Lesser General Public License as -# published by the Free Software Foundation, either version 3 of the -# License, or (at your option) any later version. +# Hooke is free software: you can redistribute it and/or modify it under the +# terms of the GNU Lesser General Public License as published by the Free +# Software Foundation, either version 3 of the License, or (at your option) any +# later version. # -# Hooke is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General -# Public License for more details. +# Hooke is distributed in the hope that it will be useful, but WITHOUT ANY +# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR +# A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more +# details. # -# You should have received a copy of the GNU Lesser General Public -# License along with Hooke. If not, see -# . +# You should have received a copy of the GNU Lesser General Public License +# along with Hooke. If not, see . """Define :class:`HookeApp` and related, central application classes. """ @@ -32,8 +31,10 @@ import platform import shutil import time +import wx import wx.html -import wx.aui as aui +#import wx.aui as aui # C++ implementation +import wx.lib.agw.aui as aui # Python implementation import wx.lib.evtmgr as evtmgr # wxPropertyGrid is included in wxPython >= 2.9.1, see # http://wxpropgrid.sourceforge.net/cgi-bin/index?page=download @@ -76,8 +77,6 @@ class HookeFrame (wx.Frame): # set the gradient and drag styles self._c['manager'].GetArtProvider().SetMetric( aui.AUI_DOCKART_GRADIENT_TYPE, aui.AUI_GRADIENT_NONE) - self._c['manager'].SetFlags( - self._c['manager'].GetFlags() ^ aui.AUI_MGR_TRANSPARENT_DRAG) # Min size for the frame itself isn't completely done. See # the end of FrameManager::Update() for the test code. For @@ -131,10 +130,8 @@ class HookeFrame (wx.Frame): # defaultFilter=self.gui.config['folders-filter-index']), 'left'), (panel.PANELS['playlist']( callbacks={ - 'delete_playlist':self._on_user_delete_playlist, - '_delete_playlist':self._on_delete_playlist, - 'delete_curve':self._on_user_delete_curve, - '_delete_curve':self._on_delete_curve, + '_delete_playlist':self._delete_playlist, + '_delete_curve':self._delete_curve, '_on_set_selected_playlist':self._on_set_selected_playlist, '_on_set_selected_curve':self._on_set_selected_curve, }, @@ -222,9 +219,9 @@ class HookeFrame (wx.Frame): callbacks={ 'next': self._next_curve, 'previous': self._previous_curve, + 'delete': self._delete_curve, }, - parent=self, - style=wx.TB_FLAT | wx.TB_NODIVIDER) + parent=self) self._c['manager'].AddPane( self._c['navigation bar'], aui.AuiPaneInfo().Name('Navigation').Caption('Navigation' @@ -239,6 +236,7 @@ class HookeFrame (wx.Frame): self.Bind(wx.EVT_SIZE, self._on_size) self.Bind(wx.EVT_CLOSE, self._on_close) self.Bind(aui.EVT_AUI_PANE_CLOSE, self._on_pane_close) + self.Bind(wx.EVT_CHAR_HOOK, self._on_key) return # TODO: cleanup treeCtrl = self._c['folders'].GetTreeCtrl() @@ -260,6 +258,7 @@ class HookeFrame (wx.Frame): def _on_close(self, *args): self.log.info('closing GUI framework') + # apply changes self._set_config('main height', self.GetSize().GetHeight()) self._set_config('main left', self.GetPosition()[0]) @@ -272,6 +271,16 @@ class HookeFrame (wx.Frame): def _on_erase_background(self, event): event.Skip() + def _on_key(self, event): + code = event.GetKeyCode() + if code == wx.WXK_RIGHT: + self._next_curve() + elif code == wx.WXK_LEFT: + self._previous_curve() + elif code == wx.WXK_DELETE or code == wx.WXK_BACK: + self._delete_curve() + else: + event.Skip() # Panel utility functions @@ -521,6 +530,11 @@ class HookeFrame (wx.Frame): self.execute_command( command=self._command_by_name('get playlist')) + def _postprocess_delete_curve(self, command, args={}, results=[]): + """No-op. Only call 'delete curve' via `self._delete_curve()`. + """ + pass + def _update_curve(self, command, args={}, results=[]): """Update the curve, since the available columns may have changed. """ @@ -595,22 +609,11 @@ class HookeFrame (wx.Frame): # Playlist panel interface - def _on_user_delete_playlist(self, _class, method, playlist): - pass - - def _on_delete_playlist(self, _class, method, playlist): - if hasattr(playlist, 'path') and playlist.path != None: - os.remove(playlist.path) - - def _on_user_delete_curve(self, _class, method, playlist, curve): - pass - - def _on_delete_curve(self, _class, method, playlist, curve): - index = playlist.index(curve) - results = self.execute_command( - command=self._command_by_name('remove curve from playlist'), - args={'index': index}) - #os.remove(curve.path) + def _delete_playlist(self, _class, method, playlist): + #if hasattr(playlist, 'path') and playlist.path != None: + # os.remove(playlist.path) + # TODO: remove playlist from underlying hooke instance and call ._c['playlist'].delete_playlist() + # possibly rename this method to _postprocess_delete_playlist... pass def _on_set_selected_playlist(self, _class, method, playlist): @@ -676,6 +679,18 @@ class HookeFrame (wx.Frame): self.execute_command( command=self._command_by_name('get curve')) + def _delete_curve(self, *args, **kwargs): + cmd_kwargs = {} + playlist = kwargs.get('playlist', None) + curve = kwargs.get('curve', None) + if playlist is not None and curve is not None: + cmd_kwargs['index'] = playlist.index(curve) + results = self.execute_command( + command=self._command_by_name('remove curve from playlist'), + args=cmd_kwargs) + if isinstance(results[-1], Success): + results = self.execute_command( + command=self._command_by_name('get playlist')) # Panel display handling