[Python-checkins] r65410 - in sandbox/trunk/ttk-gsoc/src/idlelib: OutputWindow.py PyShell.py utils.py

guilherme.polo python-checkins at python.org
Sat Aug 2 16:12:38 CEST 2008


Author: guilherme.polo
Date: Sat Aug  2 16:12:37 2008
New Revision: 65410

Log:
Added a utils.callback to call a callback with arbitrary arguments

Added:
   sandbox/trunk/ttk-gsoc/src/idlelib/utils.py
Modified:
   sandbox/trunk/ttk-gsoc/src/idlelib/OutputWindow.py
   sandbox/trunk/ttk-gsoc/src/idlelib/PyShell.py

Modified: sandbox/trunk/ttk-gsoc/src/idlelib/OutputWindow.py
==============================================================================
--- sandbox/trunk/ttk-gsoc/src/idlelib/OutputWindow.py	(original)
+++ sandbox/trunk/ttk-gsoc/src/idlelib/OutputWindow.py	Sat Aug  2 16:12:37 2008
@@ -1,14 +1,10 @@
 import re
 import tkMessageBox
 
+import utils
 import IOBinding
 from EditorWindow import EditorWindow
 
-def _callback(func, *myargs):
-    def w(*args):
-        return func(*(args + myargs))
-    return w
-
 class OutputWindow(EditorWindow):
 
     """An editor window that can serve as an output file.
@@ -25,7 +21,7 @@
 
     def __configure_new_tab(self, event=None):
         page = self.text_notebook.last_page().editpage
-        page.text.bind("<<goto-file-line>>", _callback(self.goto_file_line,
+        page.text.bind("<<goto-file-line>>", utils.callback(self.goto_file_line,
             page.text))
 
     # Customize EditorWindow

Modified: sandbox/trunk/ttk-gsoc/src/idlelib/PyShell.py
==============================================================================
--- sandbox/trunk/ttk-gsoc/src/idlelib/PyShell.py	(original)
+++ sandbox/trunk/ttk-gsoc/src/idlelib/PyShell.py	Sat Aug  2 16:12:37 2008
@@ -35,6 +35,7 @@
 idleConf.SaveUserCfgFiles()
 
 import rpc
+import utils
 import idlever
 import Debugger
 import RemoteDebugger
@@ -83,11 +84,6 @@
         return s
     warnings.formatwarning = idle_formatwarning
 
-def _callback(func, *myargs):
-    def w(*args):
-        return func(*(args + myargs))
-    return w
-
 def extended_linecache_checkcache(filename=None,
                                   orig_checkcache=linecache.checkcache):
     """Extend linecache.checkcache to preserve the <pyshell#...> entries
@@ -132,9 +128,9 @@
         text = page.text
 
         text.bind("<<set-breakpoint-here>>",
-            _callback(self._set_breakpoint_here, text, page))
+            utils.callback(self._set_breakpoint_here, text, page))
         text.bind("<<clear-breakpoint-here>>",
-            _callback(self._clear_breakpoint_here, text, page))
+            utils.callback(self._clear_breakpoint_here, text, page))
         text.bind("<<open-python-shell>>", self.flist.open_shell)
 
         # whenever a file is changed, restore breakpoints
@@ -877,19 +873,19 @@
 
         text.configure(wrap="char")
         text.bind("<<newline-and-indent>>",
-            _callback(self._enter_callback, text))
+            utils.callback(self._enter_callback, text))
         text.bind("<<plain-newline-and-indent>>",
-            _callback(self._linefeed_callback, text))
+            utils.callback(self._linefeed_callback, text))
         text.bind("<<interrupt-execution>>",
-            _callback(self._cancel_callback, text))
+            utils.callback(self._cancel_callback, text))
         text.bind("<<end-of-file>>",
-            _callback(self._eof_callback, text))
+            utils.callback(self._eof_callback, text))
         text.bind("<<toggle-debugger>>", self._toggle_debugger)
         text.bind("<<toggle-jit-stack-viewer>>", self._toggle_jit_stack_viewer)
         text.bind("<<open-stack-viewer>>", self.open_stack_viewer)
         if use_subprocess:
             text.bind("<<view-restart>>",
-                _callback(self._view_restart_mark, text))
+                utils.callback(self._view_restart_mark, text))
             text.bind("<<restart-shell>>", self.restart_shell)
 
         page.history = self.History(text)

Added: sandbox/trunk/ttk-gsoc/src/idlelib/utils.py
==============================================================================
--- (empty file)
+++ sandbox/trunk/ttk-gsoc/src/idlelib/utils.py	Sat Aug  2 16:12:37 2008
@@ -0,0 +1,4 @@
+def callback(func, *myargs):
+    def w(*args):
+        return func(*(args + myargs))
+    return w


More information about the Python-checkins mailing list