Cleaning up hooke.ui.gui. Can initialize, but without most bindings.
authorW. Trevor King <wking@drexel.edu>
Sat, 24 Jul 2010 18:06:50 +0000 (14:06 -0400)
committerW. Trevor King <wking@drexel.edu>
Sat, 24 Jul 2010 18:06:50 +0000 (14:06 -0400)
Following the wxPython style guide:
  http://wiki.wxpython.org/wxPython%20Style%20Guide
Most of removing IDs and breaking out GUI elements into their own classes.

hooke/ui/gui/__init__.py
hooke/ui/gui/panel/__init__.py
hooke/ui/gui/panel/commands.py
hooke/ui/gui/panel/note.py
hooke/ui/gui/panel/perspectives.py [deleted file]
hooke/ui/gui/panel/playlist.py
hooke/ui/gui/panel/plot.py
hooke/ui/gui/panel/propertyeditor.py
hooke/ui/gui/panel/results.py
hooke/ui/gui/panel/selection.py [new file with mode: 0644]

index db64594719090084e3e77258d2b64ae2a4a35358..5fcfb145f123a9a5d9fca657a0ceeca87c360cd1 100644 (file)
@@ -3,7 +3,7 @@
 """Defines :class:`GUI` providing a wxWindows interface to Hooke.\r
 """\r
 \r
-WX_GOOD=['2.6','2.8']\r
+WX_GOOD=['2.8']\r
 \r
 import wxversion\r
 wxversion.select(WX_GOOD)\r
@@ -25,272 +25,264 @@ import wx.lib.evtmgr as evtmgr
 \r
 from matplotlib.ticker import FuncFormatter\r
 \r
-from ..command import CommandExit, Exit, Command, Argument, StoreValue\r
-from ..interaction import Request, BooleanRequest, ReloadUserInterfaceConfig\r
-from ..ui import UserInterface, CommandMessage\r
+from ... import version\r
+from ...command import CommandExit, Exit, Command, Argument, StoreValue\r
+from ...config import Setting\r
+from ...interaction import Request, BooleanRequest, ReloadUserInterfaceConfig\r
+from ...ui import UserInterface, CommandMessage\r
+from . import panel as panel\r
+from . import prettyformat as prettyformat\r
 \r
-import lib.prettyformat\r
-import .panel as panel\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
-ID_About = wx.NewId()\r
-ID_Next = wx.NewId()\r
-ID_Previous = wx.NewId()\r
-\r
-ID_ViewAssistant = wx.NewId()\r
-ID_ViewCommands = wx.NewId()\r
-ID_ViewFolders = wx.NewId()\r
-ID_ViewNote = wx.NewId()\r
-ID_ViewOutput = wx.NewId()\r
-ID_ViewPlaylists = wx.NewId()\r
-ID_ViewProperties = wx.NewId()\r
-ID_ViewResults = wx.NewId()\r
-\r
-ID_DeletePerspective = wx.NewId()\r
-ID_SavePerspective = wx.NewId()\r
-\r
-ID_FirstPerspective = ID_SavePerspective + 1000\r
-#I hope we'll never have more than 1000 perspectives\r
-ID_FirstPlot = ID_SavePerspective + 2000\r
-\r
-class Hooke(wx.App):\r
-\r
-    def OnInit(self):\r
-        self.SetAppName('Hooke')\r
-        self.SetVendorName('')\r
-\r
-        window_height = config['main']['height']\r
-        window_left= config['main']['left']\r
-        window_top = config['main']['top']\r
-        window_width = config['main']['width']\r
-\r
-        #sometimes, the ini file gets confused and sets 'left'\r
-        #and 'top' to large negative numbers\r
-        #let's catch and fix this\r
-        #keep small negative numbers, the user might want those\r
-        if window_left < -window_width:\r
-            window_left = 0\r
-        if window_top < -window_height:\r
-            window_top = 0\r
-        window_position = (window_left, window_top)\r
-        window_size = (window_width, window_height)\r
-\r
-        #setup the splashscreen\r
-        if config['splashscreen']['show']:\r
-            filename = lh.get_file_path('hooke.jpg', ['resources'])\r
-            if os.path.isfile(filename):\r
-                bitmap = wx.Image(filename).ConvertToBitmap()\r
-                splashStyle = wx.SPLASH_CENTRE_ON_SCREEN|wx.SPLASH_TIMEOUT\r
-                splashDuration = config['splashscreen']['duration']\r
-                wx.SplashScreen(bitmap, splashStyle, splashDuration, None, -1)\r
-                wx.Yield()\r
-                '''\r
-                we need for the splash screen to disappear\r
-                for whatever reason splashDuration and sleep do not correspond to each other\r
-                at least not on Windows\r
-                maybe it's because duration is in milliseconds and sleep in seconds\r
-                thus we need to increase the sleep time a bit\r
-                a factor of 1.2 seems to work quite well\r
-                '''\r
-                sleepFactor = 1.2\r
-                time.sleep(sleepFactor * splashDuration / 1000)\r
-\r
-        plugin_objects = []\r
-        for plugin in config['plugins']:\r
-            if config['plugins'][plugin]:\r
-                filename = ''.join([plugin, '.py'])\r
-                path = lh.get_file_path(filename, ['plugins'])\r
-                if os.path.isfile(path):\r
-                    #get the corresponding filename and path\r
-                    plugin_name = ''.join(['plugins.', plugin])\r
-                    #import the module\r
-                    __import__(plugin_name)\r
-                    #get the file that contains the plugin\r
-                    class_file = getattr(plugins, plugin)\r
-                    #get the class that contains the commands\r
-                    class_object = getattr(class_file, plugin + 'Commands')\r
-                    plugin_objects.append(class_object)\r
-\r
-        def make_command_class(*bases):\r
-            #create metaclass with plugins and plotmanipulators\r
-            return type(HookeFrame)("HookeFramePlugged", bases + (HookeFrame,), {})\r
-        frame = make_command_class(*plugin_objects)(parent=None, id=wx.ID_ANY, title='Hooke', pos=window_position, size=window_size)\r
-        frame.Show(True)\r
-        self.SetTopWindow(frame)\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_ANY,\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_ANY,\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, 'Exit\tCtrl-Q')}\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
+\r
+\r
+class PerspectivesMenu (wx.Menu):\r
+    def __init__(self, *args, **kwargs):\r
+        super(PerspectivesMenu, self).__init__(*args, **kwargs)\r
+        self._c = {}\r
+\r
+    def update(self, perspectives, selected):\r
+        """Rebuild the perspectives menu.\r
+        """\r
+        for item in self.GetMenuItems():\r
+            self.DeleteItem(item)\r
+        self._c = {\r
+            'save': self.Append(item='Save Perspective'),\r
+            'delete': self.Append(item='Delete Perspective'),\r
+            }\r
+        self.AppendSeparator()\r
+        for label in perspectives:\r
+            self._c[label] = menu.AppendRadioItem(item=label)\r
+            if label == selected_perspective:\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_ANY, text='About Hooke')}\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
+            'perspectives': PerspectivesMenu(),\r
+            'help': HelpMenu(),\r
+            }\r
+        self.Append(self._c['file'], 'File')\r
+        self.Append(self._c['view'], 'View')\r
+        self.Append(self._c['perspectives'], 'Perspectives')\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
+\r
+\r
+class HookeFrame (wx.Frame):\r
+    def __init__(self, gui, commands, *args, **kwargs):\r
+        super(HookeFrame, self).__init__(*args, **kwargs)\r
+        self.gui = gui\r
+        self.commands = commands\r
+        self._perspectives = {}  # {name: perspective_str}\r
+        self._c = {}\r
+\r
+        self.SetIcon(wx.Icon(self.gui.config['icon image'], wx.BITMAP_TYPE_ICO))\r
+\r
+        # setup frame manager\r
+        self._c['manager'] = aui.AuiManager()\r
+        self._c['manager'].SetManagedWindow(self)\r
+\r
+        # set the gradient and drag styles\r
+        self._c['manager'].GetArtProvider().SetMetric(\r
+            aui.AUI_DOCKART_GRADIENT_TYPE, aui.AUI_GRADIENT_NONE)\r
+        self._c['manager'].SetFlags(\r
+            self._c['manager'].GetFlags() ^ aui.AUI_MGR_TRANSPARENT_DRAG)\r
+\r
+        # Min size for the frame itself isn't completely done.  See\r
+        # the end of FrameManager::Update() for the test code. For\r
+        # now, just hard code a frame minimum size.\r
+        self.SetMinSize(wx.Size(500, 500))\r
 \r
-        return True\r
+        self._setup_panels()\r
+        self._setup_toolbars()\r
+        self._c['manager'].Update()  # commit pending changes\r
 \r
-    def OnExit(self):\r
-        return True\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.SetMenuBar(self._c['menu bar'])\r
 \r
+        self._c['status bar'] = StatusBar(self, style=wx.ST_SIZEGRIP)\r
 \r
-class HookeFrame(wx.Frame):\r
-\r
-    def __init__(self, parent, id=-1, title='', pos=wx.DefaultPosition, size=wx.DefaultSize, style=wx.DEFAULT_FRAME_STYLE|wx.SUNKEN_BORDER|wx.CLIP_CHILDREN):\r
-        #call parent constructor\r
-        wx.Frame.__init__(self, parent, id, title, pos, size, style)\r
-        self.config = config\r
-        self.CreateApplicationIcon()\r
-        #self.configs contains: {the name of the Commands file: corresponding ConfigObj}\r
-        self.configs = {}\r
-        #self.displayed_plot holds the currently displayed plot\r
-        self.displayed_plot = None\r
-        #self.playlists contains: {the name of the playlist: [playlist, tabIndex, plotID]}\r
-        self.playlists = {}\r
-        #list of all plotmanipulators\r
-        self.plotmanipulators = []\r
-        #self.plugins contains: {the name of the plugin: [caption, function]}\r
-        self.plugins = {}\r
-        #self.results_str contains the type of results we want to display\r
-        self.results_str = 'wlc'\r
-\r
-        #tell FrameManager to manage this frame\r
-        self._mgr = aui.AuiManager()\r
-        self._mgr.SetManagedWindow(self)\r
-        #set the gradient style\r
-        self._mgr.GetArtProvider().SetMetric(aui.AUI_DOCKART_GRADIENT_TYPE, aui.AUI_GRADIENT_NONE)\r
-        #set transparent drag\r
-        self._mgr.SetFlags(self._mgr.GetFlags() ^ aui.AUI_MGR_TRANSPARENT_DRAG)\r
-\r
-        # set up default notebook style\r
-        self._notebook_style = aui.AUI_NB_DEFAULT_STYLE | aui.AUI_NB_TAB_EXTERNAL_MOVE | wx.NO_BORDER\r
-        self._notebook_theme = 0\r
-\r
-        #holds the perspectives: {name, perspective_str}\r
-        self._perspectives = {}\r
+        self._bind_events()\r
 \r
-        # min size for the frame itself isn't completely done.\r
-        # see the end up FrameManager::Update() for the test\r
-        # code. For now, just hard code a frame minimum size\r
-        self.SetMinSize(wx.Size(500, 500))\r
-        #define the list of active drivers\r
-        self.drivers = []\r
-        for driver in self.config['drivers']:\r
-            if self.config['drivers'][driver]:\r
-                #get the corresponding filename and path\r
-                filename = ''.join([driver, '.py'])\r
-                path = lh.get_file_path(filename, ['drivers'])\r
-                #the driver is active for driver[1] == 1\r
-                if os.path.isfile(path):\r
-                    #driver files are located in the 'drivers' subfolder\r
-                    driver_name = ''.join(['drivers.', driver])\r
-                    __import__(driver_name)\r
-                    class_file = getattr(drivers, driver)\r
-                    for command in dir(class_file):\r
-                        if command.endswith('Driver'):\r
-                            self.drivers.append(getattr(class_file, command))\r
-        #import all active plugins and plotmanips\r
-        #add 'core.ini' to self.configs (this is not a plugin and thus must be imported separately)\r
-        ini_path = lh.get_file_path('core.ini', ['plugins'])\r
-        plugin_config = ConfigObj(ini_path)\r
-        #self.config.merge(plugin_config)\r
-        self.configs['core'] = plugin_config\r
-        #existing_commands contains: {command: plugin}\r
-        existing_commands = {}\r
-        #make sure we execute _plug_init() for every command line plugin we import\r
-        for plugin in self.config['plugins']:\r
-            if self.config['plugins'][plugin]:\r
-                filename = ''.join([plugin, '.py'])\r
-                path = lh.get_file_path(filename, ['plugins'])\r
-                if os.path.isfile(path):\r
-                    #get the corresponding filename and path\r
-                    plugin_name = ''.join(['plugins.', plugin])\r
-                    try:\r
-                        #import the module\r
-                        module = __import__(plugin_name)\r
-                        #prepare the ini file for inclusion\r
-                        ini_path = path.replace('.py', '.ini')\r
-                        #include ini file\r
-                        plugin_config = ConfigObj(ini_path)\r
-                        #self.config.merge(plugin_config)\r
-                        self.configs[plugin] = plugin_config\r
-                        #add to plugins\r
-                        commands = eval('dir(module.' + plugin+ '.' + plugin + 'Commands)')\r
-                        #keep only commands (ie names that start with 'do_')\r
-                        commands = [command for command in commands if command.startswith('do_')]\r
-                        if commands:\r
-                            for command in commands:\r
-                                if existing_commands.has_key(command):\r
-                                    message_str = 'Adding "' + command + '" in plugin "' + plugin + '".\n\n'\r
-                                    message_str += '"' + command + '" already exists in "' + str(existing_commands[command]) + '".\n\n'\r
-                                    message_str += 'Only "' + command + '" in "' + str(existing_commands[command]) + '" will work.\n\n'\r
-                                    message_str += 'Please rename one of the commands in the source code and restart Hooke or disable one of the plugins.'\r
-                                    dialog = wx.MessageDialog(self, message_str, 'Warning', wx.OK|wx.ICON_WARNING|wx.CENTER)\r
-                                    dialog.ShowModal()\r
-                                    dialog.Destroy()\r
-                                existing_commands[command] = plugin\r
-                            self.plugins[plugin] = commands\r
-                        try:\r
-                            #initialize the plugin\r
-                            eval('module.' + plugin+ '.' + plugin + 'Commands._plug_init(self)')\r
-                        except AttributeError:\r
-                            pass\r
-                    except ImportError:\r
-                        pass\r
-        #add commands from hooke.py i.e. 'core' commands\r
-        commands = dir(HookeFrame)\r
-        commands = [command for command in commands if command.startswith('do_')]\r
-        if commands:\r
-            self.plugins['core'] = commands\r
-        #create panels here\r
-        self.panelAssistant = self.CreatePanelAssistant()\r
-        self.panelCommands = self.CreatePanelCommands()\r
-        self.panelFolders = self.CreatePanelFolders()\r
-        self.panelPlaylists = self.CreatePanelPlaylists()\r
-        self.panelProperties = self.CreatePanelProperties()\r
-        self.panelNote = self.CreatePanelNote()\r
-        self.panelOutput = self.CreatePanelOutput()\r
-        self.panelResults = self.CreatePanelResults()\r
-        self.plotNotebook = self.CreateNotebook()\r
-\r
-        # add panes\r
-        self._mgr.AddPane(self.panelFolders, aui.AuiPaneInfo().Name('Folders').Caption('Folders').Left().CloseButton(True).MaximizeButton(False))\r
-        self._mgr.AddPane(self.panelPlaylists, aui.AuiPaneInfo().Name('Playlists').Caption('Playlists').Left().CloseButton(True).MaximizeButton(False))\r
-        self._mgr.AddPane(self.panelNote, aui.AuiPaneInfo().Name('Note').Caption('Note').Left().CloseButton(True).MaximizeButton(False))\r
-        self._mgr.AddPane(self.plotNotebook, aui.AuiPaneInfo().Name('Plots').CenterPane().PaneBorder(False))\r
-        self._mgr.AddPane(self.panelCommands, aui.AuiPaneInfo().Name('Commands').Caption('Settings and commands').Right().CloseButton(True).MaximizeButton(False))\r
-        self._mgr.AddPane(self.panelProperties, aui.AuiPaneInfo().Name('Properties').Caption('Properties').Right().CloseButton(True).MaximizeButton(False))\r
-        self._mgr.AddPane(self.panelAssistant, aui.AuiPaneInfo().Name('Assistant').Caption('Assistant').Right().CloseButton(True).MaximizeButton(False))\r
-        self._mgr.AddPane(self.panelOutput, aui.AuiPaneInfo().Name('Output').Caption('Output').Bottom().CloseButton(True).MaximizeButton(False))\r
-        self._mgr.AddPane(self.panelResults, aui.AuiPaneInfo().Name('Results').Caption('Results').Bottom().CloseButton(True).MaximizeButton(False))\r
-        #self._mgr.AddPane(self.textCtrlCommandLine, aui.AuiPaneInfo().Name('CommandLine').CaptionVisible(False).Fixed().Bottom().Layer(2).CloseButton(False).MaximizeButton(False))\r
-        #self._mgr.AddPane(panelBottom, aui.AuiPaneInfo().Name("panelCommandLine").Bottom().Position(1).CloseButton(False).MaximizeButton(False))\r
-\r
-        # add the toolbars to the manager\r
-        #self.toolbar=self.CreateToolBar()\r
-        self.toolbarNavigation=self.CreateToolBarNavigation()\r
-        #self._mgr.AddPane(self.toolbar, aui.AuiPaneInfo().Name('toolbar').Caption('Toolbar').ToolbarPane().Top().Layer(1).Row(1).LeftDockable(False).RightDockable(False))\r
-        self._mgr.AddPane(self.toolbarNavigation, aui.AuiPaneInfo().Name('toolbarNavigation').Caption('Navigation').ToolbarPane().Top().Layer(1).Row(1).LeftDockable(False).RightDockable(False))\r
-        # "commit" all changes made to FrameManager\r
-        self._mgr.Update()\r
-        #create the menubar after the panes so that the default perspective\r
-        #is created with all panes open\r
-        self.CreateMenuBar()\r
-        self.statusbar = self.CreateStatusbar()\r
-        self._BindEvents()\r
-\r
-        name = self.config['perspectives']['active']\r
+        self._update_perspectives()\r
+        name = self.gui.config['active perspective']\r
+        return # TODO: cleanup\r
         menu_item = self.GetPerspectiveMenuItem(name)\r
         if menu_item is not None:\r
             self.OnRestorePerspective(menu_item)\r
             #TODO: config setting to remember playlists from last session\r
-        self.playlists = self.panelPlaylists.Playlists\r
-        #initialize the commands tree\r
-        self.panelCommands.Initialize(self.plugins)\r
-        for command in dir(self):\r
-            if command.startswith('plotmanip_'):\r
-                self.plotmanipulators.append(lib.plotmanipulator.Plotmanipulator(method=getattr(self, command), command=command))\r
-\r
+        self.playlists = self._c['playlists'].Playlists\r
+        self._displayed_plot = None\r
         #load default list, if possible\r
         self.do_loadlist(self.GetStringFromConfig('core', 'preferences', 'playlist'))\r
 \r
-    def _BindEvents(self):\r
-        #TODO: figure out if we can use the eventManager for menu ranges\r
-        #and events of 'self' without raising an assertion fail error\r
+    def _setup_panels(self):\r
+        client_size = self.GetClientSize()\r
+        for label,p,style in [\r
+            ('folders', wx.GenericDirCtrl(\r
+                    parent=self,\r
+                    dir=self.gui.config['folders-workdir'],\r
+                    size=(200, 250),\r
+                    style=wx.DIRCTRL_SHOW_FILTERS,\r
+                    filter=self.gui.config['folders-filters'],\r
+                    defaultFilter=int(self.gui.config['folders-filter-index'])), 'left'),  #HACK: config should convert\r
+            ('playlists', panel.playlist.Playlist(self), 'left'),\r
+            ('note', panel.note.Note(self), 'left'),\r
+            ('notebook', Notebook(\r
+                    parent=self,\r
+                    pos=wx.Point(client_size.x, client_size.y),\r
+                    size=wx.Size(430, 200),\r
+                    style=aui.AUI_NB_DEFAULT_STYLE\r
+                    | aui.AUI_NB_TAB_EXTERNAL_MOVE | wx.NO_BORDER), 'center'),\r
+            ('commands', panel.commands.Commands(\r
+                    commands=self.commands,\r
+                    selected=self.gui.config['selected command'],\r
+                    parent=self,\r
+                    style=wx.WANTS_CHARS|wx.NO_BORDER,\r
+                    # WANTS_CHARS so the panel doesn't eat the Return key.\r
+                    size=(160, 200)), 'right'),\r
+            #('properties', panel.propertyeditor.PropertyEditor(self),'right'),\r
+            ('assistant', wx.TextCtrl(\r
+                    parent=self,\r
+                    pos=wx.Point(0, 0),\r
+                    size=wx.Size(150, 90),\r
+                    style=wx.NO_BORDER|wx.TE_MULTILINE), 'right'),\r
+            ('output', wx.TextCtrl(\r
+                    parent=self,\r
+                    pos=wx.Point(0, 0),\r
+                    size=wx.Size(150, 90),\r
+                    style=wx.NO_BORDER|wx.TE_MULTILINE), 'bottom'),\r
+            ('results', panel.results.Results(self), 'bottom'),\r
+            ]:\r
+            self._add_panel(label, p, style)\r
+        self._c['assistant'].SetEditable(False)\r
+\r
+    def _add_panel(self, label, panel, style):\r
+        self._c[label] = panel\r
+        cap_label = label.capitalize()\r
+        info = aui.AuiPaneInfo().Name(cap_label).Caption(cap_label)\r
+        if style == 'left':\r
+            info.Left().CloseButton(True).MaximizeButton(False)\r
+        elif style == 'center':\r
+            info.CenterPane().PaneBorder(False)\r
+        elif style == 'right':\r
+            info.Right().CloseButton(True).MaximizeButton(False)\r
+        else:\r
+            assert style == 'bottom', style\r
+            info.Bottom().CloseButton(True).MaximizeButton(False)\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
+\r
+        self._c['manager'].AddPane(\r
+            self._c['navbar'],\r
+            aui.AuiPaneInfo().Name('Navigation').Caption('Navigation'\r
+                ).ToolbarPane().Top().Layer(1).Row(1).LeftDockable(False\r
+                ).RightDockable(False))\r
+\r
+    def _bind_events(self):\r
+        # TODO: figure out if we can use the eventManager for menu\r
+        # ranges and events of 'self' without raising an assertion\r
+        # fail error.\r
         self.Bind(wx.EVT_ERASE_BACKGROUND, self.OnEraseBackground)\r
         self.Bind(wx.EVT_SIZE, self.OnSize)\r
         self.Bind(wx.EVT_CLOSE, self.OnClose)\r
+        return # TODO: cleanup\r
         # Show How To Use The Closing Panes Event\r
         self.Bind(aui.EVT_AUI_PANE_CLOSE, self.OnPaneClose)\r
         self.Bind(aui.EVT_AUINOTEBOOK_PAGE_CLOSE, self.OnNotebookPageClose)\r
@@ -313,12 +305,12 @@ class HookeFrame(wx.Frame):
         #tree.Bind(wx.EVT_LEFT_DOWN, self.OnGenericDirCtrl1LeftDown)\r
         treeCtrl.Bind(wx.EVT_LEFT_DCLICK, self.OnDirCtrlLeftDclick)\r
         #playlist tree\r
-        self.panelPlaylists.PlaylistsTree.Bind(wx.EVT_LEFT_DOWN, self.OnPlaylistsLeftDown)\r
-        self.panelPlaylists.PlaylistsTree.Bind(wx.EVT_LEFT_DCLICK, self.OnPlaylistsLeftDclick)\r
+        self._c['playlists'].PlaylistsTree.Bind(wx.EVT_LEFT_DOWN, self.OnPlaylistsLeftDown)\r
+        self._c['playlists'].PlaylistsTree.Bind(wx.EVT_LEFT_DCLICK, self.OnPlaylistsLeftDclick)\r
         #commands tree\r
-        evtmgr.eventManager.Register(self.OnExecute, wx.EVT_BUTTON, self.panelCommands.ExecuteButton)\r
-        evtmgr.eventManager.Register(self.OnTreeCtrlCommandsSelectionChanged, wx.EVT_TREE_SEL_CHANGED, self.panelCommands.CommandsTree)\r
-        evtmgr.eventManager.Register(self.OnTreeCtrlItemActivated, wx.EVT_TREE_ITEM_ACTIVATED, self.panelCommands.CommandsTree)\r
+        evtmgr.eventManager.Register(self.OnExecute, wx.EVT_BUTTON, self._c['commands'].ExecuteButton)\r
+        evtmgr.eventManager.Register(self.OnTreeCtrlCommandsSelectionChanged, wx.EVT_TREE_SEL_CHANGED, self._c['commands']._c['tree'])\r
+        evtmgr.eventManager.Register(self.OnTreeCtrlItemActivated, wx.EVT_TREE_ITEM_ACTIVATED, self._c['commands']._c['tree'])\r
         evtmgr.eventManager.Register(self.OnUpdateNote, wx.EVT_BUTTON, self.panelNote.UpdateButton)\r
         #property editor\r
         self.panelProperties.pg.Bind(wxpg.EVT_PG_CHANGED, self.OnPropGridChanged)\r
@@ -328,20 +320,20 @@ class HookeFrame(wx.Frame):
     def _GetActiveFileIndex(self):\r
         lib.playlist.Playlist = self.GetActivePlaylist()\r
         #get the selected item from the tree\r
-        selected_item = self.panelPlaylists.PlaylistsTree.GetSelection()\r
+        selected_item = self._c['playlists'].PlaylistsTree.GetSelection()\r
         #test if a playlist or a curve was double-clicked\r
-        if self.panelPlaylists.PlaylistsTree.ItemHasChildren(selected_item):\r
+        if self._c['playlists'].PlaylistsTree.ItemHasChildren(selected_item):\r
             return -1\r
         else:\r
             count = 0\r
-            selected_item = self.panelPlaylists.PlaylistsTree.GetPrevSibling(selected_item)\r
+            selected_item = self._c['playlists'].PlaylistsTree.GetPrevSibling(selected_item)\r
             while selected_item.IsOk():\r
                 count += 1\r
-                selected_item = self.panelPlaylists.PlaylistsTree.GetPrevSibling(selected_item)\r
+                selected_item = self._c['playlists'].PlaylistsTree.GetPrevSibling(selected_item)\r
             return count\r
 \r
     def _GetPlaylistTab(self, name):\r
-        for index, page in enumerate(self.plotNotebook._tabs._pages):\r
+        for index, page in enumerate(self._c['notebook']._tabs._pages):\r
             if page.caption == name:\r
                 return index\r
         return -1\r
@@ -355,10 +347,10 @@ class HookeFrame(wx.Frame):
         return playlist_name\r
 \r
     def _RestorePerspective(self, name):\r
-        self._mgr.LoadPerspective(self._perspectives[name])\r
-        self.config['perspectives']['active'] = name\r
-        self._mgr.Update()\r
-        all_panes = self._mgr.GetAllPanes()\r
+        self._c['manager'].LoadPerspective(self._perspectives[name])\r
+        self.gui.config['active perspective'] = name\r
+        self._c['manager'].Update()\r
+        all_panes = self._c['manager'].GetAllPanes()\r
         for pane in all_panes:\r
             if not pane.name.startswith('toolbar'):\r
                 if pane.name == 'Assistant':\r
@@ -417,8 +409,8 @@ class HookeFrame(wx.Frame):
     def AddToPlaylists(self, playlist):\r
         if playlist.count > 0:\r
             #setup the playlist in the Playlist tree\r
-            tree_root = self.panelPlaylists.PlaylistsTree.GetRootItem()\r
-            playlist_root = self.panelPlaylists.PlaylistsTree.AppendItem(tree_root, playlist.name, 0)\r
+            tree_root = self._c['playlists'].PlaylistsTree.GetRootItem()\r
+            playlist_root = self._c['playlists'].PlaylistsTree.AppendItem(tree_root, playlist.name, 0)\r
             #add all files to the Playlist tree\r
 #            files = {}\r
             hide_curve_extension = self.GetBoolFromConfig('core', 'preferences', 'hide_curve_extension')\r
@@ -426,18 +418,18 @@ class HookeFrame(wx.Frame):
                 #optionally remove the extension from the name of the curve\r
                 if hide_curve_extension:\r
                     file_to_add.name = lh.remove_extension(file_to_add.name)\r
-                file_ID = self.panelPlaylists.PlaylistsTree.AppendItem(playlist_root, file_to_add.name, 1)\r
+                file_ID = self._c['playlists'].PlaylistsTree.AppendItem(playlist_root, file_to_add.name, 1)\r
                 if index == playlist.index:\r
-                    self.panelPlaylists.PlaylistsTree.SelectItem(file_ID)\r
+                    self._c['playlists'].PlaylistsTree.SelectItem(file_ID)\r
             playlist.reset()\r
             #create the plot tab and add playlist to the dictionary\r
-            plotPanel = panels.plot.PlotPanel(self, ID_FirstPlot + len(self.playlists))\r
-            notebook_tab = self.plotNotebook.AddPage(plotPanel, playlist.name, True)\r
-            #tab_index = self.plotNotebook.GetSelection()\r
+            plotPanel = panel.plot.PlotPanel(self, ID_FirstPlot + len(self.playlists))\r
+            notebook_tab = self._c['notebook'].AddPage(plotPanel, playlist.name, True)\r
+            #tab_index = self._c['notebook'].GetSelection()\r
             playlist.figure = plotPanel.get_figure()\r
             self.playlists[playlist.name] = playlist\r
             #self.playlists[playlist.name] = [playlist, figure]\r
-            self.panelPlaylists.PlaylistsTree.Expand(playlist_root)\r
+            self._c['playlists'].PlaylistsTree.Expand(playlist_root)\r
             self.statusbar.SetStatusText(playlist.get_status_string(), 0)\r
             self.UpdateNote()\r
             self.UpdatePlot()\r
@@ -463,136 +455,19 @@ class HookeFrame(wx.Frame):
                     manipulated_plot = plotmanipulator.method(manipulated_plot, plot_file)\r
             return manipulated_plot\r
 \r
-    def CreateApplicationIcon(self):\r
-        iconFile = 'resources' + os.sep + 'microscope.ico'\r
-        icon = wx.Icon(iconFile, wx.BITMAP_TYPE_ICO)\r
-        self.SetIcon(icon)\r
-\r
-    def CreateCommandLine(self):\r
-        return wx.TextCtrl(self, -1, '', style=wx.NO_BORDER|wx.EXPAND)\r
-\r
-    def CreatePanelAssistant(self):\r
-        panel = wx.TextCtrl(self, -1, '', wx.Point(0, 0), wx.Size(150, 90), wx.NO_BORDER|wx.TE_MULTILINE)\r
-        panel.SetEditable(False)\r
-        return panel\r
-\r
-    def CreatePanelCommands(self):\r
-        return panels.commands.Commands(self)\r
-\r
-    def CreatePanelFolders(self):\r
-        #set file filters\r
-        filters = self.config['folders']['filters']\r
-        index = self.config['folders'].as_int('filterindex')\r
-        #set initial directory\r
-        folder = self.GetStringFromConfig('core', 'preferences', 'workdir')\r
-        return wx.GenericDirCtrl(self, -1, dir=folder, size=(200, 250), style=wx.DIRCTRL_SHOW_FILTERS, filter=filters, defaultFilter=index)\r
-\r
-    def CreatePanelNote(self):\r
-        return panels.note.Note(self)\r
-\r
-    def CreatePanelOutput(self):\r
-        return wx.TextCtrl(self, -1, '', wx.Point(0, 0), wx.Size(150, 90), wx.NO_BORDER|wx.TE_MULTILINE)\r
-\r
-    def CreatePanelPlaylists(self):\r
-        return panels.playlist.Playlists(self)\r
-\r
-    def CreatePanelProperties(self):\r
-        return panels.propertyeditor.PropertyEditor(self)\r
-\r
-    def CreatePanelResults(self):\r
-        return panels.results.Results(self)\r
-\r
-    def CreatePanelWelcome(self):\r
-        #TODO: move into panels.welcome\r
-        ctrl = wx.html.HtmlWindow(self, -1, wx.DefaultPosition, wx.Size(400, 300))\r
-        introStr = '<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 by users by means of plugins and drivers</li>' + \\r
-                 '</ul>' + \\r
-                 '<p>See the <a href="http://code.google.com/p/hooke/wiki/DocumentationIndex">DocumentationIndex</a> for more information</p>'\r
-        ctrl.SetPage(introStr)\r
-        return ctrl\r
-\r
-    def CreateMenuBar(self):\r
-        menu_bar = wx.MenuBar()\r
-        self.SetMenuBar(menu_bar)\r
-        #file\r
-        file_menu = wx.Menu()\r
-        file_menu.Append(wx.ID_EXIT, 'Exit\tCtrl-Q')\r
-#        edit_menu.AppendSeparator();\r
-#        edit_menu.Append(ID_Config, 'Preferences')\r
-        #view\r
-        view_menu = wx.Menu()\r
-        view_menu.AppendCheckItem(ID_ViewFolders, 'Folders\tF5')\r
-        view_menu.AppendCheckItem(ID_ViewPlaylists, 'Playlists\tF6')\r
-        view_menu.AppendCheckItem(ID_ViewCommands, 'Commands\tF7')\r
-        view_menu.AppendCheckItem(ID_ViewProperties, 'Properties\tF8')\r
-        view_menu.AppendCheckItem(ID_ViewAssistant, 'Assistant\tF9')\r
-        view_menu.AppendCheckItem(ID_ViewResults, 'Results\tF10')\r
-        view_menu.AppendCheckItem(ID_ViewOutput, 'Output\tF11')\r
-        view_menu.AppendCheckItem(ID_ViewNote, 'Note\tF12')\r
-        #perspectives\r
-        perspectives_menu = wx.Menu()\r
-\r
-        #help\r
-        help_menu = wx.Menu()\r
-        help_menu.Append(wx.ID_ABOUT, 'About Hooke')\r
-        #put it all together\r
-        menu_bar.Append(file_menu, 'File')\r
-        menu_bar.Append(view_menu, 'View')\r
-        menu_bar.Append(perspectives_menu, "Perspectives")\r
-        self.UpdatePerspectivesMenu()\r
-        menu_bar.Append(help_menu, 'Help')\r
-\r
-    def CreateNotebook(self):\r
-        # create the notebook off-window to avoid flicker\r
-        client_size = self.GetClientSize()\r
-        ctrl = aui.AuiNotebook(self, -1, wx.Point(client_size.x, client_size.y), wx.Size(430, 200), self._notebook_style)\r
-        arts = [aui.AuiDefaultTabArt, aui.AuiSimpleTabArt, aui.VC71TabArt, aui.FF2TabArt, aui.VC8TabArt, aui.ChromeTabArt]\r
-        art = arts[self._notebook_theme]()\r
-        ctrl.SetArtProvider(art)\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
-        ctrl.AddPage(self.CreatePanelWelcome(), "Welcome", False)\r
-        return ctrl\r
-\r
-    def CreateStatusbar(self):\r
-        statusbar = self.CreateStatusBar(2, wx.ST_SIZEGRIP)\r
-        statusbar.SetStatusWidths([-2, -3])\r
-        statusbar.SetStatusText('Ready', 0)\r
-        welcomeString=u'Welcome to Hooke (version '+__version__+', '+__release_name__+')!'\r
-        statusbar.SetStatusText(welcomeString, 1)\r
-        return statusbar\r
-\r
-    def CreateToolBarNavigation(self):\r
-        toolbar = wx.ToolBar(self, -1, wx.DefaultPosition, wx.DefaultSize, wx.TB_FLAT | wx.TB_NODIVIDER)\r
-        toolbar.SetToolBitmapSize(wx.Size(16,16))\r
-        toolbar_bmpBack = wx.ArtProvider_GetBitmap(wx.ART_GO_BACK, wx.ART_OTHER, wx.Size(16, 16))\r
-        toolbar_bmpForward = wx.ArtProvider_GetBitmap(wx.ART_GO_FORWARD, wx.ART_OTHER, wx.Size(16, 16))\r
-        toolbar.AddLabelTool(ID_Previous, 'Previous', toolbar_bmpBack, shortHelp='Previous curve')\r
-        toolbar.AddLabelTool(ID_Next, 'Next', toolbar_bmpForward, shortHelp='Next curve')\r
-        toolbar.Realize()\r
-        return toolbar\r
-\r
     def DeleteFromPlaylists(self, name):\r
         if name in self.playlists:\r
             del self.playlists[name]\r
-        tree_root = self.panelPlaylists.PlaylistsTree.GetRootItem()\r
-        item, cookie = self.panelPlaylists.PlaylistsTree.GetFirstChild(tree_root)\r
+        tree_root = self._c['playlists'].PlaylistsTree.GetRootItem()\r
+        item, cookie = self._c['playlists'].PlaylistsTree.GetFirstChild(tree_root)\r
         while item.IsOk():\r
-            playlist_name = self.panelPlaylists.PlaylistsTree.GetItemText(item)\r
+            playlist_name = self._c['playlists'].PlaylistsTree.GetItemText(item)\r
             if playlist_name == name:\r
                 try:\r
-                    self.panelPlaylists.PlaylistsTree.Delete(item)\r
+                    self._c['playlists'].PlaylistsTree.Delete(item)\r
                 except:\r
                     pass\r
-            item = self.panelPlaylists.PlaylistsTree.GetNextSibling(item)\r
+            item = self._c['playlists'].PlaylistsTree.GetNextSibling(item)\r
 \r
     def GetActiveFigure(self):\r
         playlist_name = self.GetActivePlaylistName()\r
@@ -615,15 +490,15 @@ class HookeFrame(wx.Frame):
 \r
     def GetActivePlaylistName(self):\r
         #get the selected item from the tree\r
-        selected_item = self.panelPlaylists.PlaylistsTree.GetSelection()\r
+        selected_item = self._c['playlists'].PlaylistsTree.GetSelection()\r
         #test if a playlist or a curve was double-clicked\r
-        if self.panelPlaylists.PlaylistsTree.ItemHasChildren(selected_item):\r
+        if self._c['playlists'].PlaylistsTree.ItemHasChildren(selected_item):\r
             playlist_item = selected_item\r
         else:\r
             #get the name of the playlist\r
-            playlist_item = self.panelPlaylists.PlaylistsTree.GetItemParent(selected_item)\r
+            playlist_item = self._c['playlists'].PlaylistsTree.GetItemParent(selected_item)\r
         #now we have a playlist\r
-        return self.panelPlaylists.PlaylistsTree.GetItemText(playlist_item)\r
+        return self._c['playlists'].PlaylistsTree.GetItemText(playlist_item)\r
 \r
     def GetActivePlot(self):\r
         playlist = self.GetActivePlaylist()\r
@@ -650,79 +525,7 @@ class HookeFrame(wx.Frame):
         return plot\r
 \r
     def GetDockArt(self):\r
-        return self._mgr.GetArtProvider()\r
-\r
-    def GetBoolFromConfig(self, *args):\r
-        if len(args) == 2:\r
-            plugin = args[0]\r
-            section = args[0]\r
-            key = args[1]\r
-        elif len(args) == 3:\r
-            plugin = args[0]\r
-            section = args[1]\r
-            key = args[2]\r
-        if self.configs.has_key(plugin):\r
-            config = self.configs[plugin]\r
-            return config[section][key].as_bool('value')\r
-        return None\r
-\r
-    def GetColorFromConfig(self, *args):\r
-        if len(args) == 2:\r
-            plugin = args[0]\r
-            section = args[0]\r
-            key = args[1]\r
-        elif len(args) == 3:\r
-            plugin = args[0]\r
-            section = args[1]\r
-            key = args[2]\r
-        if self.configs.has_key(plugin):\r
-            config = self.configs[plugin]\r
-            color_tuple = eval(config[section][key]['value'])\r
-            color = [value / 255.0 for value in color_tuple]\r
-            return color\r
-        return None\r
-\r
-    def GetFloatFromConfig(self, *args):\r
-        if len(args) == 2:\r
-            plugin = args[0]\r
-            section = args[0]\r
-            key = args[1]\r
-        elif len(args) == 3:\r
-            plugin = args[0]\r
-            section = args[1]\r
-            key = args[2]\r
-        if self.configs.has_key(plugin):\r
-            config = self.configs[plugin]\r
-            return config[section][key].as_float('value')\r
-        return None\r
-\r
-    def GetIntFromConfig(self, *args):\r
-        if len(args) == 2:\r
-            plugin = args[0]\r
-            section = args[0]\r
-            key = args[1]\r
-        elif len(args) == 3:\r
-            plugin = args[0]\r
-            section = args[1]\r
-            key = args[2]\r
-        if self.configs.has_key(plugin):\r
-            config = self.configs[plugin]\r
-            return config[section][key].as_int('value')\r
-        return None\r
-\r
-    def GetStringFromConfig(self, *args):\r
-        if len(args) == 2:\r
-            plugin = args[0]\r
-            section = args[0]\r
-            key = args[1]\r
-        elif len(args) == 3:\r
-            plugin = args[0]\r
-            section = args[1]\r
-            key = args[2]\r
-        if self.configs.has_key(plugin):\r
-            config = self.configs[plugin]\r
-            return config[section][key]['value']\r
-        return None\r
+        return self._c['manager'].GetArtProvider()\r
 \r
     def GetPlotmanipulator(self, name):\r
         '''\r
@@ -764,31 +567,45 @@ class HookeFrame(wx.Frame):
         dialog.Destroy()\r
 \r
     def OnClose(self, event):\r
-        #apply changes\r
-        self.config['main']['height'] = str(self.GetSize().GetHeight())\r
-        self.config['main']['left'] = str(self.GetPosition()[0])\r
-        self.config['main']['top'] = str(self.GetPosition()[1])\r
-        self.config['main']['width'] = str(self.GetSize().GetWidth())\r
-        #save the configuration file to 'config/hooke.ini'\r
-        self.config.write()\r
-        #save all plugin config files\r
-        for config in self.configs:\r
-            plugin_config = self.configs[config]\r
-            plugin_config.write()\r
+        # apply changes\r
+        self.gui.config['main height'] = str(self.GetSize().GetHeight())\r
+        self.gui.config['main left'] = str(self.GetPosition()[0])\r
+        self.gui.config['main top'] = str(self.GetPosition()[1])\r
+        self.gui.config['main width'] = str(self.GetSize().GetWidth())\r
+        # push changes back to Hooke.config?\r
         self._UnbindEvents()\r
-        self._mgr.UnInit()\r
-        del self._mgr\r
+        self._c['manager'].UnInit()\r
+        del self._c['manager']\r
         self.Destroy()\r
 \r
     def OnDeletePerspective(self, event):\r
-        dialog = panels.perspectives.Perspectives(self, -1, 'Delete perspective(s)')\r
+        dialog = panel.selection.Selection(\r
+            options=sorted(os.listdir(self.gui.config['perspective-path'])),\r
+            message="\nPlease check the perspectives\n\nyou want to delete and click 'Delete'.\n",\r
+            button_id=wx.ID_DELETE,\r
+            button_callback=self._on_delete_perspective,\r
+            parent=self,\r
+            label='Delete perspective(s)',\r
+            style=wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER)\r
         dialog.CenterOnScreen()\r
         dialog.ShowModal()\r
         dialog.Destroy()\r
-        self.UpdatePerspectivesMenu()\r
-        #unfortunately, there is a bug in wxWidgets (Ticket #3258) that\r
-        #makes the radio item indicator in the menu disappear\r
-        #the code should be fine once this issue is fixed\r
+        self._c['menu bar']['perspectives'].update(\r
+            sorted(self._perspectives.keys),\r
+            self.gui.config['active perspective'])\r
+        # Unfortunately, there is a bug in wxWidgets for win32 (Ticket #3258\r
+        #   http://trac.wxwidgets.org/ticket/3258 \r
+        # ) that makes the radio item indicator in the menu disappear.\r
+        # The code should be fine once this issue is fixed.\r
+\r
+    def _on_delete_perspective(self, event, items, selected_items):\r
+        for item in selected_items:\r
+            self._perspectives.remove(item)\r
+            if item == self.gui.config['active perspective']:\r
+                self.gui.config['active perspective'] = 'Default'\r
+            path = os.path.join(self.gui.config['perspective-path'],\r
+                                item+'.txt')\r
+            remove(path)\r
 \r
     def OnDirCtrlLeftDclick(self, event):\r
         file_path = self.panelFolders.GetPath()\r
@@ -801,10 +618,10 @@ class HookeFrame(wx.Frame):
         event.Skip()\r
 \r
     def OnExecute(self, event):\r
-        item = self.panelCommands.CommandsTree.GetSelection()\r
+        item = self._c['commands']._c['tree'].GetSelection()\r
         if item.IsOk():\r
-            if not self.panelCommands.CommandsTree.ItemHasChildren(item):\r
-                item_text = self.panelCommands.CommandsTree.GetItemText(item)\r
+            if not self._c['commands']._c['tree'].ItemHasChildren(item):\r
+                item_text = self._c['commands']._c['tree'].GetItemText(item)\r
                 command = ''.join(['self.do_', item_text, '()'])\r
                 #self.AppendToOutput(command + '\n')\r
                 exec(command)\r
@@ -820,20 +637,20 @@ class HookeFrame(wx.Frame):
         -----\r
         Syntax: next, n\r
         '''\r
-        selected_item = self.panelPlaylists.PlaylistsTree.GetSelection()\r
-        if self.panelPlaylists.PlaylistsTree.ItemHasChildren(selected_item):\r
+        selected_item = self._c['playlists'].PlaylistsTree.GetSelection()\r
+        if self._c['playlists'].PlaylistsTree.ItemHasChildren(selected_item):\r
             #GetFirstChild returns a tuple\r
             #we only need the first element\r
-            next_item = self.panelPlaylists.PlaylistsTree.GetFirstChild(selected_item)[0]\r
+            next_item = self._c['playlists'].PlaylistsTree.GetFirstChild(selected_item)[0]\r
         else:\r
-            next_item = self.panelPlaylists.PlaylistsTree.GetNextSibling(selected_item)\r
+            next_item = self._c['playlists'].PlaylistsTree.GetNextSibling(selected_item)\r
             if not next_item.IsOk():\r
-                parent_item = self.panelPlaylists.PlaylistsTree.GetItemParent(selected_item)\r
+                parent_item = self._c['playlists'].PlaylistsTree.GetItemParent(selected_item)\r
                 #GetFirstChild returns a tuple\r
                 #we only need the first element\r
-                next_item = self.panelPlaylists.PlaylistsTree.GetFirstChild(parent_item)[0]\r
-        self.panelPlaylists.PlaylistsTree.SelectItem(next_item, True)\r
-        if not self.panelPlaylists.PlaylistsTree.ItemHasChildren(selected_item):\r
+                next_item = self._c['playlists'].PlaylistsTree.GetFirstChild(parent_item)[0]\r
+        self._c['playlists'].PlaylistsTree.SelectItem(next_item, True)\r
+        if not self._c['playlists'].PlaylistsTree.ItemHasChildren(selected_item):\r
             playlist = self.GetActivePlaylist()\r
             if playlist.count > 1:\r
                 playlist.next()\r
@@ -850,20 +667,20 @@ class HookeFrame(wx.Frame):
         event.Skip()\r
 \r
     def OnPlaylistsLeftDclick(self, event):\r
-        if self.panelPlaylists.PlaylistsTree.Count > 0:\r
+        if self._c['playlists'].PlaylistsTree.Count > 0:\r
             playlist_name = self.GetActivePlaylistName()\r
             #if that playlist already exists\r
             #we check if it is the active playlist (ie selected in panelPlaylists)\r
             #and switch to it if necessary\r
             if playlist_name in self.playlists:\r
-                index = self.plotNotebook.GetSelection()\r
-                current_playlist = self.plotNotebook.GetPageText(index)\r
+                index = self._c['notebook'].GetSelection()\r
+                current_playlist = self._c['notebook'].GetPageText(index)\r
                 if current_playlist != playlist_name:\r
                     index = self._GetPlaylistTab(playlist_name)\r
-                    self.plotNotebook.SetSelection(index)\r
+                    self._c['notebook'].SetSelection(index)\r
                 #if a curve was double-clicked\r
-                item = self.panelPlaylists.PlaylistsTree.GetSelection()\r
-                if not self.panelPlaylists.PlaylistsTree.ItemHasChildren(item):\r
+                item = self._c['playlists'].PlaylistsTree.GetSelection()\r
+                if not self._c['playlists'].PlaylistsTree.ItemHasChildren(item):\r
                     index = self._GetActiveFileIndex()\r
                 else:\r
                     index = 0\r
@@ -877,14 +694,14 @@ class HookeFrame(wx.Frame):
             #event.Skip()\r
 \r
     def OnPlaylistsLeftDown(self, event):\r
-        hit_item, hit_flags = self.panelPlaylists.PlaylistsTree.HitTest(event.GetPosition())\r
+        hit_item, hit_flags = self._c['playlists'].PlaylistsTree.HitTest(event.GetPosition())\r
         if (hit_flags & wx.TREE_HITTEST_ONITEM) != 0:\r
-            self.panelPlaylists.PlaylistsTree.SelectItem(hit_item)\r
+            self._c['playlists'].PlaylistsTree.SelectItem(hit_item)\r
             playlist_name = self.GetActivePlaylistName()\r
             playlist = self.GetActivePlaylist()\r
             #if a curve was clicked\r
-            item = self.panelPlaylists.PlaylistsTree.GetSelection()\r
-            if not self.panelPlaylists.PlaylistsTree.ItemHasChildren(item):\r
+            item = self._c['playlists'].PlaylistsTree.GetSelection()\r
+            if not self._c['playlists'].PlaylistsTree.ItemHasChildren(item):\r
                 index = self._GetActiveFileIndex()\r
                 if index >= 0:\r
                     playlist.index = index\r
@@ -902,15 +719,15 @@ class HookeFrame(wx.Frame):
         #playlist = self.playlists[self.GetActivePlaylistName()][0]\r
         #select the previous curve and tell the user if we wrapped around\r
         #self.AppendToOutput(playlist.previous())\r
-        selected_item = self.panelPlaylists.PlaylistsTree.GetSelection()\r
-        if self.panelPlaylists.PlaylistsTree.ItemHasChildren(selected_item):\r
-            previous_item = self.panelPlaylists.PlaylistsTree.GetLastChild(selected_item)\r
+        selected_item = self._c['playlists'].PlaylistsTree.GetSelection()\r
+        if self._c['playlists'].PlaylistsTree.ItemHasChildren(selected_item):\r
+            previous_item = self._c['playlists'].PlaylistsTree.GetLastChild(selected_item)\r
         else:\r
-            previous_item = self.panelPlaylists.PlaylistsTree.GetPrevSibling(selected_item)\r
+            previous_item = self._c['playlists'].PlaylistsTree.GetPrevSibling(selected_item)\r
             if not previous_item.IsOk():\r
-                parent_item = self.panelPlaylists.PlaylistsTree.GetItemParent(selected_item)\r
-                previous_item = self.panelPlaylists.PlaylistsTree.GetLastChild(parent_item)\r
-        self.panelPlaylists.PlaylistsTree.SelectItem(previous_item, True)\r
+                parent_item = self._c['playlists'].PlaylistsTree.GetItemParent(selected_item)\r
+                previous_item = self._c['playlists'].PlaylistsTree.GetLastChild(parent_item)\r
+        self._c['playlists'].PlaylistsTree.SelectItem(previous_item, True)\r
         playlist = self.GetActivePlaylist()\r
         if playlist.count > 1:\r
             playlist.previous()\r
@@ -922,10 +739,10 @@ class HookeFrame(wx.Frame):
         prop = event.GetProperty()\r
         if prop:\r
             item_section = self.panelProperties.SelectedTreeItem\r
-            item_plugin = self.panelCommands.CommandsTree.GetItemParent(item_section)\r
-            plugin = self.panelCommands.CommandsTree.GetItemText(item_plugin)\r
-            config = self.configs[plugin]\r
-            property_section = self.panelCommands.CommandsTree.GetItemText(item_section)\r
+            item_plugin = self._c['commands']._c['tree'].GetItemParent(item_section)\r
+            plugin = self._c['commands']._c['tree'].GetItemText(item_plugin)\r
+            config = self.gui.config[plugin]\r
+            property_section = self._c['commands']._c['tree'].GetItemText(item_section)\r
             property_key = prop.GetName()\r
             property_value = prop.GetDisplayedString()\r
 \r
@@ -968,10 +785,11 @@ class HookeFrame(wx.Frame):
             else:\r
                 done = True\r
 \r
-        perspective = self._mgr.SavePerspective()\r
+        perspective = self._c['manager'].SavePerspective()\r
         self._SavePerspectiveToFile(name, perspective)\r
-        self.config['perspectives']['active'] = name\r
-        self.UpdatePerspectivesMenu()\r
+        self.gui.config['active perspectives'] = name\r
+        self._c['menu bar']['perspectives'].update(\r
+            sorted(self._perspectives.keys), name)\r
 #        if nameExists(name):\r
 #            #check the corresponding menu item\r
 #            menu_item = self.GetPerspectiveMenuItem(name)\r
@@ -1011,25 +829,25 @@ class HookeFrame(wx.Frame):
             section = ''\r
             #deregister/register the listener to avoid infinite loop\r
             evtmgr.eventManager.DeregisterListener(self.OnTreeCtrlCommandsSelectionChanged)\r
-            self.panelCommands.CommandsTree.SelectItem(selected_item)\r
-            evtmgr.eventManager.Register(self.OnTreeCtrlCommandsSelectionChanged, wx.EVT_TREE_SEL_CHANGED, self.panelCommands.CommandsTree)\r
+            self._c['commands']._c['tree'].SelectItem(selected_item)\r
+            evtmgr.eventManager.Register(self.OnTreeCtrlCommandsSelectionChanged, wx.EVT_TREE_SEL_CHANGED, self._c['commands']._c['tree'])\r
             self.panelProperties.SelectedTreeItem = selected_item\r
             #if a command was clicked\r
             properties = []\r
-            if not self.panelCommands.CommandsTree.ItemHasChildren(selected_item):\r
-                item_plugin = self.panelCommands.CommandsTree.GetItemParent(selected_item)\r
-                plugin = self.panelCommands.CommandsTree.GetItemText(item_plugin)\r
-                if self.configs.has_key(plugin):\r
-                    #config = self.panelCommands.CommandsTree.GetPyData(item_plugin)\r
-                    config = self.configs[plugin]\r
-                    section = self.panelCommands.CommandsTree.GetItemText(selected_item)\r
+            if not self._c['commands']._c['tree'].ItemHasChildren(selected_item):\r
+                item_plugin = self._c['commands']._c['tree'].GetItemParent(selected_item)\r
+                plugin = self._c['commands']._c['tree'].GetItemText(item_plugin)\r
+                if self.gui.config.has_key(plugin):\r
+                    #config = self._c['commands']._c['tree'].GetPyData(item_plugin)\r
+                    config = self.gui.config[plugin]\r
+                    section = self._c['commands']._c['tree'].GetItemText(selected_item)\r
                     #display docstring in help window\r
                     doc_string = eval('self.do_' + section + '.__doc__')\r
                     if section in config:\r
                         for option in config[section]:\r
                             properties.append([option, config[section][option]])\r
             else:\r
-                plugin = self.panelCommands.CommandsTree.GetItemText(selected_item)\r
+                plugin = self._c['commands']._c['tree'].GetItemText(selected_item)\r
                 if plugin != 'core':\r
                     doc_string = eval('plugins.' + plugin + '.' + plugin + 'Commands.__doc__')\r
                 else:\r
@@ -1038,10 +856,10 @@ class HookeFrame(wx.Frame):
                 self.panelAssistant.ChangeValue(doc_string)\r
             else:\r
                 self.panelAssistant.ChangeValue('')\r
-            panels.propertyeditor.PropertyEditor.Initialize(self.panelProperties, properties)\r
+            panel.propertyeditor.PropertyEditor.Initialize(self.panelProperties, properties)\r
             #save the currently selected command/plugin to the config file\r
-            self.config['command']['command'] = section\r
-            self.config['command']['plugin'] = plugin\r
+            self.gui.config['command']['command'] = section\r
+            self.gui.config['command']['plugin'] = plugin\r
 \r
     def OnTreeCtrlItemActivated(self, event):\r
         self.OnExecute(event)\r
@@ -1058,13 +876,13 @@ class HookeFrame(wx.Frame):
         menu_item = self.MenuBar.FindItemById(menu_id)\r
         menu_label = menu_item.GetLabel()\r
 \r
-        pane = self._mgr.GetPane(menu_label)\r
+        pane = self._c['manager'].GetPane(menu_label)\r
         pane.Show(not pane.IsShown())\r
         #if we don't do the following, the Folders pane does not resize properly on hide/show\r
         if pane.caption == 'Folders' and pane.IsShown() and pane.IsDocked():\r
             #folders_size = pane.GetSize()\r
             self.panelFolders.Fit()\r
-        self._mgr.Update()\r
+        self._c['manager'].Update()\r
 \r
     def _clickize(self, xvector, yvector, index):\r
         '''\r
@@ -1076,14 +894,14 @@ class HookeFrame(wx.Frame):
         point.find_graph_coords(xvector, yvector)\r
         return point\r
 \r
-    def _delta(self, message='Click 2 points', whatset=lh.RETRACTION):\r
+    def _delta(self, message='Click 2 points', block=0):\r
         '''\r
         Calculates the difference between two clicked points\r
         '''\r
-        clicked_points = self._measure_N_points(N=2, message=message, whatset=whatset)\r
+        clicked_points = self._measure_N_points(N=2, message=message, block=block)\r
 \r
         plot = self.GetDisplayedPlotCorrected()\r
-        curve = plot.curves[whatset]\r
+        curve = plot.curves[block]\r
 \r
         delta = lib.delta.Delta()\r
         delta.point1.x = clicked_points[0].graph_coords[0]\r
@@ -1095,7 +913,7 @@ class HookeFrame(wx.Frame):
 \r
         return delta\r
 \r
-    def _measure_N_points(self, N, message='', whatset=lh.RETRACTION):\r
+    def _measure_N_points(self, N, message='', block=0):\r
         '''\r
         General helper function for N-points measurements\r
         By default, measurements are done on the retraction\r
@@ -1106,8 +924,8 @@ class HookeFrame(wx.Frame):
 \r
         figure = self.GetActiveFigure()\r
 \r
-        xvector = self.displayed_plot.curves[whatset].x\r
-        yvector = self.displayed_plot.curves[whatset].y\r
+        xvector = self.displayed_plot.curves[block].x\r
+        yvector = self.displayed_plot.curves[block].y\r
 \r
         clicked_points = figure.ginput(N, timeout=-1, show_clicks=True)\r
 \r
@@ -1204,10 +1022,10 @@ class HookeFrame(wx.Frame):
         if active_file is not None:\r
             self.panelNote.Editor.SetValue(active_file.note)\r
 \r
-    def UpdatePerspectivesMenu(self):\r
-        #add perspectives to menubar and _perspectives\r
-        perspectivesDirectory = os.path.join(lh.hookeDir, 'perspectives')\r
+    def _update_perspectives(self):\r
+        # add perspectives to menubar and _perspectives\r
         self._perspectives = {}\r
+        return # TODO: cleanup\r
         if os.path.isdir(perspectivesDirectory):\r
             perspectiveFileNames = os.listdir(perspectivesDirectory)\r
             for perspectiveFilename in perspectiveFileNames:\r
@@ -1223,34 +1041,20 @@ class HookeFrame(wx.Frame):
 \r
         #in case there are no perspectives\r
         if not self._perspectives:\r
-            perspective = self._mgr.SavePerspective()\r
+            perspective = self._c['manager'].SavePerspective()\r
             self._perspectives['Default'] = perspective\r
             self._SavePerspectiveToFile('Default', perspective)\r
 \r
-        selected_perspective = self.config['perspectives']['active']\r
+        selected_perspective = self.gui.config['active perspective']\r
         if not self._perspectives.has_key(selected_perspective):\r
-            self.config['perspectives']['active'] = 'Default'\r
+            self.gui.config['active perspective'] = 'Default'\r
             selected_perspective = 'Default'\r
 \r
-        perspectives_list = [key for key, value in self._perspectives.iteritems()]\r
-        perspectives_list.sort()\r
-\r
-        #get the Perspectives menu\r
-        menu_position = self.MenuBar.FindMenu('Perspectives')\r
-        menu = self.MenuBar.GetMenu(menu_position)\r
-        #delete all menu items\r
-        for item in menu.GetMenuItems():\r
-            menu.DeleteItem(item)\r
-        #rebuild the menu by adding the standard menu items\r
-        menu.Append(ID_SavePerspective, 'Save Perspective')\r
-        menu.Append(ID_DeletePerspective, 'Delete Perspective')\r
-        menu.AppendSeparator()\r
-        #add all previous perspectives\r
-        for index, label in enumerate(perspectives_list):\r
-            menu_item = menu.AppendRadioItem(ID_FirstPerspective + index, label)\r
-            if label == selected_perspective:\r
-                self._RestorePerspective(label)\r
-                menu_item.Check(True)\r
+        self._c['menu']._c['perspectives'].update(\r
+            sorted(self._perspectives.keys()), selected_perspective)\r
+\r
+        self._RestorePerspective(selected_perspective)\r
+\r
 \r
     def UpdatePlaylistsTreeSelection(self):\r
         playlist = self.GetActivePlaylist()\r
@@ -1346,24 +1150,66 @@ class HookeFrame(wx.Frame):
         #refresh the plot\r
         figure.canvas.draw()\r
 \r
-if __name__ == '__main__':\r
 \r
-    ## now, silence a deprecation warning for py2.3\r
-    import warnings\r
-    warnings.filterwarnings("ignore", "integer", DeprecationWarning, "wxPython.gdi")\r
 \r
-    redirect = True\r
-    if __debug__:\r
-        redirect=False\r
+class HookeApp (wx.App):\r
+    def __init__(self, gui, commands, inqueue, outqueue, *args, **kwargs):\r
+        self.gui = gui\r
+        self.commands = commands\r
+        self.inqueue = inqueue\r
+        self.outqueue = outqueue\r
+        super(HookeApp, self).__init__(*args, **kwargs)\r
 \r
-    app = Hooke(redirect=redirect)\r
+    def OnInit(self):\r
+        self.SetAppName('Hooke')\r
+        self.SetVendorName('')\r
+        self._setup_splash_screen()\r
+\r
+        height = int(self.gui.config['main height']) # HACK: config should convert\r
+        width = int(self.gui.config['main width'])\r
+        top = int(self.gui.config['main top'])\r
+        left = int(self.gui.config['main left'])\r
+\r
+        # Sometimes, the ini file gets confused and sets 'left' and\r
+        # 'top' to large negative numbers.  Here we catch and fix\r
+        # this.  Keep small negative numbers, the user might want\r
+        # those.\r
+        if left < -width:\r
+            left = 0\r
+        if top < -height:\r
+            top = 0\r
+\r
+        self._c = {\r
+            'frame': HookeFrame(\r
+                self.gui, self.commands, 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
+        self._c['frame'].Show(True)\r
+        self.SetTopWindow(self._c['frame'])\r
+        return True\r
 \r
-    app.MainLoop()\r
+    def _setup_splash_screen(self):\r
+        if self.gui.config['show splash screen']:\r
+            path = self.gui.config['splash screen image']\r
+            if os.path.isfile(path):\r
+                duration = int(self.gui.config['splash screen duration'])  # HACK: config should decode types\r
+                wx.SplashScreen(\r
+                    bitmap=wx.Image(path).ConvertToBitmap(),\r
+                    splashStyle=wx.SPLASH_CENTRE_ON_SCREEN|wx.SPLASH_TIMEOUT,\r
+                    milliseconds=duration,\r
+                    parent=None)\r
+                wx.Yield()\r
+                # For some reason splashDuration and sleep do not\r
+                # correspond to each other at least not on Windows.\r
+                # Maybe it's because duration is in milliseconds and\r
+                # sleep in seconds.  Thus we need to increase the\r
+                # sleep time a bit. A factor of 1.2 seems to work.\r
+                sleepFactor = 1.2\r
+                time.sleep(sleepFactor * duration / 1000)\r
 \r
-from ..command import CommandExit, Exit, Command, Argument, StoreValue\r
-from ..interaction import Request, BooleanRequest, ReloadUserInterfaceConfig\r
-from ..ui import UserInterface, CommandMessage\r
-from ..util.encoding import get_input_encoding, get_output_encoding\r
+    def OnExit(self):\r
+        return True\r
 \r
 \r
 class GUI (UserInterface):\r
@@ -1380,17 +1226,63 @@ class GUI (UserInterface):
 \r
             Setting(section=self.setting_section, help=self.__doc__)\r
         """\r
-        return []\r
-\r
-    def reload_config(self):\r
-        pass\r
+        return [\r
+            Setting(section=self.setting_section, help=self.__doc__),\r
+            Setting(section=self.setting_section, option='icon image',\r
+                    value=os.path.join('doc', 'img', 'microscope.ico'),\r
+                    help='Path to the hooke icon image.'),\r
+            Setting(section=self.setting_section, option='show splash screen',\r
+                    value=True,\r
+                    help='Enable/disable the splash screen'),\r
+            Setting(section=self.setting_section, option='splash screen image',\r
+                    value=os.path.join('doc', 'img', 'hooke.jpg'),\r
+                    help='Path to the Hooke splash screen image.'),\r
+            Setting(section=self.setting_section, option='splash screen duration',\r
+                    value=1000,\r
+                    help='Duration of the splash screen in milliseconds.'),\r
+            Setting(section=self.setting_section, option='perspective-path',\r
+                    value=os.path.join('resources', 'gui', 'perspectives'),\r
+                    help='Directory containing perspective files.'), # TODO: allow colon separated list, like $PATH.\r
+            Setting(section=self.setting_section, option='folders-workdir',\r
+                    value='.',\r
+                    help='This should probably go...'),\r
+            Setting(section=self.setting_section, option='folders-filters',\r
+                    value='.',\r
+                    help='This should probably go...'),\r
+            Setting(section=self.setting_section, option='active perspective',\r
+                    value='Default',\r
+                    help='Name of active perspective file (or "Default").'),\r
+            Setting(section=self.setting_section, option='folders-filter-index',\r
+                    value='0',\r
+                    help='This should probably go...'),\r
+            Setting(section=self.setting_section, option='main height',\r
+                    value=500,\r
+                    help='Height of main window in pixels.'),\r
+            Setting(section=self.setting_section, option='main width',\r
+                    value=500,\r
+                    help='Width of main window in pixels.'),\r
+            Setting(section=self.setting_section, option='main top',\r
+                    value=0,\r
+                    help='Pixels from screen top to top of main window.'),\r
+            Setting(section=self.setting_section, option='main left',\r
+                    value=0,\r
+                    help='Pixels from screen left to left of main window.'),            \r
+            Setting(section=self.setting_section, option='selected command',\r
+                    value='load playlist',\r
+                    help='Name of the initially selected command.'),\r
+            ]\r
+\r
+    def _app(self, commands, ui_to_command_queue, command_to_ui_queue):\r
+        redirect = True\r
+        if __debug__:\r
+            redirect=False\r
+        app = HookeApp(gui=self,\r
+                       commands=commands,\r
+                       inqueue=ui_to_command_queue,\r
+                       outqueue=command_to_ui_queue,\r
+                       redirect=redirect)\r
+        return app\r
 \r
     def run(self, commands, ui_to_command_queue, command_to_ui_queue):\r
-        self._initialize()\r
-        cmd = self._cmd(commands, ui_to_command_queue, command_to_ui_queue)\r
-        cmd.cmdloop(self._splash_text())\r
-\r
-    def run_lines(self, commands, ui_to_command_queue, command_to_ui_queue,\r
-                  lines):\r
-        raise NotImplementedError(\r
-            'Use the command line interface for run_lines()')\r
+        app = self._app(commands, ui_to_command_queue, command_to_ui_queue)\r
+        app.MainLoop()\r
index 26664e8995983478a60faf47dad9ae7f3b71bb75..c5a77e655c59a8d094f7638a8b8a1923937834d1 100644 (file)
@@ -1,12 +1,12 @@
 # Copyright\r
 \r
-import .commands as commands\r
-import .note as note\r
-import .perspectives as perspectives\r
-import .playlist as playlist\r
-import .plot as plot\r
-import .propertyeditor as propertyeditor\r
-import .results as results\r
+from . import commands as commands\r
+from . import note as note\r
+from . import playlist as playlist\r
+from . import plot as plot\r
+#from . import propertyeditor as propertyeditor\r
+from . import results as results\r
+from . import selection as selection\r
 \r
-__all__ = [commands, note, perspectives, playlist, plot, propertyeditor,\r
-           results]\r
+__all__ = [commands, note, playlist, plot, #propertyeditor,\r
+           results, selection]\r
index 52db8a4e1e5e0e8a41748eb75a8604b8108d06c4..d26d5b0cd97536176305cdb4a56394f40ac2498f 100644 (file)
@@ -1,93 +1,76 @@
 #!/usr/bin/env python\r
 \r
-'''\r
-commands.py\r
+"""Commands and settings panel for Hooke.\r
+"""\r
 \r
-Commands and settings panel for Hooke.\r
-\r
-Copyright 2009 by Dr. Rolf Schmidt (Concordia University, Canada)\r
-\r
-This program is released under the GNU General Public License version 2.\r
-'''\r
-\r
-from configobj import ConfigObj\r
 import os.path\r
-import wx\r
-\r
-import lib.libhooke as lh\r
 \r
-class Commands(wx.Panel):\r
-\r
-    def __init__(self, parent):\r
-        # Use the WANTS_CHARS style so the panel doesn't eat the Return key.\r
-        wx.Panel.__init__(self, parent, -1, style=wx.WANTS_CHARS|wx.NO_BORDER, size=(160, 200))\r
-\r
-        self.CommandsTree = wx.TreeCtrl(self, -1, wx.Point(0, 0), wx.Size(160, 250), wx.TR_DEFAULT_STYLE|wx.NO_BORDER|wx.TR_HIDE_ROOT)\r
-        imglist = wx.ImageList(16, 16, True, 2)\r
-        imglist.Add(wx.ArtProvider.GetBitmap(wx.ART_FOLDER, wx.ART_OTHER, wx.Size(16, 16)))\r
-        imglist.Add(wx.ArtProvider.GetBitmap(wx.ART_EXECUTABLE_FILE, wx.ART_OTHER, wx.Size(16, 16)))\r
-        self.CommandsTree.AssignImageList(imglist)\r
-        self.CommandsTree.AddRoot('Commands and Settings', 0)\r
+import wx\r
 \r
-        self.ExecuteButton = wx.Button(self, -1, 'Execute')\r
 \r
+class Tree (wx.TreeCtrl):\r
+    def __init__(self, commands, selected, *args, **kwargs):\r
+        super(Tree, self).__init__(*args, **kwargs)\r
+        imglist = wx.ImageList(width=16, height=16, mask=True, initialCount=2)\r
+        imglist.Add(wx.ArtProvider.GetBitmap(\r
+                wx.ART_FOLDER, wx.ART_OTHER, wx.Size(16, 16)))\r
+        imglist.Add(wx.ArtProvider.GetBitmap(\r
+                wx.ART_EXECUTABLE_FILE, wx.ART_OTHER, wx.Size(16, 16)))\r
+        self.AssignImageList(imglist)\r
+        self.image = {\r
+            'root': 0,\r
+            'plugin': 0,\r
+            'command': 1,\r
+            }\r
+        self.AddRoot(text='Commands and Settings', image=self.image['root'])\r
+\r
+        self._setup_commands(commands, selected)\r
+\r
+    def _setup_commands(self, commands, selected):\r
+        self._commands = commands\r
+        selected = None\r
+        tree_root = self.GetRootItem()\r
+\r
+        plugin_roots = {}\r
+        plugins = sorted(set([c.plugin for c in commands]),\r
+                         key=lambda p:p.name)\r
+        for plugin in plugins:\r
+            plugin_roots[plugin.name] = self.AppendItem(\r
+                parent=tree_root,\r
+                text=plugin.name,\r
+                image=self.image['plugin'],\r
+                data=wx.TreeItemData(plugin))\r
+\r
+        for command in sorted(commands, key=lambda c:c.name):\r
+            item = self.AppendItem(\r
+                parent=plugin_roots[command.plugin.name],\r
+                text=command.name,\r
+                image=self.image['command'])\r
+            if command.name == selected:\r
+                selected = item\r
+        for key,value in plugin_roots.items():\r
+            self.Expand(value)\r
+        #make sure the selected command/plugin is visible in the tree\r
+        if selected is not None:\r
+            self.SelectItem(selected, True)\r
+            self.EnsureVisible(selected)\r
+\r
+\r
+class Commands (wx.Panel):\r
+    def __init__(self, commands, selected, *args, **kwargs):\r
+        super(Commands, self).__init__(*args, **kwargs)\r
+        self._c = {\r
+            'tree': Tree(\r
+                commands=commands,\r
+                selected=selected,\r
+                parent=self,\r
+                pos=wx.Point(0, 0),\r
+                size=wx.Size(160, 250),\r
+                style=wx.TR_DEFAULT_STYLE|wx.NO_BORDER|wx.TR_HIDE_ROOT),\r
+            'execute': wx.Button(self, label='Execute'),\r
+            }\r
         sizer = wx.BoxSizer(wx.VERTICAL)\r
-        sizer.Add(self.CommandsTree, 1, wx.EXPAND)\r
-        sizer.Add(self.ExecuteButton, 0, wx.EXPAND)\r
-\r
+        sizer.Add(self._c['execute'], 0, wx.EXPAND)\r
+        sizer.Add(self._c['tree'], 1, wx.EXPAND)\r
         self.SetSizer(sizer)\r
         sizer.Fit(self)\r
-\r
-    def Initialize(self, plugins):\r
-        selected = None\r
-        tree_root = self.CommandsTree.GetRootItem()\r
-        path = lh.get_file_path('hooke.ini', ['config'])\r
-        config = ConfigObj()\r
-        if os.path.isfile(path):\r
-            config.filename = path\r
-            config.reload()\r
-            #get the selected command/plugin from the config file\r
-            command_str = config['command']['command']\r
-            module_str = config['command']['plugin']\r
-\r
-            #sort the plugins into alphabetical order\r
-            plugins_list = [key for key, value in plugins.iteritems()]\r
-            plugins_list.sort()\r
-            for plugin in plugins_list:\r
-                filename = ''.join([plugin, '.ini'])\r
-                path = lh.get_file_path(filename, ['plugins'])\r
-                config = ConfigObj()\r
-                if os.path.isfile(path):\r
-                    config.filename = path\r
-                    config.reload()\r
-                    #append the ini file to the plugin\r
-                    plugin_root = self.CommandsTree.AppendItem(tree_root, plugin, 0, data=wx.TreeItemData(config))\r
-                else:\r
-                    plugin_root = self.CommandsTree.AppendItem(tree_root, plugin, 0)\r
-                #select the plugin according to the config file\r
-                if plugin == module_str:\r
-                    selected = plugin_root\r
-\r
-                #add all commands to the tree\r
-                for command in plugins[plugin]:\r
-                    command_label = command.replace('do_', '')\r
-                    #do not add the ini file to the command (we'll access the ini file of the plugin (ie parent) instead, see above)\r
-                    item = self.CommandsTree.AppendItem(plugin_root, command_label, 1)\r
-                    #select the command according to the config file\r
-                    if plugin == module_str and command_label == command_str:\r
-                        selected = item\r
-                        #e = wx.MouseEvent()\r
-                        #e.SetEventType(wx.EVT_LEFT_DOWN.typeId)\r
-                        #e.SetEventObject(self.CommandsTree)\r
-\r
-                        ##e.SetSelection(page)\r
-                        #self.Parent.OnTreeCtrlCommandsLeftDown(e)\r
-                        #wx.PostEvent(self, e)\r
-\r
-                        #self.CommandsTree.SelectItem(item, True)\r
-\r
-                self.CommandsTree.Expand(plugin_root)\r
-            #make sure the selected command/plugin is visible in the tree\r
-            if selected is not None:\r
-                self.CommandsTree.SelectItem(selected, True)\r
-                self.CommandsTree.EnsureVisible(selected)\r
index 2257d8844694cf4b1a111369a9e31c910d888d9f..ff92cfe336e11dd2684ac5ed4899aa98f777f3a7 100644 (file)
@@ -1,14 +1,8 @@
 #!/usr/bin/env python\r
 \r
-'''\r
-note.py\r
+"""Note panel for Hooke.\r
+"""\r
 \r
-Note panel for Hooke.\r
-\r
-Copyright 2010 by Dr. Rolf Schmidt (Concordia University, Canada)\r
-\r
-This program is released under the GNU General Public License version 2.\r
-'''\r
 import wx\r
 \r
 class Note(wx.Panel):\r
diff --git a/hooke/ui/gui/panel/perspectives.py b/hooke/ui/gui/panel/perspectives.py
deleted file mode 100644 (file)
index 75eab72..0000000
+++ /dev/null
@@ -1,73 +0,0 @@
-#!/usr/bin/env python\r
-\r
-'''\r
-perspectives.py\r
-\r
-Perspectives panel for deletion.\r
-\r
-Copyright 2010 by Dr. Rolf Schmidt (Concordia University, Canada)\r
-\r
-This program is released under the GNU General Public License version 2.\r
-'''\r
-\r
-from os import remove\r
-import wx\r
-\r
-import lib.libhooke as lh\r
-\r
-class Perspectives(wx.Dialog):\r
-\r
-    def __init__(self, parent, ID, title):\r
-        wx.Dialog.__init__(self, parent, ID, title, style=wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER)\r
-\r
-        # contents\r
-        sizer_vertical = wx.BoxSizer(wx.VERTICAL)\r
-\r
-        message_str = "\nPlease check the perspectives\n\nyou want to delete and click 'Delete'.\n"\r
-        text = wx.StaticText(self, -1, message_str, wx.DefaultPosition, style=wx.ALIGN_CENTRE)\r
-        sizer_vertical.Add(text, 0, wx.GROW|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5)\r
-\r
-        perspectives_list = [item[0] for item in self.Parent._perspectives.items() if item[0] != 'Default']\r
-        perspectives_list.sort()\r
-        listbox = wx.CheckListBox(self, -1, wx.DefaultPosition, wx.Size(175, 200), perspectives_list)\r
-        self.Bind(wx.EVT_CHECKLISTBOX, self.EvtCheckListBox, listbox)\r
-        listbox.SetSelection(0)\r
-        sizer_vertical.Add(listbox, 1, wx.GROW|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5)\r
-        self.listbox = listbox\r
-\r
-        horizontal_line = wx.StaticLine(self, -1, size=(20,-1), style=wx.LI_HORIZONTAL)\r
-        sizer_vertical.Add(horizontal_line, 0, wx.GROW, 5)\r
-\r
-        sizer_buttons = wx.BoxSizer(wx.HORIZONTAL)\r
-\r
-        button_delete = wx.Button(self, wx.ID_DELETE)\r
-        self.Bind(wx.EVT_BUTTON, self.OnButtonDelete, button_delete)\r
-        button_delete.SetDefault()\r
-        sizer_buttons.Add(button_delete, 0, wx.GROW|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5)\r
-\r
-        button_close = wx.Button(self, wx.ID_CLOSE)\r
-        self.Bind(wx.EVT_BUTTON, self.OnButtonClose, button_close)\r
-        sizer_buttons.Add(button_close, 0, wx.GROW|wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5)\r
-\r
-        sizer_vertical.Add(sizer_buttons, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_CENTER_HORIZONTAL|wx.ALL, 5)\r
-\r
-        self.SetSizer(sizer_vertical)\r
-        sizer_vertical.Fit(self)\r
-\r
-    def EvtCheckListBox(self, event):\r
-        index = event.GetSelection()\r
-        self.listbox.SetSelection(index)    # so that (un)checking also selects (moves the highlight)\r
-\r
-    def OnButtonClose(self, event):\r
-        self.EndModal(wx.ID_CLOSE)\r
-\r
-    def OnButtonDelete(self, event):\r
-        items = self.listbox.GetItems()\r
-        selected_perspective = self.Parent.config['perspectives']['active']\r
-        for index in reversed(self.listbox.GetChecked()):\r
-            self.listbox.Delete(index)\r
-            if items[index] == selected_perspective:\r
-                self.Parent.config['perspectives']['active'] = 'Default'\r
-\r
-            filename = lh.get_file_path(items[index] + '.txt', ['perspectives'])\r
-            remove(filename)\r
index 3868a4fd941a86ece36f2a6e4eeaa472d7d75c07..022950d15f0b9852ed579439aa8e8cde2f9017c3 100644 (file)
@@ -1,18 +1,11 @@
-#!/usr/bin/env python\r
+# Copyright\r
 \r
-'''\r
-playlist.py\r
-\r
-Playlist panel for Hooke.\r
-\r
-Copyright 2009 by Dr. Rolf Schmidt (Concordia University, Canada)\r
-\r
-This program is released under the GNU General Public License version 2.\r
-'''\r
+"""Playlist panel for Hooke.\r
+"""\r
 \r
 import wx\r
 \r
-class Playlists(wx.Panel):\r
+class Playlist(wx.Panel):\r
 \r
     def __init__(self, parent):\r
         # Use the WANTS_CHARS style so the panel doesn't eat the Return key.\r
index 7a1515e4991e0801ff4f8a9e93c62a20f098f637..b1c7f78232d95d3608f25e34233586186aeb74f6 100644 (file)
@@ -1,25 +1,16 @@
-#!/usr/bin/env python\r
+# Copyright\r
 \r
-'''\r
-plot.py\r
-\r
-Plot panel for Hooke.\r
-\r
-Copyright 2009 by Dr. Rolf Schmidt (Concordia University, Canada)\r
-\r
-This program is released under the GNU General Public License version 2.\r
-'''\r
+"""Plot panel for Hooke.\r
+"""\r
 \r
 from matplotlib.backends.backend_wxagg import FigureCanvasWxAgg as FigureCanvas\r
-\r
 from matplotlib.backends.backend_wx import NavigationToolbar2Wx\r
-\r
 from matplotlib.figure import Figure\r
 \r
 import wx\r
 \r
-#there are many comments in here from the demo app\r
-#they should come in handy to expand the functionality in the future\r
+# There are many comments in here from the demo app.\r
+# They should come in handy to expand the functionality in the future.\r
 \r
 class HookeCustomToolbar(NavigationToolbar2Wx):\r
 \r
index 40eecaf0fc8c0330398f6c0f113b53d6ec590350..edf0968ab8ace51886c548f0530683874dbd51d7 100644 (file)
@@ -1,50 +1,35 @@
-#!/usr/bin/env python\r
+# Copyright\r
 \r
-'''\r
-propertyeditor.py\r
-\r
-Property editor panel for Hooke.\r
-\r
-Copyright 2009 by Dr. Rolf Schmidt (Concordia University, Canada)\r
-\r
-This program is released under the GNU General Public License version 2.\r
-'''\r
+"""Property editor panel for Hooke.\r
+"""\r
 \r
 import sys\r
 import os.path\r
 \r
 import wx\r
 import wx.propgrid as wxpg\r
-#import wx.stc\r
-from string import split\r
 \r
-#there are many comments and code fragments in here from the demo app\r
-#they should come in handy to expand the functionality in the future\r
+# There are many comments and code fragments in here from the demo app.\r
+# They should come in handy to expand the functionality in the future.\r
 \r
-class Display:\r
+class Display (object):\r
     property_descriptor = []\r
     def __init__(self):\r
         pass\r
 \r
-\r
-class ValueObject:\r
+class ValueObject (object):\r
     def __init__(self):\r
         pass\r
 \r
 \r
-class IntProperty2(wxpg.PyProperty):\r
-    """\\r
-    This is a simple re-implementation of wxIntProperty.\r
+class IntProperty2 (wxpg.PyProperty):\r
+    """This is a simple re-implementation of wxIntProperty.\r
     """\r
     def __init__(self, label, name = wxpg.LABEL_AS_NAME, value=0):\r
         wxpg.PyProperty.__init__(self, label, name)\r
         self.SetValue(value)\r
 \r
     def GetClassName(self):\r
-        """\\r
-        This is not 100% necessary and in future is probably going to be\r
-        automated to return class name.\r
-        """\r
         return "IntProperty2"\r
 \r
     def GetEditor(self):\r
index c53de1186f26bc0330cee9fad8c5877d54d3d3d8..1588dbdcb2659f0de91d0fdf1a0f917b4cae4605 100644 (file)
@@ -1,16 +1,10 @@
-#!/usr/bin/env python\r
+# Copyright\r
 \r
-'''\r
-results.py\r
-\r
-Fitting results panel for Hooke.\r
-\r
-Copyright 2009 by Dr. Rolf Schmidt (Concordia University, Canada)\r
-\r
-This program is released under the GNU General Public License version 2.\r
-'''\r
+"""Fitting results panel for Hooke.\r
+"""\r
 \r
 import sys\r
+\r
 import wx\r
 from wx.lib.mixins.listctrl import CheckListCtrlMixin\r
 \r
diff --git a/hooke/ui/gui/panel/selection.py b/hooke/ui/gui/panel/selection.py
new file mode 100644 (file)
index 0000000..4979ad4
--- /dev/null
@@ -0,0 +1,86 @@
+# Copyright\r
+\r
+"""Selection dialog.\r
+"""\r
+\r
+from os import remove\r
+\r
+import wx\r
+\r
+\r
+class Selection (wx.Dialog):\r
+    """A selection dialog box.\r
+\r
+    Lists options and two buttons.  The first button is setup by the\r
+    caller.  The second button cancels the dialog.\r
+\r
+    The button appearance can be specified by selecting one of the\r
+    `standard wx IDs`_.\r
+\r
+    .. _standard wx IDs:\r
+      http://docs.wxwidgets.org/stable/wx_stdevtid.html#stdevtid\r
+    """\r
+    def __init__(self, options, message, button_id, button_callback, *args, **kwargs):\r
+        super(Selection, self).__init__(*args, **kwargs)\r
+\r
+        self._button_callback = button_callback\r
+\r
+        self._c = {\r
+            'text': wx.StaticText(\r
+                parent=self, label=message, style=wx.ALIGN_CENTRE),\r
+            'listbox': wx.CheckListBox(\r
+                parent=self, size=wx.Size(175, 200), list=options),\r
+            'button': wx.Button(parent=self, id=button_id),\r
+            'cancel': wx.Button(self, wx.ID_CANCEL),\r
+            }\r
+        self.Bind(wx.EVT_CHECKLISTBOX, self._on_check, self._c['listbox'])\r
+        self.Bind(wx.EVT_BUTTON, self._on_button, self._c['button'])\r
+        self.Bind(wx.EVT_BUTTON, self._on_cancel, self._c['cancel'])\r
+\r
+        border_width = 5\r
+\r
+        b = wx.BoxSizer(wx.HORIZONTAL)\r
+        b.Add(window=self._c['button'],\r
+              flag=wx.GROW|wx.ALIGN_CENTER_VERTICAL|wx.ALL,\r
+              border=border_width)\r
+        b.Add(window=self._c['cancel'],\r
+              flag=wx.GROW|wx.ALIGN_CENTER_VERTICAL|wx.ALL,\r
+              border=border_width)\r
+\r
+        v = wx.BoxSizer(wx.VERTICAL)\r
+        v.Add(window=self._c['text'],\r
+              flag=wx.GROW|wx.ALIGN_CENTER_VERTICAL|wx.ALL,\r
+              border=border_width)\r
+        v.Add(window=self._c['listbox'],\r
+              proportion=1,\r
+              flag=wx.GROW|wx.ALIGN_CENTER_VERTICAL|wx.ALL,\r
+              border=border_width)\r
+        v.Add(window=wx.StaticLine(\r
+                parent=self, size=(20,-1), style=wx.LI_HORIZONTAL),\r
+              flag=wx.GROW,\r
+              border=border_width)\r
+        v.Add(window=b,\r
+              flag=wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_CENTER_HORIZONTAL|wx.ALL,\r
+              border=border_width)\r
+        self.SetSizer(v)\r
+        v.Fit(self)\r
+\r
+    def _on_check(self, event):\r
+        """Refocus on the first checked item.\r
+        """\r
+        index = event.GetSelection()\r
+        self.listbox.SetSelection(index)\r
+\r
+    def _on_cancel(self, event):\r
+        """Close the dialog.\r
+        """\r
+        self.EndModal(wx.ID_CANCEL)\r
+\r
+    def _on_button(self, event):\r
+        """Call ._button_callback() and close the dialog.\r
+        """\r
+        self._button_callback(\r
+            event=event,\r
+            items=self._c['listbox'].GetItems(),\r
+            selected_items=self._c['listbox'].GetChecked())\r
+        self.EndModal(wx.ID_CLOSE)\r