ViewMenu now works with new gui layout
authorW. Trevor King <wking@drexel.edu>
Tue, 27 Jul 2010 14:47:32 +0000 (10:47 -0400)
committerW. Trevor King <wking@drexel.edu>
Tue, 27 Jul 2010 14:47:32 +0000 (10:47 -0400)
hooke/ui/gui/__init__.py
hooke/ui/gui/menu.py

index f83936d0a1c09959f042a6ccecbca58e5af4c95d..e9e45f504ac48d9a9e2482929ec18ad8e6e55186 100644 (file)
@@ -79,6 +79,9 @@ class HookeFrame (wx.Frame):
             callbacks={\r
                 'close': self._on_close,\r
                 'about': self._on_about,\r
+                'view_panel': self._on_panel_visibility,\r
+                'save_perspective': self._on_save_perspective,\r
+                'delete_perspective': self._on_delete_perspective,\r
                 })\r
         self.SetMenuBar(self._c['menu bar'])\r
 \r
@@ -677,13 +680,10 @@ class HookeFrame (wx.Frame):
         active_file = self.GetActiveFile()\r
         active_file.note = self.panelNote.Editor.GetValue()\r
 \r
-    def _on_view(self, event):\r
-        menu_id = event.GetId()\r
-        menu_item = self._c['menu bar'].FindItemById(menu_id)\r
-        menu_label = menu_item.GetLabel()\r
-\r
-        pane = self._c['manager'].GetPane(menu_label)\r
-        pane.Show(not pane.IsShown())\r
+    def _on_panel_visibility(self, _class, method, panel_name, visible):\r
+        pane = self._c['manager'].GetPane(panel_name)\r
+        print visible\r
+        pane.Show(visible)\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
index 836bcec92e5ef02018eaf61e03e8585b705ed98c..320bc436b49497819585d127379519a678943528 100644 (file)
@@ -67,10 +67,18 @@ class ViewMenu (Menu):
         self._callbacks = callbacks
         self._c = {}
         for i,panelname in enumerate(sorted(panel.PANELS.keys())):
-            text = '%s\tF%d' % (panelname.capitalize, i+5)
+            text = '%s\tF%d' % (panelname.capitalize(), i+5)
             self._c[panelname] = self.AppendCheckItem(id=wx.ID_ANY, text=text)
         for item in self._c.values():
             item.Check()
+            self.Bind(event=wx.EVT_MENU, handler=self.view_panel, id=item.GetId())
+
+    def view_panel(self, event):
+        _id = event.GetId()
+        item = self.FindItemById(_id)
+        label = item.GetLabel()
+        selected = item.IsChecked()
+        in_callback(self, panel_name=label, visible=selected)
 
 
 class PerspectiveMenu (Menu):