[Idle-dev] [ idlefork-Patches-456006 ] open multiple modules at once

noreply@sourceforge.net noreply@sourceforge.net
Mon, 27 Aug 2001 21:11:30 -0700


Patches item #456006, was opened at 2001-08-27 21:11
You can respond by visiting: 
http://sourceforge.net/tracker/?func=detail&atid=309579&aid=456006&group_id=9579

Category: None
Group: None
Status: Open
Resolution: None
Priority: 5
Submitted By: Stephen M. Gava (elguavas)
Assigned to: Nobody/Anonymous (nobody)
Summary: open multiple modules at once

Initial Comment:

Every time I open a project, I open a lot of modules, 
and this was 
usually done by double-clicking each module in

import myModule1, myModule2, myModule3, myModule4, 
myModule5, myModule6

and pressing Alt-M to open it.

Now I patched EditorWindow.py to extend the ability 
of open_module to 
open a list of modules (and ignore the import 
keyword), so that one 
can select the whole line and open all modules with 
one Alt-M.

Below is the changed method open_module in 
EditorWindow.py, which can 
be substituted to the original to obtain the new 
behaviour.


     def open_module(self, event=None):
         # XXX Shouldn't this be in IOBinding or in 
FileList?
         try:
             name = self.text.get("sel.first", 
"sel.last")
         except TclError:
             name = ""
         else:
             name = string.strip(name)
         if not name:
             name = tkSimpleDialog.askstring("Module",
                      "Enter the name of a Python 
module\n"
                      "to search on sys.path and 
open:",
                      parent=self.text)
         name = string.replace(name, ",", " ")
         name = string.replace(name, ";", " ")
         nameList = string.split(name)
         # XXX Ought to support package syntax
         # XXX Ought to insert current file's 
directory in front of path
         for name in nameList:
             if name in ["", "import"]: continue
             try:
                 (f, file, (suffix, mode, type)) = 
imp.find_module(name)
             except (NameError, ImportError), msg:
                 tkMessageBox.showerror("Import 
error", str(msg), 
parent=self.text)
                 return
             if type != imp.PY_SOURCE:
                 tkMessageBox.showerror("Unsupported 
type",
                     "%s is not a source module" % 
name, parent=self.text)
                 return
             if f:
                 f.close()
             if self.flist:
                 self.flist.open(file)
             else:
                 self.io.loadfile(file)


Daniel Haertle

------------------------------------------------------------------------
         Daniel Haertle        
haertle@iqe.phys.ethz.ch
      _________________  ___   http://www.nlo.ethz.ch
     /  ____/_   __/  /_/  /   ETH Hoenggerberg - 
Nonlinear Optics Laboratory
    /  __/_  /  / /  __   /    Institute of Quantum 
Electronics, HPF E18
   /______/ /__/ /__/ /__/     8093 Zuerich   -   
Switzerland
                               Tel +41 1 63 32338    
Fax +41 1 63 31056
------------------------------------------------------------------------


----------------------------------------------------------------------

You can respond by visiting: 
http://sourceforge.net/tracker/?func=detail&atid=309579&aid=456006&group_id=9579