#
# 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
-# <http://www.gnu.org/licenses/>.
+# You should have received a copy of the GNU Lesser General Public License
+# along with Hooke. If not, see <http://www.gnu.org/licenses/>.
"""Define :class:`HookeApp` and related, central application classes.
"""
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
# 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
# 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,
},
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'
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()
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])
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
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.
"""
# 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):
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