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

noreply@sourceforge.net noreply@sourceforge.net
Sun, 22 Sep 2002 18:05:33 -0700


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

Category: None
Group: None
Status: Open
Resolution: Postponed
Priority: 3
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
------------------------------------------------------------------------


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

Comment By: Kurt B. Kaiser (kbk)
Date: 2002-09-22 19:54

Message:
Logged In: YES 
user_id=149084

Per GvR Python style guide, PEP  8, 
multiple module names on one line are 
discouraged.  The sylistically allowable
exceptions are rather minor.  

Downgrade priority pending further
discussion whether this is worthwhile.


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

Comment By: Stephen M. Gava (elguavas)
Date: 2001-10-07 21:59

Message:
Logged In: YES 
user_id=75867

I like this idea in principle. I float implementation detail
ideas on idle-dev when I get the chance to eventually come
back to this in earnest.

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

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