from ...config import Setting\r
from ...interaction import Request, BooleanRequest, ReloadUserInterfaceConfig\r
from ...ui import UserInterface, CommandMessage\r
+from . import menu as menu\r
+from . import navbar as navbar\r
from . import panel as panel\r
from . import prettyformat as prettyformat\r
-\r
-\r
-class Notebook (aui.AuiNotebook):\r
- def __init__(self, *args, **kwargs):\r
- super(Notebook, self).__init__(*args, **kwargs)\r
- self.SetArtProvider(aui.AuiDefaultTabArt())\r
- #uncomment if we find a nice icon\r
- #page_bmp = wx.ArtProvider.GetBitmap(wx.ART_NORMAL_FILE, wx.ART_OTHER, wx.Size(16, 16))\r
- self.AddPage(self._welcome_window(), 'Welcome')\r
-\r
- def _welcome_window(self):\r
- #TODO: move into panel.welcome\r
- ctrl = wx.html.HtmlWindow(parent=self, size=wx.Size(400, 300))\r
- lines = [\r
- '<h1>Welcome to Hooke</h1>',\r
- '<h3>Features</h3>',\r
- '<ul>',\r
- '<li>View, annotate, measure force files</li>',\r
- '<li>Worm-like chain fit of force peaks</li>',\r
- '<li>Automatic convolution-based filtering of empty files</li>',\r
- '<li>Automatic fit and measurement of multiple force peaks</li>',\r
- '<li>Handles force-clamp force experiments (experimental)</li>',\r
- '<li>It is extensible through plugins and drivers</li>',\r
- '</ul>',\r
- '<p>See the <a href="%s">DocumentationIndex</a>'\r
- % 'http://code.google.com/p/hooke/wiki/DocumentationIndex',\r
- 'for more information</p>',\r
- ]\r
- ctrl.SetPage('\n'.join(lines))\r
- return ctrl\r
-\r
-\r
-class NavBar (wx.ToolBar):\r
- def __init__(self, *args, **kwargs):\r
- super(NavBar, self).__init__(*args, **kwargs)\r
- self.SetToolBitmapSize(wx.Size(16,16))\r
- self._c = {\r
- 'previous': self.AddLabelTool(\r
- id=wx.ID_PREVIEW_PREVIOUS,\r
- label='Previous',\r
- bitmap=wx.ArtProvider_GetBitmap(\r
- wx.ART_GO_BACK, wx.ART_OTHER, wx.Size(16, 16)),\r
- shortHelp='Previous curve'),\r
- 'next': self.AddLabelTool(\r
- id=wx.ID_PREVIEW_NEXT,\r
- label='Next',\r
- bitmap=wx.ArtProvider_GetBitmap(\r
- wx.ART_GO_FORWARD, wx.ART_OTHER, wx.Size(16, 16)),\r
- shortHelp='Next curve'),\r
- }\r
- self.Realize()\r
-\r
-\r
-class FileMenu (wx.Menu):\r
- def __init__(self, *args, **kwargs):\r
- super(FileMenu, self).__init__(*args, **kwargs)\r
- self._c = {'exit': self.Append(wx.ID_EXIT)}\r
-\r
-\r
-class ViewMenu (wx.Menu):\r
- def __init__(self, *args, **kwargs):\r
- super(ViewMenu, self).__init__(*args, **kwargs)\r
- self._c = {\r
- 'folders': self.AppendCheckItem(id=wx.ID_ANY, text='Folders\tF5'),\r
- 'playlist': self.AppendCheckItem(\r
- id=wx.ID_ANY, text='Playlists\tF6'),\r
- 'commands': self.AppendCheckItem(\r
- id=wx.ID_ANY, text='Commands\tF7'),\r
- 'assistant': self.AppendCheckItem(\r
- id=wx.ID_ANY, text='Assistant\tF9'),\r
- 'properties': self.AppendCheckItem(\r
- id=wx.ID_ANY, text='Properties\tF8'),\r
- 'results': self.AppendCheckItem(id=wx.ID_ANY, text='Results\tF10'),\r
- 'output': self.AppendCheckItem(id=wx.ID_ANY, text='Output\tF11'),\r
- 'note': self.AppendCheckItem(id=wx.ID_ANY, text='Note\tF12'),\r
- }\r
- for item in self._c.values():\r
- item.Check()\r
-\r
-\r
-class PerspectiveMenu (wx.Menu):\r
- def __init__(self, *args, **kwargs):\r
- super(PerspectiveMenu, self).__init__(*args, **kwargs)\r
- self._c = {}\r
-\r
- def update(self, perspectives, selected, callback):\r
- """Rebuild the perspectives menu.\r
- """\r
- for item in self.GetMenuItems():\r
- self.UnBind(item)\r
- self.DeleteItem(item)\r
- self._c = {\r
- 'save': self.Append(id=wx.ID_ANY, text='Save Perspective'),\r
- 'delete': self.Append(id=wx.ID_ANY, text='Delete Perspective'),\r
- }\r
- self.AppendSeparator()\r
- for label in perspectives:\r
- self._c[label] = self.AppendRadioItem(id=wx.ID_ANY, text=label)\r
- self.Bind(wx.EVT_MENU, callback, self._c[label])\r
- if label == selected:\r
- self._c[label].Check(True)\r
- \r
-\r
-class HelpMenu (wx.Menu):\r
- def __init__(self, *args, **kwargs):\r
- super(HelpMenu, self).__init__(*args, **kwargs)\r
- self._c = {'about':self.Append(id=wx.ID_ABOUT)}\r
-\r
-\r
-class MenuBar (wx.MenuBar):\r
- def __init__(self, *args, **kwargs):\r
- super(MenuBar, self).__init__(*args, **kwargs)\r
- self._c = {\r
- 'file': FileMenu(),\r
- 'view': ViewMenu(),\r
- 'perspective': PerspectiveMenu(),\r
- 'help': HelpMenu(),\r
- }\r
- self.Append(self._c['file'], 'File')\r
- self.Append(self._c['view'], 'View')\r
- self.Append(self._c['perspective'], 'Perspective')\r
- self.Append(self._c['help'], 'Help')\r
-\r
-\r
-class StatusBar (wx.StatusBar):\r
- def __init__(self, *args, **kwargs):\r
- super(StatusBar, self).__init__(*args, **kwargs)\r
- self.SetStatusWidths([-2, -3])\r
- self.SetStatusText('Ready', 0)\r
- self.SetStatusText(u'Welcome to Hooke (version %s)' % version(), 1)\r
+from . import statusbar as statusbar\r
\r
\r
class HookeFrame (wx.Frame):\r
- def __init__(self, gui, commands, *args, **kwargs):\r
+ """The main Hooke-interface window.\r
+\r
+ \r
+ """\r
+ def __init__(self, gui, commands, inqueue, outqueue, *args, **kwargs):\r
super(HookeFrame, self).__init__(*args, **kwargs)\r
self.gui = gui\r
self.commands = commands\r
+ self.inqueue = inqueue\r
+ self.outqueue = outqueue\r
self._perspectives = {} # {name: perspective_str}\r
self._c = {}\r
\r
\r
# Create the menubar after the panes so that the default\r
# perspective is created with all panes open\r
- self._c['menu bar'] = MenuBar(\r
+ self._c['menu bar'] = menu.MenuBar(\r
+ callbacks={},\r
)\r
self.SetMenuBar(self._c['menu bar'])\r
\r
- self._c['status bar'] = StatusBar(self, style=wx.ST_SIZEGRIP)\r
+ self._c['status bar'] = statubar.StatusBar(\r
+ parent=self,\r
+ style=wx.ST_SIZEGRIP)\r
\r
self._update_perspectives()\r
self._bind_events()\r
self._c['manager'].AddPane(panel, info)\r
\r
def _setup_toolbars(self):\r
- self._c['navbar'] = NavBar(self, style=wx.TB_FLAT | wx.TB_NODIVIDER)\r
+ self._c['navbar'] = navbar.NavBar(\r
+ callbacks={\r
+ 'next': self._next_curve,\r
+ 'previous': self._previous_curve,\r
+ },\r
+ parent=self,\r
+ style=wx.TB_FLAT | wx.TB_NODIVIDER)\r
\r
self._c['manager'].AddPane(\r
self._c['navbar'],\r
self.Bind(wx.EVT_MENU, self._on_delete_perspective,\r
self._c['menu bar']._c['perspective']._c['delete'])\r
\r
- self.Bind(wx.EVT_TOOL, self._on_next, self._c['navbar']._c['next'])\r
- self.Bind(wx.EVT_TOOL, self._on_previous,self._c['navbar']._c['previous'])\r
-\r
treeCtrl = self._c['folders'].GetTreeCtrl()\r
treeCtrl.Bind(wx.EVT_LEFT_DCLICK, self._on_dir_ctrl_left_double_click)\r
\r
def _on_erase_background(self, event):\r
event.Skip()\r
\r
- def OnExit(self, event):\r
- self.Close()\r
-\r
- def _on_next(self, event):\r
+ def _next_curve(self, *args):\r
'''\r
NEXT\r
Go to the next curve in the playlist.\r
playlist = self.GetActivePlaylist()\r
if playlist.count > 1:\r
playlist.next()\r
- self.statusbar.SetStatusText(playlist.get_status_string(), 0)\r
+ self._c['status bar'].set_playlist(playlist)\r
self.UpdateNote()\r
self.UpdatePlot()\r
\r
- def _on_notebook_page_close(self, event):\r
- ctrl = event.GetEventObject()\r
- playlist_name = ctrl.GetPageText(ctrl._curpage)\r
- self.DeleteFromPlaylists(playlist_name)\r
-\r
- def OnPaneClose(self, event):\r
- event.Skip()\r
-\r
- def _on_previous(self, event):\r
+ def _previous_curve(self, *args):\r
'''\r
PREVIOUS\r
Go to the previous curve in the playlist.\r
playlist = self.GetActivePlaylist()\r
if playlist.count > 1:\r
playlist.previous()\r
- self.statusbar.SetStatusText(playlist.get_status_string(), 0)\r
+ self._c['status bar'].set_playlist(playlist)\r
self.UpdateNote()\r
self.UpdatePlot()\r
\r
+ def _on_notebook_page_close(self, event):\r
+ ctrl = event.GetEventObject()\r
+ playlist_name = ctrl.GetPageText(ctrl._curpage)\r
+ self.DeleteFromPlaylists(playlist_name)\r
+\r
+ def OnPaneClose(self, event):\r
+ event.Skip()\r
+\r
def OnPropGridChanged (self, event):\r
prop = event.GetProperty()\r
if prop:\r
playlist = self.GetActivePlaylist()\r
if playlist is not None:\r
if playlist.index >= 0:\r
- self.statusbar.SetStatusText(playlist.get_status_string(), 0)\r
+ self._c['status bar'].set_playlist(playlist)\r
self.UpdateNote()\r
self.UpdatePlot()\r
\r
playlist.figure = plotPanel.get_figure()\r
self.playlists[playlist.name] = playlist\r
#self.playlists[playlist.name] = [playlist, figure]\r
- self.statusbar.SetStatusText(playlist.get_status_string(), 0)\r
+ self._c['status bar'].set_playlist(playlist)\r
self.UpdateNote()\r
self.UpdatePlot()\r
\r
if current_playlist != playlist_name:\r
index = self._GetPlaylistTab(playlist_name)\r
self._c['notebook'].SetSelection(index)\r
- self.statusbar.SetStatusText(playlist.get_status_string(), 0)\r
+ self._c['status bar'].set_playlist(playlist)\r
self.UpdateNote()\r
self.UpdatePlot()\r
\r
\r
\r
class HookeApp (wx.App):\r
+ """A :class:`wx.App` wrapper around :class:`HookeFrame`.\r
+\r
+ Tosses up a splash screen and then loads :class:`HookeFrame` in\r
+ its own window.\r
+ """\r
def __init__(self, gui, commands, inqueue, outqueue, *args, **kwargs):\r
self.gui = gui\r
self.commands = commands\r
\r
self._c = {\r
'frame': HookeFrame(\r
- self.gui, self.commands, parent=None, title='Hooke',\r
+ self.gui, self.commands, self.inqueue, self.outqueue,\r
+ parent=None, title='Hooke',\r
pos=(left, top), size=(width, height),\r
style=wx.DEFAULT_FRAME_STYLE|wx.SUNKEN_BORDER|wx.CLIP_CHILDREN),\r
}\r
sleepFactor = 1.2\r
time.sleep(sleepFactor * duration / 1000)\r
\r
- def OnExit(self):\r
- return True\r
-\r
\r
class GUI (UserInterface):\r
"""wxWindows graphical user interface.\r
--- /dev/null
+# Copyright
+
+"""Menu bar for Hooke.
+"""
+
+import wx
+
+
+class FileMenu (wx.Menu):
+ def __init__(self, *args, **kwargs):
+ super(FileMenu, self).__init__(*args, **kwargs)
+ self._c = {'exit': self.Append(wx.ID_EXIT)}
+
+
+class ViewMenu (wx.Menu):
+ def __init__(self, *args, **kwargs):
+ super(ViewMenu, self).__init__(*args, **kwargs)
+ self._c = {
+ 'folders': self.AppendCheckItem(id=wx.ID_ANY, text='Folders\tF5'),
+ 'playlist': self.AppendCheckItem(
+ id=wx.ID_ANY, text='Playlists\tF6'),
+ 'commands': self.AppendCheckItem(
+ id=wx.ID_ANY, text='Commands\tF7'),
+ 'assistant': self.AppendCheckItem(
+ id=wx.ID_ANY, text='Assistant\tF9'),
+ 'properties': self.AppendCheckItem(
+ id=wx.ID_ANY, text='Properties\tF8'),
+ 'results': self.AppendCheckItem(id=wx.ID_ANY, text='Results\tF10'),
+ 'output': self.AppendCheckItem(id=wx.ID_ANY, text='Output\tF11'),
+ 'note': self.AppendCheckItem(id=wx.ID_ANY, text='Note\tF12'),
+ }
+ for item in self._c.values():
+ item.Check()
+
+
+class PerspectiveMenu (wx.Menu):
+ def __init__(self, *args, **kwargs):
+ super(PerspectiveMenu, self).__init__(*args, **kwargs)
+ self._c = {}
+
+ def update(self, perspectives, selected, callback):
+ """Rebuild the perspectives menu.
+ """
+ for item in self.GetMenuItems():
+ self.UnBind(item)
+ self.DeleteItem(item)
+ self._c = {
+ 'save': self.Append(id=wx.ID_ANY, text='Save Perspective'),
+ 'delete': self.Append(id=wx.ID_ANY, text='Delete Perspective'),
+ }
+ self.AppendSeparator()
+ for label in perspectives:
+ self._c[label] = self.AppendRadioItem(id=wx.ID_ANY, text=label)
+ self.Bind(wx.EVT_MENU, callback, self._c[label])
+ if label == selected:
+ self._c[label].Check(True)
+
+
+class HelpMenu (wx.Menu):
+ def __init__(self, *args, **kwargs):
+ super(HelpMenu, self).__init__(*args, **kwargs)
+ self._c = {'about':self.Append(id=wx.ID_ABOUT)}
+
+
+class MenuBar (wx.MenuBar):
+ def __init__(self, *args, **kwargs):
+ super(MenuBar, self).__init__(*args, **kwargs)
+ self._c = {
+ 'file': FileMenu(),
+ 'view': ViewMenu(),
+ 'perspective': PerspectiveMenu(),
+ 'help': HelpMenu(),
+ }
+ self.Append(self._c['file'], 'File')
+ self.Append(self._c['view'], 'View')
+ self.Append(self._c['perspective'], 'Perspective')
+ self.Append(self._c['help'], 'Help')