[issue21192] Idle: Print filename when running a file from editor

Adnan Umer report at bugs.python.org
Wed Apr 16 18:50:05 CEST 2014


Adnan Umer added the comment:

I tried to replace RESTART by doing these little changing

# PyShell.Py
class ModifiedInterpreter(InteractiveInterpreter):
    def restart_subprocess(self, with_cwd=False, with_msg=True):
        ...
        if with_msg:
            halfbar = ((int(console.width) - 16) // 2) * '='
            console.write(halfbar + ' RESTART ' + halfbar)

    def runcode(self, code):
        with_msg = True
        if code.co_filename[0] != '<':
            self.tkconsole.write('Executing ' + code.co_filename + '\n')
            with_msg = False
        
        if self.tkconsole.executing:
            self.interp.restart_subprocess(with_msg)

# ScriptBinding.Py
class ScriptBinding:
    def _run_module_event(self, event):
        filename = self.getfilename()
        if not filename:
            return 'break'
        code = self.checksyntax(filename)
        if not code:
            return 'break'
        if not self.tabnanny(filename):
            return 'break'
        interp = self.shell.interp
        if PyShell.use_subprocess:
            interp.restart_subprocess(with_cwd=False, with_msg=False)

This works fine and replaces RESTART with Execute <filename> when file is executed in Python Shell.

Also instead of this

halfbar = ((int(console.width) - 16) // 2) * '='
console.write(halfbar + ' RESTART ' + halfbar)

my recomemdation is:
console.write('[SHELL RESTART]')

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue21192>
_______________________________________


More information about the Python-bugs-list mailing list