Switch to AUI instead of splitter windows. Also load and save config settings.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_8_BRANCH@44320 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -17,6 +17,7 @@
|
|||||||
import wx
|
import wx
|
||||||
import wx.py
|
import wx.py
|
||||||
import wx.stc
|
import wx.stc
|
||||||
|
import wx.aui
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
|
|
||||||
@@ -105,22 +106,27 @@ class InspectionFrame(wx.Frame):
|
|||||||
|
|
||||||
self.MacSetMetalAppearance(True)
|
self.MacSetMetalAppearance(True)
|
||||||
self.MakeToolBar()
|
self.MakeToolBar()
|
||||||
|
panel = wx.Panel(self, size=self.GetClientSize())
|
||||||
|
|
||||||
self.outerSplitter = wx.SplitterWindow(self,style=wx.SP_LIVE_UPDATE)
|
# tell FrameManager to manage this frame
|
||||||
self.innerSplitter = wx.SplitterWindow(self.outerSplitter,style=wx.SP_LIVE_UPDATE)
|
self.mgr = wx.aui.AuiManager(panel,
|
||||||
self.tree = InspectionTree(self.outerSplitter)
|
wx.aui.AUI_MGR_DEFAULT
|
||||||
self.info = InspectionInfoPanel(self.innerSplitter)
|
| wx.aui.AUI_MGR_TRANSPARENT_DRAG
|
||||||
|
| wx.aui.AUI_MGR_ALLOW_ACTIVE_PANE)
|
||||||
|
|
||||||
|
# make the child tools
|
||||||
|
self.tree = InspectionTree(panel)
|
||||||
|
self.info = InspectionInfoPanel(panel)
|
||||||
|
|
||||||
if not locals:
|
if not locals:
|
||||||
locals = {}
|
locals = {}
|
||||||
myIntroText = (
|
myIntroText = (
|
||||||
"Python %s on %s\nNOTE: The 'obj' variable refers to the selected object."
|
"Python %s on %s\nNOTE: The 'obj' variable refers to the object selected in the tree."
|
||||||
% (sys.version.split()[0], sys.platform))
|
% (sys.version.split()[0], sys.platform))
|
||||||
self.crust = wx.py.crust.Crust(self.innerSplitter, locals=locals,
|
self.crust = wx.py.crust.Crust(panel, locals=locals,
|
||||||
intro=myIntroText,
|
intro=myIntroText,
|
||||||
showInterpIntro=False,
|
showInterpIntro=False,
|
||||||
)
|
)
|
||||||
self.crust.shell.SetMarginWidth(1, 0)
|
|
||||||
self.locals = self.crust.shell.interp.locals
|
self.locals = self.crust.shell.interp.locals
|
||||||
self.crust.shell.interp.introText = ''
|
self.crust.shell.interp.introText = ''
|
||||||
self.locals['obj'] = self.obj = wnd
|
self.locals['obj'] = self.obj = wnd
|
||||||
@@ -128,10 +134,33 @@ class InspectionFrame(wx.Frame):
|
|||||||
self.locals['wx'] = wx
|
self.locals['wx'] = wx
|
||||||
wx.CallAfter(self._postStartup)
|
wx.CallAfter(self._postStartup)
|
||||||
|
|
||||||
self.innerSplitter.SplitHorizontally(self.info, self.crust, -225)
|
# put the chlid tools in AUI panes
|
||||||
self.outerSplitter.SplitVertically(self.tree, self.innerSplitter, 280)
|
self.mgr.AddPane(self.info,
|
||||||
self.outerSplitter.SetMinimumPaneSize(20)
|
wx.aui.AuiPaneInfo().Name("info").Caption("Object Info").
|
||||||
self.innerSplitter.SetMinimumPaneSize(20)
|
CenterPane().CaptionVisible(True).
|
||||||
|
CloseButton(False).MaximizeButton(True)
|
||||||
|
)
|
||||||
|
self.mgr.AddPane(self.tree,
|
||||||
|
wx.aui.AuiPaneInfo().Name("tree").Caption("Widget Tree").
|
||||||
|
CaptionVisible(True).Left().Dockable(True).Floatable(True).
|
||||||
|
BestSize((280,200)).CloseButton(False).MaximizeButton(True)
|
||||||
|
)
|
||||||
|
self.mgr.AddPane(self.crust,
|
||||||
|
wx.aui.AuiPaneInfo().Name("crust").Caption("PyCrust").
|
||||||
|
CaptionVisible(True).Bottom().Dockable(True).Floatable(True).
|
||||||
|
BestSize((400,200)).CloseButton(False).MaximizeButton(True)
|
||||||
|
)
|
||||||
|
|
||||||
|
self.mgr.Update()
|
||||||
|
|
||||||
|
if config is None:
|
||||||
|
config = wx.Config('wxpyinspector')
|
||||||
|
self.config = config
|
||||||
|
self.Bind(wx.EVT_CLOSE, self.OnClose)
|
||||||
|
self.LoadSettings(self.config)
|
||||||
|
self.crust.shell.lineNumbers = False
|
||||||
|
self.crust.shell.setDisplayLineNumbers(False)
|
||||||
|
self.crust.shell.SetMarginWidth(1, 0)
|
||||||
|
|
||||||
|
|
||||||
def MakeToolBar(self):
|
def MakeToolBar(self):
|
||||||
@@ -170,9 +199,16 @@ class InspectionFrame(wx.Frame):
|
|||||||
self.UpdateInfo()
|
self.UpdateInfo()
|
||||||
self.started = True
|
self.started = True
|
||||||
|
|
||||||
|
|
||||||
|
def OnClose(self, evt):
|
||||||
|
self.SaveSettings(self.config)
|
||||||
|
evt.Skip()
|
||||||
|
|
||||||
|
|
||||||
def UpdateInfo(self):
|
def UpdateInfo(self):
|
||||||
self.info.Update(self.obj)
|
self.info.Update(self.obj)
|
||||||
|
|
||||||
|
|
||||||
def SetObj(self, obj):
|
def SetObj(self, obj):
|
||||||
if self.obj is obj:
|
if self.obj is obj:
|
||||||
return
|
return
|
||||||
@@ -198,6 +234,7 @@ class InspectionFrame(wx.Frame):
|
|||||||
self.CaptureMouse()
|
self.CaptureMouse()
|
||||||
self.finding = wx.BusyInfo("Click on any widget in the app...")
|
self.finding = wx.BusyInfo("Click on any widget in the app...")
|
||||||
|
|
||||||
|
|
||||||
def OnCaptureLost(self, evt):
|
def OnCaptureLost(self, evt):
|
||||||
self.Unbind(wx.EVT_LEFT_DOWN)
|
self.Unbind(wx.EVT_LEFT_DOWN)
|
||||||
self.Unbind(wx.EVT_MOUSE_CAPTURE_LOST)
|
self.Unbind(wx.EVT_MOUSE_CAPTURE_LOST)
|
||||||
@@ -231,6 +268,38 @@ class InspectionFrame(wx.Frame):
|
|||||||
evt.Check(self.crust.ToolsShown())
|
evt.Check(self.crust.ToolsShown())
|
||||||
|
|
||||||
|
|
||||||
|
def LoadSettings(self, config):
|
||||||
|
self.crust.LoadSettings(config)
|
||||||
|
|
||||||
|
pos = wx.Point(config.ReadInt('Window/PosX', -1),
|
||||||
|
config.ReadInt('Window/PosY', -1))
|
||||||
|
|
||||||
|
size = wx.Size(config.ReadInt('Window/Width', -1),
|
||||||
|
config.ReadInt('Window/Height', -1))
|
||||||
|
self.SetSize(size)
|
||||||
|
self.Move(pos)
|
||||||
|
|
||||||
|
perspective = config.Read('perspective', '')
|
||||||
|
if perspective:
|
||||||
|
self.mgr.LoadPerspective(perspective)
|
||||||
|
self.includeSizers = config.ReadBool('includeSizers', False)
|
||||||
|
|
||||||
|
|
||||||
|
def SaveSettings(self, config):
|
||||||
|
self.crust.SaveSettings(config)
|
||||||
|
|
||||||
|
if not self.IsIconized() and not self.IsMaximized():
|
||||||
|
w, h = self.GetSize()
|
||||||
|
config.WriteInt('Window/Width', w)
|
||||||
|
config.WriteInt('Window/Height', h)
|
||||||
|
|
||||||
|
px, py = self.GetPosition()
|
||||||
|
config.WriteInt('Window/PosX', px)
|
||||||
|
config.WriteInt('Window/PosY', py)
|
||||||
|
|
||||||
|
perspective = self.mgr.SavePerspective()
|
||||||
|
config.Write('perspective', perspective)
|
||||||
|
config.WriteBool('includeSizers', self.includeSizers)
|
||||||
|
|
||||||
#---------------------------------------------------------------------------
|
#---------------------------------------------------------------------------
|
||||||
|
|
||||||
@@ -249,7 +318,7 @@ class InspectionTree(wx.TreeCtrl):
|
|||||||
self.roots = []
|
self.roots = []
|
||||||
self.built = False
|
self.built = False
|
||||||
self.Bind(wx.EVT_TREE_SEL_CHANGED, self.OnSelectionChanged)
|
self.Bind(wx.EVT_TREE_SEL_CHANGED, self.OnSelectionChanged)
|
||||||
|
self.toolFrame = wx.GetTopLevelParent(self)
|
||||||
|
|
||||||
def BuildTree(self, startWidget, includeSizers=False):
|
def BuildTree(self, startWidget, includeSizers=False):
|
||||||
if self.GetCount():
|
if self.GetCount():
|
||||||
@@ -360,8 +429,7 @@ class InspectionTree(wx.TreeCtrl):
|
|||||||
|
|
||||||
def OnSelectionChanged(self, evt):
|
def OnSelectionChanged(self, evt):
|
||||||
obj = self.GetItemPyData(evt.GetItem())
|
obj = self.GetItemPyData(evt.GetItem())
|
||||||
toolFrm = wx.GetTopLevelParent(self)
|
self.toolFrame.SetObj(obj)
|
||||||
toolFrm.SetObj(obj)
|
|
||||||
|
|
||||||
|
|
||||||
#---------------------------------------------------------------------------
|
#---------------------------------------------------------------------------
|
||||||
|
Reference in New Issue
Block a user