Bound events down through folders. To go: commands, propgrid, results
authorW. Trevor King <wking@drexel.edu>
Sat, 24 Jul 2010 19:58:01 +0000 (15:58 -0400)
committerW. Trevor King <wking@drexel.edu>
Sat, 24 Jul 2010 19:58:01 +0000 (15:58 -0400)
hooke/ui/gui/__init__.py

index 5fcfb145f123a9a5d9fca657a0ceeca87c360cd1..e4c966b991dbf8be425361d765e45a156e13e3be 100644 (file)
@@ -18,6 +18,7 @@ import wx.html
 import wx.aui as aui\r
 import wx.lib.evtmgr as evtmgr\r
 \r
+\r
 # wxPropertyGrid included in wxPython >= 2.9.1, until then, see\r
 #   http://wxpropgrid.sourceforge.net/cgi-bin/index?page=download\r
 # until then, we'll avoid it because of the *nix build problems.\r
@@ -70,13 +71,13 @@ class NavBar (wx.ToolBar):
         self.SetToolBitmapSize(wx.Size(16,16))\r
         self._c = {\r
             'previous': self.AddLabelTool(\r
-                id=wx.ID_ANY,\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_ANY,\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
@@ -88,7 +89,7 @@ class NavBar (wx.ToolBar):
 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
+        self._c = {'exit': self.Append(wx.ID_EXIT)}\r
 \r
 \r
 class ViewMenu (wx.Menu):\r
@@ -108,33 +109,37 @@ class ViewMenu (wx.Menu):
             '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 PerspectivesMenu (wx.Menu):\r
+class PerspectiveMenu (wx.Menu):\r
     def __init__(self, *args, **kwargs):\r
-        super(PerspectivesMenu, self).__init__(*args, **kwargs)\r
+        super(PerspectiveMenu, self).__init__(*args, **kwargs)\r
         self._c = {}\r
 \r
-    def update(self, perspectives, selected):\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(item='Save Perspective'),\r
-            'delete': self.Append(item='Delete Perspective'),\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] = menu.AppendRadioItem(item=label)\r
-            if label == selected_perspective:\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
 \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
+        self._c = {'about':self.Append(id=wx.ID_ABOUT)}\r
 \r
 \r
 class MenuBar (wx.MenuBar):\r
@@ -143,12 +148,12 @@ class MenuBar (wx.MenuBar):
         self._c = {\r
             'file': FileMenu(),\r
             'view': ViewMenu(),\r
-            'perspectives': PerspectivesMenu(),\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['perspectives'], 'Perspectives')\r
+        self.Append(self._c['perspective'], 'Perspective')\r
         self.Append(self._c['help'], 'Help')\r
 \r
 \r
@@ -191,19 +196,20 @@ class HookeFrame (wx.Frame):
 \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'] = MenuBar(\r
+            )\r
         self.SetMenuBar(self._c['menu bar'])\r
 \r
         self._c['status bar'] = StatusBar(self, style=wx.ST_SIZEGRIP)\r
 \r
+        self._update_perspectives()\r
         self._bind_events()\r
 \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
+            self._on_restore_perspective(menu_item)\r
             #TODO: config setting to remember playlists from last session\r
         self.playlists = self._c['playlists'].Playlists\r
         self._displayed_plot = None\r
@@ -279,32 +285,29 @@ class HookeFrame (wx.Frame):
         # 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(wx.EVT_ERASE_BACKGROUND, self._on_erase_background)\r
+        self.Bind(wx.EVT_SIZE, self._on_size)\r
+        self.Bind(wx.EVT_CLOSE, self._on_close)\r
+        self.Bind(wx.EVT_MENU, self._on_close, id=wx.ID_EXIT)\r
+        self.Bind(wx.EVT_MENU, self._on_about, id=wx.ID_ABOUT)\r
         self.Bind(aui.EVT_AUI_PANE_CLOSE, self.OnPaneClose)\r
-        self.Bind(aui.EVT_AUINOTEBOOK_PAGE_CLOSE, self.OnNotebookPageClose)\r
-        #menu\r
-        evtmgr.eventManager.Register(self.OnAbout, wx.EVT_MENU, win=self, id=wx.ID_ABOUT)\r
-        evtmgr.eventManager.Register(self.OnClose, wx.EVT_MENU, win=self, id=wx.ID_EXIT)\r
-        #view\r
-        self.Bind(wx.EVT_MENU_RANGE, self.OnView, id=ID_ViewAssistant, id2=ID_ViewResults)\r
-        #perspectives\r
-        self.Bind(wx.EVT_MENU, self.OnDeletePerspective, id=ID_DeletePerspective)\r
-        self.Bind(wx.EVT_MENU, self.OnSavePerspective, id=ID_SavePerspective)\r
-        self.Bind(wx.EVT_MENU_RANGE, self.OnRestorePerspective, id=ID_FirstPerspective, id2=ID_FirstPerspective+1000)\r
-        #toolbar\r
-        evtmgr.eventManager.Register(self.OnNext, wx.EVT_TOOL, win=self, id=ID_Next)\r
-        evtmgr.eventManager.Register(self.OnPrevious, wx.EVT_TOOL, win=self, id=ID_Previous)\r
-        #self.Bind(.EVT_AUITOOLBAR_TOOL_DROPDOWN, self.OnDropDownToolbarItem, id=ID_DropDownToolbarItem)\r
-        #dir control\r
-        treeCtrl = self.panelFolders.GetTreeCtrl()\r
-        #tree.Bind(wx.EVT_LEFT_UP, self.OnDirCtrl1LeftUp)\r
-        #tree.Bind(wx.EVT_LEFT_DOWN, self.OnGenericDirCtrl1LeftDown)\r
-        treeCtrl.Bind(wx.EVT_LEFT_DCLICK, self.OnDirCtrlLeftDclick)\r
-        #playlist tree\r
+        self.Bind(aui.EVT_AUINOTEBOOK_PAGE_CLOSE, self._on_notebook_page_close)\r
+\r
+        for value in self._c['menu bar']._c['view']._c.values():\r
+            self.Bind(wx.EVT_MENU_RANGE, self._on_view, value)\r
+\r
+        self.Bind(wx.EVT_MENU, self._on_save_perspective,\r
+                  self._c['menu bar']._c['perspective']._c['save'])\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
+        return # TODO: cleanup\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
@@ -346,50 +349,22 @@ class HookeFrame (wx.Frame):
             count += 1\r
         return playlist_name\r
 \r
-    def _RestorePerspective(self, name):\r
+    def _restore_perspective(self, name):\r
+        # TODO: cleanup\r
+        self.gui.config['active perspective'] = name  # TODO: push to engine's Hooke\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
-                    self.MenuBar.FindItemById(ID_ViewAssistant).Check(pane.window.IsShown())\r
-                if pane.name == 'Folders':\r
-                    self.MenuBar.FindItemById(ID_ViewFolders).Check(pane.window.IsShown())\r
-                if pane.name == 'Playlists':\r
-                    self.MenuBar.FindItemById(ID_ViewPlaylists).Check(pane.window.IsShown())\r
-                if pane.name == 'Commands':\r
-                    self.MenuBar.FindItemById(ID_ViewCommands).Check(pane.window.IsShown())\r
-                if pane.name == 'Note':\r
-                    self.MenuBar.FindItemById(ID_ViewNote).Check(pane.window.IsShown())\r
-                if pane.name == 'Properties':\r
-                    self.MenuBar.FindItemById(ID_ViewProperties).Check(pane.window.IsShown())\r
-                if pane.name == 'Output':\r
-                    self.MenuBar.FindItemById(ID_ViewOutput).Check(pane.window.IsShown())\r
-                if pane.name == 'Results':\r
-                    self.MenuBar.FindItemById(ID_ViewResults).Check(pane.window.IsShown())\r
+        for pane in self._c['manager'].GetAllPanes():\r
+            if pane.name in self._c['menu bar']._c['view']._c.keys():\r
+                pane.Check(pane.window.IsShown())\r
 \r
     def _SavePerspectiveToFile(self, name, perspective):\r
         filename = ''.join([name, '.txt'])\r
-        filename = lh.get_file_path(filename, ['perspectives'])\r
+        filename = lh.get_file_path(filename, ['perspective'])\r
         perspectivesFile = open(filename, 'w')\r
         perspectivesFile.write(perspective)\r
         perspectivesFile.close()\r
 \r
-    def _UnbindEvents(self):\r
-        #menu\r
-        evtmgr.eventManager.DeregisterListener(self.OnAbout)\r
-        evtmgr.eventManager.DeregisterListener(self.OnClose)\r
-        #toolbar\r
-        evtmgr.eventManager.DeregisterListener(self.OnNext)\r
-        evtmgr.eventManager.DeregisterListener(self.OnPrevious)\r
-        #commands tree\r
-        evtmgr.eventManager.DeregisterListener(self.OnExecute)\r
-        evtmgr.eventManager.DeregisterListener(self.OnTreeCtrlCommandsSelectionChanged)\r
-        evtmgr.eventManager.DeregisterListener(self.OnTreeCtrlItemActivated)\r
-        evtmgr.eventManager.DeregisterListener(self.OnUpdateNote)\r
-\r
     def AddPlaylist(self, playlist=None, name='Untitled'):\r
         if playlist and playlist.count > 0:\r
             playlist.name = self._GetUniquePlaylistName(name)\r
@@ -556,7 +531,7 @@ class HookeFrame (wx.Frame):
                 return True\r
         return False\r
 \r
-    def OnAbout(self, event):\r
+    def _on_about(self, event):\r
         message = 'Hooke\n\n'+\\r
             'A free, open source data analysis platform\n\n'+\\r
             'Copyright 2006-2008 by Massimo Sandal\n'+\\r
@@ -566,21 +541,117 @@ class HookeFrame (wx.Frame):
         dialog.ShowModal()\r
         dialog.Destroy()\r
 \r
-    def OnClose(self, event):\r
+    def _on_close(self, event):\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._c['manager'].UnInit()\r
         del self._c['manager']\r
         self.Destroy()\r
 \r
-    def OnDeletePerspective(self, event):\r
+    def _update_perspectives(self):\r
+        """Add perspectives to menubar and _perspectives.\r
+        """\r
+        self._perspectives = {\r
+            'Default': self._c['manager'].SavePerspective(),\r
+            }\r
+        path = self.gui.config['perspective path']\r
+        if os.path.isdir(path):\r
+            files = sorted(os.listdir(path))\r
+            for fname in files:\r
+                name, extension = os.path.splitext(fname)\r
+                if extension != '.txt':\r
+                    continue\r
+                fpath = os.path.join(path, fpath)\r
+                if not os.path.isfile(fpath):\r
+                    continue\r
+                perspective = None\r
+                with open(fpath, 'rU') as f:\r
+                    perspective = f.readline()\r
+                if perspective:\r
+                    self._perspectives[name] = perspective\r
+\r
+        selected_perspective = self.gui.config['active perspective']\r
+        if not self._perspectives.has_key(selected_perspective):\r
+            self.gui.config['active perspective'] = 'Default'  # TODO: push to engine's Hooke\r
+\r
+        self._update_perspective_menu()\r
+        self._restore_perspective(selected_perspective)\r
+\r
+    def _update_perspective_menu(self):\r
+        self._c['menu bar']._c['perspective'].update(\r
+            sorted(self._perspectives.keys()),\r
+            self.gui.config['active perspective'],\r
+            self._on_restore_perspective)\r
+\r
+    def _on_restore_perspective(self, event):\r
+        name = self.MenuBar.FindItemById(event.GetId()).GetLabel()\r
+        self._restore_perspective(name)\r
+\r
+    def _on_save_perspective(self, event):\r
+        def nameExists(name):\r
+            menu_position = self.MenuBar.FindMenu('Perspective')\r
+            menu = self.MenuBar.GetMenu(menu_position)\r
+            for item in menu.GetMenuItems():\r
+                if item.GetText() == name:\r
+                    return True\r
+            return False\r
+\r
+        done = False\r
+        while not done:\r
+            dialog = wx.TextEntryDialog(self, 'Enter a name for the new perspective:', 'Save perspective')\r
+            dialog.SetValue('New perspective')\r
+            if dialog.ShowModal() != wx.ID_OK:\r
+                return\r
+            else:\r
+                name = dialog.GetValue()\r
+\r
+            if nameExists(name):\r
+                dialogConfirm = wx.MessageDialog(self, 'A file with this name already exists.\n\nDo you want to replace it?', 'Confirm', wx.YES_NO|wx.ICON_QUESTION|wx.CENTER)\r
+                if dialogConfirm.ShowModal() == wx.ID_YES:\r
+                    done = True\r
+            else:\r
+                done = True\r
+\r
+        perspective = self._c['manager'].SavePerspective()\r
+        self._SavePerspectiveToFile(name, perspective)\r
+        self.gui.config['active perspectives'] = name\r
+        self._update_perspective_menu()\r
+#        if nameExists(name):\r
+#            #check the corresponding menu item\r
+#            menu_item = self.GetPerspectiveMenuItem(name)\r
+#            #replace the perspectiveStr in _pespectives\r
+#            self._perspectives[name] = perspective\r
+#        else:\r
+#            #because we deal with radio items, we need to do some extra work\r
+#            #delete all menu items from the perspectives menu\r
+#            for item in self._perspectives_menu.GetMenuItems():\r
+#                self._perspectives_menu.DeleteItem(item)\r
+#            #recreate the perspectives menu\r
+#            self._perspectives_menu.Append(ID_SavePerspective, 'Save Perspective')\r
+#            self._perspectives_menu.Append(ID_DeletePerspective, 'Delete Perspective')\r
+#            self._perspectives_menu.AppendSeparator()\r
+#            #convert the perspectives dictionary into a list\r
+#            # the list contains:\r
+#            #[0]: name of the perspective\r
+#            #[1]: perspective\r
+#            perspectives_list = [key for key, value in self._perspectives.iteritems()]\r
+#            perspectives_list.append(name)\r
+#            perspectives_list.sort()\r
+#            #add all previous perspectives\r
+#            for index, item in enumerate(perspectives_list):\r
+#                menu_item = self._perspectives_menu.AppendRadioItem(ID_FirstPerspective + index, item)\r
+#                if item == name:\r
+#                    menu_item.Check()\r
+#            #add the new perspective to _perspectives\r
+#            self._perspectives[name] = perspective\r
+\r
+    def _on_delete_perspective(self, event):\r
         dialog = panel.selection.Selection(\r
-            options=sorted(os.listdir(self.gui.config['perspective-path'])),\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
@@ -590,9 +661,7 @@ class HookeFrame (wx.Frame):
         dialog.CenterOnScreen()\r
         dialog.ShowModal()\r
         dialog.Destroy()\r
-        self._c['menu bar']['perspectives'].update(\r
-            sorted(self._perspectives.keys),\r
-            self.gui.config['active perspective'])\r
+        self._update_perspective_menu()\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
@@ -603,18 +672,19 @@ class HookeFrame (wx.Frame):
             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
+            path = os.path.join(self.gui.config['perspective path'],\r
                                 item+'.txt')\r
             remove(path)\r
+        self._update_perspective_menu()\r
 \r
-    def OnDirCtrlLeftDclick(self, event):\r
+    def _on_dir_ctrl_left_double_click(self, event):\r
         file_path = self.panelFolders.GetPath()\r
         if os.path.isfile(file_path):\r
             if file_path.endswith('.hkp'):\r
                 self.do_loadlist(file_path)\r
         event.Skip()\r
 \r
-    def OnEraseBackground(self, event):\r
+    def _on_erase_background(self, event):\r
         event.Skip()\r
 \r
     def OnExecute(self, event):\r
@@ -629,7 +699,7 @@ class HookeFrame (wx.Frame):
     def OnExit(self, event):\r
         self.Close()\r
 \r
-    def OnNext(self, event):\r
+    def _on_next(self, event):\r
         '''\r
         NEXT\r
         Go to the next curve in the playlist.\r
@@ -658,7 +728,7 @@ class HookeFrame (wx.Frame):
                 self.UpdateNote()\r
                 self.UpdatePlot()\r
 \r
-    def OnNotebookPageClose(self, event):\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
@@ -708,7 +778,7 @@ class HookeFrame (wx.Frame):
             self.playlists[playlist_name] = playlist\r
         event.Skip()\r
 \r
-    def OnPrevious(self, event):\r
+    def _on_previous(self, event):\r
         '''\r
         PREVIOUS\r
         Go to the previous curve in the playlist.\r
@@ -748,10 +818,6 @@ class HookeFrame (wx.Frame):
 \r
             config[property_section][property_key]['value'] = property_value\r
 \r
-    def OnRestorePerspective(self, event):\r
-        name = self.MenuBar.FindItemById(event.GetId()).GetLabel()\r
-        self._RestorePerspective(name)\r
-\r
     def OnResultsCheck(self, index, flag):\r
         results = self.GetActivePlot().results\r
         if results.has_key(self.results_str):\r
@@ -759,67 +825,8 @@ class HookeFrame (wx.Frame):
             results[self.results_str].update()\r
             self.UpdatePlot()\r
 \r
-    def OnSavePerspective(self, event):\r
-\r
-        def nameExists(name):\r
-            menu_position = self.MenuBar.FindMenu('Perspectives')\r
-            menu = self.MenuBar.GetMenu(menu_position)\r
-            for item in menu.GetMenuItems():\r
-                if item.GetText() == name:\r
-                    return True\r
-            return False\r
-\r
-        done = False\r
-        while not done:\r
-            dialog = wx.TextEntryDialog(self, 'Enter a name for the new perspective:', 'Save perspective')\r
-            dialog.SetValue('New perspective')\r
-            if dialog.ShowModal() != wx.ID_OK:\r
-                return\r
-            else:\r
-                name = dialog.GetValue()\r
-\r
-            if nameExists(name):\r
-                dialogConfirm = wx.MessageDialog(self, 'A file with this name already exists.\n\nDo you want to replace it?', 'Confirm', wx.YES_NO|wx.ICON_QUESTION|wx.CENTER)\r
-                if dialogConfirm.ShowModal() == wx.ID_YES:\r
-                    done = True\r
-            else:\r
-                done = True\r
-\r
-        perspective = self._c['manager'].SavePerspective()\r
-        self._SavePerspectiveToFile(name, perspective)\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
-#            #replace the perspectiveStr in _pespectives\r
-#            self._perspectives[name] = perspective\r
-#        else:\r
-#            #because we deal with radio items, we need to do some extra work\r
-#            #delete all menu items from the perspectives menu\r
-#            for item in self._perspectives_menu.GetMenuItems():\r
-#                self._perspectives_menu.DeleteItem(item)\r
-#            #recreate the perspectives menu\r
-#            self._perspectives_menu.Append(ID_SavePerspective, 'Save Perspective')\r
-#            self._perspectives_menu.Append(ID_DeletePerspective, 'Delete Perspective')\r
-#            self._perspectives_menu.AppendSeparator()\r
-#            #convert the perspectives dictionary into a list\r
-#            # the list contains:\r
-#            #[0]: name of the perspective\r
-#            #[1]: perspective\r
-#            perspectives_list = [key for key, value in self._perspectives.iteritems()]\r
-#            perspectives_list.append(name)\r
-#            perspectives_list.sort()\r
-#            #add all previous perspectives\r
-#            for index, item in enumerate(perspectives_list):\r
-#                menu_item = self._perspectives_menu.AppendRadioItem(ID_FirstPerspective + index, item)\r
-#                if item == name:\r
-#                    menu_item.Check()\r
-#            #add the new perspective to _perspectives\r
-#            self._perspectives[name] = perspective\r
 \r
-    def OnSize(self, event):\r
+    def _on_size(self, event):\r
         event.Skip()\r
 \r
     def OnTreeCtrlCommandsSelectionChanged(self, event):\r
@@ -871,7 +878,7 @@ class HookeFrame (wx.Frame):
         active_file = self.GetActiveFile()\r
         active_file.note = self.panelNote.Editor.GetValue()\r
 \r
-    def OnView(self, event):\r
+    def _on_view(self, event):\r
         menu_id = event.GetId()\r
         menu_item = self.MenuBar.FindItemById(menu_id)\r
         menu_label = menu_item.GetLabel()\r
@@ -1022,40 +1029,6 @@ class HookeFrame (wx.Frame):
         if active_file is not None:\r
             self.panelNote.Editor.SetValue(active_file.note)\r
 \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
-                filename = lh.get_file_path(perspectiveFilename, ['perspectives'])\r
-                if os.path.isfile(filename):\r
-                    perspectiveFile = open(filename, 'rU')\r
-                    perspective = perspectiveFile.readline()\r
-                    perspectiveFile.close()\r
-                    if perspective:\r
-                        name, extension = os.path.splitext(perspectiveFilename)\r
-                        if extension == '.txt':\r
-                            self._perspectives[name] = perspective\r
-\r
-        #in case there are no perspectives\r
-        if not self._perspectives:\r
-            perspective = self._c['manager'].SavePerspective()\r
-            self._perspectives['Default'] = perspective\r
-            self._SavePerspectiveToFile('Default', perspective)\r
-\r
-        selected_perspective = self.gui.config['active perspective']\r
-        if not self._perspectives.has_key(selected_perspective):\r
-            self.gui.config['active perspective'] = 'Default'\r
-            selected_perspective = 'Default'\r
-\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
         if playlist is not None:\r
@@ -1240,8 +1213,8 @@ class GUI (UserInterface):
             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
+            Setting(section=self.setting_section, option='perspective path',\r
+                    value=os.path.join('resources', 'gui', 'perspective'),\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