]> git.saurik.com Git - wxWidgets.git/commitdiff
generate middle click events (backport from HEAD of the patch 1521314)
authorVadim Zeitlin <vadim@wxwidgets.org>
Tue, 25 Jul 2006 00:12:51 +0000 (00:12 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Tue, 25 Jul 2006 00:12:51 +0000 (00:12 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@43585 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

wxPython/demo/Main.py
wxPython/docs/CHANGES.txt
wxPython/wx/lib/mixins/inspect.py [new file with mode: 0644]

index 748c58060c47e2a5b5cfbb97a2724ecaba1d6ca7..ba1b09105990a63f781ef77945dc93f66f9e3427 100644 (file)
@@ -1772,8 +1772,9 @@ class MySplashScreen(wx.SplashScreen):
         if self.fc.IsRunning():
             self.Raise()
         
+import wx.lib.mixins.inspect
 
-class MyApp(wx.App):
+class MyApp(wx.App, wx.lib.mixins.inspect.InspectionMixin):
     def OnInit(self):
         """
         Create and show the splash screen.  It will then create and show
@@ -1794,6 +1795,9 @@ class MyApp(wx.App):
         splash = MySplashScreen()
         splash.Show()
 
+        # Setup the InspectionMixin
+        self.Init()
+        
         return True
 
 
index b2b2e2427b68d9882358f2db844193d88061d98f..b48e63de576075fbadb5347e18739a373474e28e 100644 (file)
@@ -29,6 +29,11 @@ works.
 Added wx.combo.BitmapComboBox which is a combobox that displays a
 bitmap in front of the list items.
 
+Added the wx.lib.mixins.inspect module.  It contains the InspectMixin
+class which can be mixed with a wx.App class and provides a PyCrust
+window that can be activated with a Ctrl-Alt-I keystroke (or Cmd-Alt-I
+on the Mac.)
+
 
 
 
diff --git a/wxPython/wx/lib/mixins/inspect.py b/wxPython/wx/lib/mixins/inspect.py
new file mode 100644 (file)
index 0000000..7821233
--- /dev/null
@@ -0,0 +1,58 @@
+#----------------------------------------------------------------------------
+# Name:        wx.lib.mixins.inspect
+# Purpose:     A mix-in class that can add PyCrust-based inspection of the app
+#
+# Author:      Robin Dunn
+#
+# Created:     21-Nov-2006
+# RCS-ID:      $Id$
+# Copyright:   (c) 2006 by Total Control Software
+# Licence:     wxWindows license
+#----------------------------------------------------------------------------
+
+# NOTE: This class is based on ideas sent to the wxPython-users
+# mail-list by Dan Elof.
+
+import wx.py
+
+class InspectionMixin(object):
+    """
+    This class is intended to be used as a mix-in with the wx.App
+    object.  When used it will add the ability to popup a PyCrust
+    window where the widget under the mouse cursor will be loaded into
+    the shell's namespace as 'win'.
+
+    To use this class simply derive a class from wx.App and
+    InspectionMixin and then call the Init() method from the app's
+    OnInit.
+    """    
+    def Init(self):
+        """
+        Make the event binding that will activate the PyCrust window.
+        """
+        self.Bind(wx.EVT_KEY_DOWN, self.OnKeyPress)
+        self._crust = None
+
+
+    def OnKeyPress(self, evt):
+        """
+        Event handler
+        """
+        if evt.AltDown() and evt.CmdDown() and evt.KeyCode == ord('I'):
+            self.ShowShell()
+        else:
+            evt.Skip()
+
+
+    def ShowShell(self):
+        """
+        Show the PyCrust window.
+        """
+        if not self._crust:
+            self._crust = wx.py.crust.CrustFrame(self.GetTopWindow())
+            self._crust.shell.interp.locals['app'] = self
+        win = wx.FindWindowAtPointer()
+        self._crust.shell.interp.locals['win'] = win
+        self._crust.Show()
+
+