]> git.saurik.com Git - wxWidgets.git/blob - wxPython/wx/lib/mixins/inspect.py
fixed child windows scrolling to use wxSIZE_ALLOW_MINUS_ONE
[wxWidgets.git] / wxPython / wx / lib / mixins / inspect.py
1 #----------------------------------------------------------------------------
2 # Name: wx.lib.mixins.inspect
3 # Purpose: A mix-in class that can add PyCrust-based inspection of the app
4 #
5 # Author: Robin Dunn
6 #
7 # Created: 21-Nov-2006
8 # RCS-ID: $Id$
9 # Copyright: (c) 2006 by Total Control Software
10 # Licence: wxWindows license
11 #----------------------------------------------------------------------------
12
13 # NOTE: This class is based on ideas sent to the wxPython-users
14 # mail-list by Dan Eloff.
15
16 import wx
17 import wx.py
18
19 class InspectionMixin(object):
20 """
21 This class is intended to be used as a mix-in with the wx.App
22 object. When used it will add the ability to popup a PyCrust
23 window where the widget under the mouse cursor will be loaded into
24 the shell's namespace as 'win'.
25
26 To use this class simply derive a class from wx.App and
27 InspectionMixin and then call the Init() method from the app's
28 OnInit.
29 """
30 def Init(self, pos=(-1, -1), size=(-1, -1)):
31 """
32 Make the event binding that will activate the PyCrust window.
33 """
34 self.Bind(wx.EVT_KEY_DOWN, self.OnKeyPress)
35 self._crust = None
36 self._pos = pos
37 self._size = size
38
39
40 def OnKeyPress(self, evt):
41 """
42 Event handler
43 """
44 if evt.AltDown() and evt.CmdDown() and evt.KeyCode == ord('I'):
45 self.ShowShell()
46 else:
47 evt.Skip()
48
49
50 def ShowShell(self):
51 """
52 Show the PyCrust window.
53 """
54 if not self._crust:
55 self._crust = wx.py.crust.CrustFrame(self.GetTopWindow(),
56 pos = self._pos, size = self._size)
57 self._crust.shell.interp.locals['app'] = self
58 self._crust.shell.interp.locals['wx'] = wx
59 win = wx.FindWindowAtPointer()
60 self._crust.shell.interp.locals['win'] = win
61 self._crust.Show()