From: W. Trevor King Date: Tue, 27 Jul 2010 14:47:32 +0000 (-0400) Subject: ViewMenu now works with new gui layout X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=61f8bbbada335ecd748bcc18e8e2eb178ea0fc61;p=hooke.git ViewMenu now works with new gui layout --- diff --git a/hooke/ui/gui/__init__.py b/hooke/ui/gui/__init__.py index f83936d..e9e45f5 100644 --- a/hooke/ui/gui/__init__.py +++ b/hooke/ui/gui/__init__.py @@ -79,6 +79,9 @@ class HookeFrame (wx.Frame): callbacks={ 'close': self._on_close, 'about': self._on_about, + 'view_panel': self._on_panel_visibility, + 'save_perspective': self._on_save_perspective, + 'delete_perspective': self._on_delete_perspective, }) self.SetMenuBar(self._c['menu bar']) @@ -677,13 +680,10 @@ class HookeFrame (wx.Frame): active_file = self.GetActiveFile() active_file.note = self.panelNote.Editor.GetValue() - def _on_view(self, event): - menu_id = event.GetId() - menu_item = self._c['menu bar'].FindItemById(menu_id) - menu_label = menu_item.GetLabel() - - pane = self._c['manager'].GetPane(menu_label) - pane.Show(not pane.IsShown()) + def _on_panel_visibility(self, _class, method, panel_name, visible): + pane = self._c['manager'].GetPane(panel_name) + print visible + pane.Show(visible) #if we don't do the following, the Folders pane does not resize properly on hide/show if pane.caption == 'Folders' and pane.IsShown() and pane.IsDocked(): #folders_size = pane.GetSize() diff --git a/hooke/ui/gui/menu.py b/hooke/ui/gui/menu.py index 836bcec..320bc43 100644 --- a/hooke/ui/gui/menu.py +++ b/hooke/ui/gui/menu.py @@ -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):