]>
git.saurik.com Git - wxWidgets.git/blob - wxPython/wx/lib/mixins/inspect.py
782123359ab4b90fb676e0791e30c7b3bc68a945
1 #----------------------------------------------------------------------------
2 # Name: wx.lib.mixins.inspect
3 # Purpose: A mix-in class that can add PyCrust-based inspection of the app
9 # Copyright: (c) 2006 by Total Control Software
10 # Licence: wxWindows license
11 #----------------------------------------------------------------------------
13 # NOTE: This class is based on ideas sent to the wxPython-users
14 # mail-list by Dan Elof.
18 class InspectionMixin(object):
20 This class is intended to be used as a mix-in with the wx.App
21 object. When used it will add the ability to popup a PyCrust
22 window where the widget under the mouse cursor will be loaded into
23 the shell's namespace as 'win'.
25 To use this class simply derive a class from wx.App and
26 InspectionMixin and then call the Init() method from the app's
31 Make the event binding that will activate the PyCrust window.
33 self
.Bind(wx
.EVT_KEY_DOWN
, self
.OnKeyPress
)
37 def OnKeyPress(self
, evt
):
41 if evt
.AltDown() and evt
.CmdDown() and evt
.KeyCode
== ord('I'):
49 Show the PyCrust window.
52 self
._crust
= wx
.py
.crust
.CrustFrame(self
.GetTopWindow())
53 self
._crust
.shell
.interp
.locals['app'] = self
54 win
= wx
.FindWindowAtPointer()
55 self
._crust
.shell
.interp
.locals['win'] = win