PyCrust now has an option for showing/hiding the notebook.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@44215 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -17,6 +17,8 @@ multiple event types at once, and in these cases the typeId property
|
|||||||
may not give you what you want. You should use te component events in
|
may not give you what you want. You should use te component events in
|
||||||
these cases.
|
these cases.
|
||||||
|
|
||||||
|
PyCrust now has an option for showing/hiding the notebook.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@@ -76,18 +76,48 @@ class Crust(wx.SplitterWindow):
|
|||||||
self.dispatcherlisting = DispatcherListing(parent=self.notebook)
|
self.dispatcherlisting = DispatcherListing(parent=self.notebook)
|
||||||
self.notebook.AddPage(page=self.dispatcherlisting, text='Dispatcher')
|
self.notebook.AddPage(page=self.dispatcherlisting, text='Dispatcher')
|
||||||
|
|
||||||
self.SplitHorizontally(self.shell, self.notebook, -self.sashoffset)
|
|
||||||
|
# Initialize in an unsplit mode, and check later after loading
|
||||||
|
# settings if we should split or not.
|
||||||
|
self.shell.Hide()
|
||||||
|
self.notebook.Hide()
|
||||||
|
self.Initialize(self.shell)
|
||||||
|
self._shouldsplit = True
|
||||||
|
wx.CallAfter(self._CheckShouldSplit)
|
||||||
self.SetMinimumPaneSize(100)
|
self.SetMinimumPaneSize(100)
|
||||||
|
|
||||||
self.Bind(wx.EVT_SIZE, self.SplitterOnSize)
|
self.Bind(wx.EVT_SIZE, self.SplitterOnSize)
|
||||||
self.Bind(wx.EVT_SPLITTER_SASH_POS_CHANGED, self.OnChanged)
|
self.Bind(wx.EVT_SPLITTER_SASH_POS_CHANGED, self.OnChanged)
|
||||||
|
self.Bind(wx.EVT_SPLITTER_DCLICK, self.OnSashDClick)
|
||||||
|
|
||||||
|
def _CheckShouldSplit(self):
|
||||||
|
if self._shouldsplit:
|
||||||
|
self.SplitHorizontally(self.shell, self.notebook, -self.sashoffset)
|
||||||
|
self.lastsashpos = self.GetSashPosition()
|
||||||
|
else:
|
||||||
|
self.lastsashpos = -1
|
||||||
|
|
||||||
|
def ToggleTools(self):
|
||||||
|
"""Toggle the display of the filling and other tools"""
|
||||||
|
if self.issplit:
|
||||||
|
self.Unsplit()
|
||||||
|
else:
|
||||||
|
self.SplitHorizontally(self.shell, self.notebook, -self.sashoffset)
|
||||||
|
self.lastsashpos = self.GetSashPosition()
|
||||||
|
self.issplit = self.IsSplit()
|
||||||
|
|
||||||
|
def ToolsShown(self):
|
||||||
|
return self.issplit
|
||||||
|
|
||||||
def OnChanged(self, event):
|
def OnChanged(self, event):
|
||||||
"""update sash offset from the bottom of the window"""
|
"""update sash offset from the bottom of the window"""
|
||||||
self.sashoffset = self.GetSize().height - event.GetSashPosition()
|
self.sashoffset = self.GetSize().height - event.GetSashPosition()
|
||||||
|
self.lastsashpos = event.GetSashPosition()
|
||||||
event.Skip()
|
event.Skip()
|
||||||
|
|
||||||
|
def OnSashDClick(self, event):
|
||||||
|
self.Unsplit()
|
||||||
|
self.issplit = False
|
||||||
|
|
||||||
# Make the splitter expand the top window when resized
|
# Make the splitter expand the top window when resized
|
||||||
def SplitterOnSize(self, event):
|
def SplitterOnSize(self, event):
|
||||||
@@ -110,13 +140,17 @@ class Crust(wx.SplitterWindow):
|
|||||||
zoom = config.ReadInt('View/Zoom/Display', -99)
|
zoom = config.ReadInt('View/Zoom/Display', -99)
|
||||||
if zoom != -99:
|
if zoom != -99:
|
||||||
self.display.SetZoom(zoom)
|
self.display.SetZoom(zoom)
|
||||||
|
self.issplit = config.ReadInt('Sash/IsSplit', True)
|
||||||
|
if not self.issplit:
|
||||||
|
self._shouldsplit = False
|
||||||
|
|
||||||
def SaveSettings(self, config):
|
def SaveSettings(self, config):
|
||||||
self.shell.SaveSettings(config)
|
self.shell.SaveSettings(config)
|
||||||
self.filling.SaveSettings(config)
|
self.filling.SaveSettings(config)
|
||||||
|
|
||||||
config.WriteInt('Sash/CrustPos', self.GetSashPosition())
|
if self.lastsashpos != -1:
|
||||||
|
config.WriteInt('Sash/CrustPos', self.lastsashpos)
|
||||||
|
config.WriteInt('Sash/IsSplit', self.issplit)
|
||||||
config.WriteInt('View/Zoom/Display', self.display.GetZoom())
|
config.WriteInt('View/Zoom/Display', self.display.GetZoom())
|
||||||
|
|
||||||
|
|
||||||
@@ -307,6 +341,13 @@ class CrustFrame(frame.Frame, frame.ShellFrameMixin):
|
|||||||
dialog.Destroy()
|
dialog.Destroy()
|
||||||
|
|
||||||
|
|
||||||
|
def ToggleTools(self):
|
||||||
|
"""Toggle the display of the filling and other tools"""
|
||||||
|
return self.crust.ToggleTools()
|
||||||
|
|
||||||
|
def ToolsShown(self):
|
||||||
|
return self.crust.ToolsShown()
|
||||||
|
|
||||||
def OnHelp(self, event):
|
def OnHelp(self, event):
|
||||||
"""Show a help dialog."""
|
"""Show a help dialog."""
|
||||||
frame.ShellFrameMixin.OnHelp(self, event)
|
frame.ShellFrameMixin.OnHelp(self, event)
|
||||||
|
@@ -55,6 +55,7 @@ ID_STARTUP = wx.NewId()
|
|||||||
ID_SETTINGS = wx.NewId()
|
ID_SETTINGS = wx.NewId()
|
||||||
ID_FIND = wx.ID_FIND
|
ID_FIND = wx.ID_FIND
|
||||||
ID_FINDNEXT = wx.NewId()
|
ID_FINDNEXT = wx.NewId()
|
||||||
|
ID_SHOWTOOLS = wx.NewId()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -154,6 +155,10 @@ class Frame(wx.Frame):
|
|||||||
'Wrap lines at right edge', wx.ITEM_CHECK)
|
'Wrap lines at right edge', wx.ITEM_CHECK)
|
||||||
m.Append(ID_SHOW_LINENUMBERS, '&Show Line Numbers\tCtrl+Shift+L', 'Show Line Numbers', wx.ITEM_CHECK)
|
m.Append(ID_SHOW_LINENUMBERS, '&Show Line Numbers\tCtrl+Shift+L', 'Show Line Numbers', wx.ITEM_CHECK)
|
||||||
m.Append(ID_TOGGLE_MAXIMIZE, '&Toggle Maximize\tF11', 'Maximize/Restore Application')
|
m.Append(ID_TOGGLE_MAXIMIZE, '&Toggle Maximize\tF11', 'Maximize/Restore Application')
|
||||||
|
if hasattr(self, 'ToggleTools'):
|
||||||
|
m.Append(ID_SHOWTOOLS,
|
||||||
|
'Show &Tools\tF4',
|
||||||
|
'Show the filling and other tools', wx.ITEM_CHECK)
|
||||||
|
|
||||||
# Options
|
# Options
|
||||||
m = self.autocompMenu = wx.Menu()
|
m = self.autocompMenu = wx.Menu()
|
||||||
@@ -268,6 +273,7 @@ class Frame(wx.Frame):
|
|||||||
self.Bind(wx.EVT_MENU, self.OnExecStartupScript, id=ID_EXECSTARTUPSCRIPT)
|
self.Bind(wx.EVT_MENU, self.OnExecStartupScript, id=ID_EXECSTARTUPSCRIPT)
|
||||||
self.Bind(wx.EVT_MENU, self.OnFindText, id=ID_FIND)
|
self.Bind(wx.EVT_MENU, self.OnFindText, id=ID_FIND)
|
||||||
self.Bind(wx.EVT_MENU, self.OnFindNext, id=ID_FINDNEXT)
|
self.Bind(wx.EVT_MENU, self.OnFindNext, id=ID_FINDNEXT)
|
||||||
|
self.Bind(wx.EVT_MENU, self.OnToggleTools, id=ID_SHOWTOOLS)
|
||||||
|
|
||||||
self.Bind(wx.EVT_UPDATE_UI, self.OnUpdateMenu, id=ID_NEW)
|
self.Bind(wx.EVT_UPDATE_UI, self.OnUpdateMenu, id=ID_NEW)
|
||||||
self.Bind(wx.EVT_UPDATE_UI, self.OnUpdateMenu, id=ID_OPEN)
|
self.Bind(wx.EVT_UPDATE_UI, self.OnUpdateMenu, id=ID_OPEN)
|
||||||
@@ -306,6 +312,7 @@ class Frame(wx.Frame):
|
|||||||
self.Bind(wx.EVT_UPDATE_UI, self.OnUpdateMenu, id=ID_EDITSTARTUPSCRIPT)
|
self.Bind(wx.EVT_UPDATE_UI, self.OnUpdateMenu, id=ID_EDITSTARTUPSCRIPT)
|
||||||
self.Bind(wx.EVT_UPDATE_UI, self.OnUpdateMenu, id=ID_FIND)
|
self.Bind(wx.EVT_UPDATE_UI, self.OnUpdateMenu, id=ID_FIND)
|
||||||
self.Bind(wx.EVT_UPDATE_UI, self.OnUpdateMenu, id=ID_FINDNEXT)
|
self.Bind(wx.EVT_UPDATE_UI, self.OnUpdateMenu, id=ID_FINDNEXT)
|
||||||
|
self.Bind(wx.EVT_UPDATE_UI, self.OnUpdateMenu, id=ID_SHOWTOOLS)
|
||||||
|
|
||||||
self.Bind(wx.EVT_ACTIVATE, self.OnActivate)
|
self.Bind(wx.EVT_ACTIVATE, self.OnActivate)
|
||||||
self.Bind(wx.EVT_FIND, self.OnFindNext)
|
self.Bind(wx.EVT_FIND, self.OnFindNext)
|
||||||
@@ -510,6 +517,8 @@ class Frame(wx.Frame):
|
|||||||
self.findDlg.Destroy()
|
self.findDlg.Destroy()
|
||||||
self.findDlg = None
|
self.findDlg = None
|
||||||
|
|
||||||
|
def OnToggleTools(self, event):
|
||||||
|
self.ToggleTools()
|
||||||
|
|
||||||
|
|
||||||
def OnUpdateMenu(self, event):
|
def OnUpdateMenu(self, event):
|
||||||
@@ -610,6 +619,9 @@ class Frame(wx.Frame):
|
|||||||
elif id == ID_FINDNEXT:
|
elif id == ID_FINDNEXT:
|
||||||
event.Enable(hasattr(win, 'DoFindNext'))
|
event.Enable(hasattr(win, 'DoFindNext'))
|
||||||
|
|
||||||
|
elif id == ID_SHOWTOOLS:
|
||||||
|
event.Check(self.ToolsShown())
|
||||||
|
|
||||||
else:
|
else:
|
||||||
event.Enable(False)
|
event.Enable(False)
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
|
Reference in New Issue
Block a user