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

by way of Stephen M. Gava <elguavas@users.sourceforge.net> noreply@sourceforge.net
Mon, 8 Oct 2001 13:08:06 +1000


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=9
579

Category: None
Group: None
Status: Open

>Resolution: Postponed

Priority: 5
Submitted By: Stephen M. Gava (elguavas)

>Assigned to: Stephen M. Gava (elguavas)

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: Stephen M. Gava (elguavas)

Date: 2001-10-07 19:59

Message:
Logged In: YES
user_id=75867

I like this idea in principle. I will 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:
http://sourceforge.net/tracker/?func=detail&atid=309579&aid=456006&group_id=9
579