[Python-checkins] r65570 - sandbox/trunk/ttk-gsoc/src/idlelib/FileList.py

guilherme.polo python-checkins at python.org
Thu Aug 7 15:51:14 CEST 2008


Author: guilherme.polo
Date: Thu Aug  7 15:51:14 2008
New Revision: 65570

Log:
Check for an existing PyShellEditorWindow to open a file/module there if no action is given and the necessary option for that is set

Modified:
   sandbox/trunk/ttk-gsoc/src/idlelib/FileList.py

Modified: sandbox/trunk/ttk-gsoc/src/idlelib/FileList.py
==============================================================================
--- sandbox/trunk/ttk-gsoc/src/idlelib/FileList.py	(original)
+++ sandbox/trunk/ttk-gsoc/src/idlelib/FileList.py	Thu Aug  7 15:51:14 2008
@@ -1,6 +1,8 @@
 import os
 import tkMessageBox
 
+from configHandler import idleConf
+
 def _canonize(filename):
     if not os.path.isabs(filename):
         try:
@@ -41,6 +43,22 @@
         if action:
             # Don't create window, perform 'action', e.g. open in same window
             return action(filename=filename)
+
+        elif idleConf.GetOption('main', 'EditorWindow', 'file-in-tab',
+           default=1, type='bool'):
+            # check if there is some PyShellEditorWindow running to open this
+            # new tab
+            for entry in self.inversedict:
+                if hasattr(entry, 'set_breakpoint'):
+                    # PyShellEditorWindow, good
+                    entry.new_tab(filename=filename)
+                    # select the last page created
+                    entry.text_notebook.select(len(entry.text_notebook.pages)-1)
+                    return entry
+            else:
+                # no PyShellEditorWindows, create one
+                return self.EditorWindow(self, filename, key)
+
         else:
             return self.EditorWindow(self, filename, key)
 


More information about the Python-checkins mailing list