Ejemplo n.º 1
0
    def __init__(self, flist=None):
        if use_subprocess:
            ms = self.menu_specs
            if ms[2][0] != "shell":
                ms.insert(2, ("shell", "She_ll"))
        self.interp = ModifiedInterpreter(self)
        if flist is None:
            root = Tk()
            fixwordbreaks(root)
            root.withdraw()
            flist = PyShellFileList(root)
        #
        OutputWindow.__init__(self, flist, None, None)
        #
        ##        self.config(usetabs=1, indentwidth=8, context_use_ps1=1)
        self.usetabs = True
        # indentwidth must be 8 when using tabs.  See note in EditorWindow:
        self.indentwidth = 8
        self.context_use_ps1 = True
        #
        text = self.text
        text.configure(wrap="char")
        text.bind("<<newline-and-indent>>", self.enter_callback)
        text.bind("<<plain-newline-and-indent>>", self.linefeed_callback)
        text.bind("<<interrupt-execution>>", self.cancel_callback)
        text.bind("<<end-of-file>>", self.eof_callback)
        text.bind("<<open-stack-viewer>>", self.open_stack_viewer)
        text.bind("<<toggle-debugger>>", self.toggle_debugger)
        text.bind("<<toggle-jit-stack-viewer>>", self.toggle_jit_stack_viewer)
        self.color = color = self.ColorDelegator()
        self.per.insertfilter(color)
        if use_subprocess:
            text.bind("<<view-restart>>", self.view_restart_mark)
            text.bind("<<restart-shell>>", self.restart_shell)
        #
        self.save_stdout = sys.stdout
        self.save_stderr = sys.stderr
        self.save_stdin = sys.stdin
        from idlelib import IOBinding

        self.stdout = PseudoFile(self, "stdout", IOBinding.encoding)
        self.stderr = PseudoFile(self, "stderr", IOBinding.encoding)
        self.console = PseudoFile(self, "console", IOBinding.encoding)
        if not use_subprocess:
            sys.stdout = self.stdout
            sys.stderr = self.stderr
            sys.stdin = self
        try:
            # page help() text to shell.
            import pydoc  # import must be done here to capture i/o rebinding.

            # XXX KBK 27Dec07 use a textView someday, but must work w/o subproc
            pydoc.pager = pydoc.plainpager
        except:
            sys.stderr = sys.__stderr__
            raise
        #
        self.history = self.History(self.text)
        #
        self.pollinterval = 50  # millisec
Ejemplo n.º 2
0
    def check_style(self, ev=None):
        """ Runs pep8 stylecheck, captures output and prints to new
            output window."""

        sbind = ScriptBinding(self.editwin)
        filename = sbind.getfilename()

        if filename:
            try:
                p = sub.Popen(['pep8', filename],
                              stdout=sub.PIPE, stderr=sub.PIPE)
                output, errors = p.communicate()

                if output.strip():
                    output_short = '\n'.join(
                        [line.split('/')[-1]
                         for line in output.split('\n')[:-1]])
                    # shorten pathname in each line of output
                else:
                    output_short = "Passed all checks!"

            except OSError:
                output_short = "Please install pep8."

            win = OutputWindow(self.editwin.flist)
            win.write(output_short)
Ejemplo n.º 3
0
    def __init__(self, flist=None):
        if use_subprocess:
            ms = self.menu_specs
            if ms[2][0] != "shell":
                ms.insert(2, ("shell", "She_ll"))
        self.interp = ModifiedInterpreter(self)
        if flist is None:
            root = Tk()
            fixwordbreaks(root)
            root.withdraw()
            flist = PyShellFileList(root)
        #
        OutputWindow.__init__(self, flist, None, None)
        #
##        self.config(usetabs=1, indentwidth=8, context_use_ps1=1)
        self.usetabs = True
        # indentwidth must be 8 when using tabs.  See note in EditorWindow:
        self.indentwidth = 8
        self.context_use_ps1 = True
        #
        text = self.text
        text.configure(wrap="char")
        text.bind("<<newline-and-indent>>", self.enter_callback)
        text.bind("<<plain-newline-and-indent>>", self.linefeed_callback)
        text.bind("<<interrupt-execution>>", self.cancel_callback)
        text.bind("<<end-of-file>>", self.eof_callback)
        text.bind("<<open-stack-viewer>>", self.open_stack_viewer)
        text.bind("<<toggle-debugger>>", self.toggle_debugger)
        text.bind("<<toggle-jit-stack-viewer>>", self.toggle_jit_stack_viewer)
        self.color = color = self.ColorDelegator()
        self.per.insertfilter(color)
        if use_subprocess:
            text.bind("<<view-restart>>", self.view_restart_mark)
            text.bind("<<restart-shell>>", self.restart_shell)
        #
        self.save_stdout = sys.stdout
        self.save_stderr = sys.stderr
        self.save_stdin = sys.stdin
        from idlelib import IOBinding
        self.stdout = PseudoFile(self, "stdout", IOBinding.encoding)
        self.stderr = PseudoFile(self, "stderr", IOBinding.encoding)
        self.console = PseudoFile(self, "console", IOBinding.encoding)
        if not use_subprocess:
            sys.stdout = self.stdout
            sys.stderr = self.stderr
            sys.stdin = self
        try:
            # page help() text to shell.
            import pydoc # import must be done here to capture i/o rebinding.
            # XXX KBK 27Dec07 use a textView someday, but must work w/o subproc
            pydoc.pager = pydoc.plainpager
        except:
            sys.stderr = sys.__stderr__
            raise
        #
        self.history = self.History(self.text)
        #
        self.pollinterval = 50  # millisec
Ejemplo n.º 4
0
 def write(self, s, tags=()):
     try:
         self.text.mark_gravity("iomark", "right")
         OutputWindow.write(self, s, tags, "iomark")
         self.text.mark_gravity("iomark", "left")
     except:
         pass
     if self.canceled:
         self.canceled = 0
         if not use_subprocess:
             raise KeyboardInterrupt
Ejemplo n.º 5
0
 def write(self, s, tags=()):
     try:
         self.text.mark_gravity("iomark", "right")
         OutputWindow.write(self, s, tags, "iomark")
         self.text.mark_gravity("iomark", "left")
     except:
         raise ###pass  # ### 11Aug07 KBK if we are expecting exceptions
                        # let's find out what they are and be specific.
     if self.canceled:
         self.canceled = 0
         if not use_subprocess:
             raise KeyboardInterrupt
Ejemplo n.º 6
0
    def write(self, s, tags=()):
        try:
            self.text.mark_gravity('iomark', 'right')
            OutputWindow.write(self, s, tags, 'iomark')
            self.text.mark_gravity('iomark', 'left')
        except:
            pass

        if self.canceled:
            self.canceled = 0
            if not use_subprocess:
                raise KeyboardInterrupt
Ejemplo n.º 7
0
    def write(self, s, tags = ()):
        try:
            self.text.mark_gravity('iomark', 'right')
            OutputWindow.write(self, s, tags, 'iomark')
            self.text.mark_gravity('iomark', 'left')
        except:
            pass

        if self.canceled:
            self.canceled = 0
            if not use_subprocess:
                raise KeyboardInterrupt
Ejemplo n.º 8
0
 def write(self, s, tags=()):
     try:
         self.text.mark_gravity("iomark", "right")
         OutputWindow.write(self, s, tags, "iomark")
         self.text.mark_gravity("iomark", "left")
     except:
         raise ###pass  # ### 11Aug07 KBK if we are expecting exceptions
                        # let's find out what they are and be specific.
     if self.canceled:
         self.canceled = 0
         if not use_subprocess:
             raise KeyboardInterrupt
Ejemplo n.º 9
0
    def doc_test(self, ev=None):
        """ Run doctests on the current module"""

        sbind = ScriptBinding(self.editwin)
        filename = sbind.getfilename()

        if filename:
            p = sub.Popen(['python', '-m', 'doctest', '-v', filename],
                            stdout=sub.PIPE, stderr=sub.PIPE)
            output, errors = p.communicate()

            win = OutputWindow(self.editwin.flist)
            win.write(output + '\n' + errors)  # write to output window
Ejemplo n.º 10
0
    def doc_test(self, ev=None):
        """ Run doctests on the current module"""

        sbind = ScriptBinding(self.editwin)
        filename = sbind.getfilename()

        if filename:
            p = sub.Popen(['python', '-m', 'doctest', '-v', filename],
                          stdout=sub.PIPE,
                          stderr=sub.PIPE)
            output, errors = p.communicate()

            win = OutputWindow(self.editwin.flist)
            win.write(output + '\n' + errors)  # write to output window
Ejemplo n.º 11
0
    def __init__(self, flist=None):
        if use_subprocess:
            ms = self.menu_specs
            if ms[2][0] != "shell":
                ms.insert(2, ("shell", "She_ll"))
        self.interp = ModifiedInterpreter(self)
        if flist is None:
            root = Tk()
            fixwordbreaks(root)
            root.withdraw()
            flist = PyShellFileList(root)
        #
        OutputWindow.__init__(self, flist, None, None)
        #
##        self.config(usetabs=1, indentwidth=8, context_use_ps1=1)
        self.usetabs = True
        # indentwidth must be 8 when using tabs.  See note in EditorWindow:
        self.indentwidth = 8
        self.context_use_ps1 = True
        #
        text = self.text
        text.configure(wrap="char")
        text.bind("<<newline-and-indent>>", self.enter_callback)
        text.bind("<<plain-newline-and-indent>>", self.linefeed_callback)
        text.bind("<<interrupt-execution>>", self.cancel_callback)
        text.bind("<<end-of-file>>", self.eof_callback)
        text.bind("<<open-stack-viewer>>", self.open_stack_viewer)
        text.bind("<<toggle-debugger>>", self.toggle_debugger)
        text.bind("<<toggle-jit-stack-viewer>>", self.toggle_jit_stack_viewer)
        if use_subprocess:
            text.bind("<<view-restart>>", self.view_restart_mark)
            text.bind("<<restart-shell>>", self.restart_shell)
        #
        self.save_stdout = sys.stdout
        self.save_stderr = sys.stderr
        self.save_stdin = sys.stdin
        import idlelib.IOBinding as IOBinding
        self.stdout = PseudoFile(self, "stdout", IOBinding.encoding)
        self.stderr = PseudoFile(self, "stderr", IOBinding.encoding)
        self.console = PseudoFile(self, "console", IOBinding.encoding)
        if not use_subprocess:
            sys.stdout = self.stdout
            sys.stderr = self.stderr
            sys.stdin = self
        #
        self.history = self.History(self.text)
        #
        self.pollinterval = 50  # millisec
Ejemplo n.º 12
0
 def __init__(self, flist = None):
     if use_subprocess:
         ms = self.menu_specs
         if ms[2][0] != 'shell':
             ms.insert(2, ('shell', 'She_ll'))
     self.interp = ModifiedInterpreter(self)
     if flist is None:
         root = Tk()
         fixwordbreaks(root)
         root.withdraw()
         flist = PyShellFileList(root)
     OutputWindow.__init__(self, flist, None, None)
     self.usetabs = True
     self.indentwidth = 8
     self.context_use_ps1 = True
     text = self.text
     text.configure(wrap='char')
     text.bind('<<newline-and-indent>>', self.enter_callback)
     text.bind('<<plain-newline-and-indent>>', self.linefeed_callback)
     text.bind('<<interrupt-execution>>', self.cancel_callback)
     text.bind('<<end-of-file>>', self.eof_callback)
     text.bind('<<open-stack-viewer>>', self.open_stack_viewer)
     text.bind('<<toggle-debugger>>', self.toggle_debugger)
     text.bind('<<toggle-jit-stack-viewer>>', self.toggle_jit_stack_viewer)
     if use_subprocess:
         text.bind('<<view-restart>>', self.view_restart_mark)
         text.bind('<<restart-shell>>', self.restart_shell)
     self.save_stdout = sys.stdout
     self.save_stderr = sys.stderr
     self.save_stdin = sys.stdin
     from idlelib import IOBinding
     self.stdin = PseudoInputFile(self, 'stdin', IOBinding.encoding)
     self.stdout = PseudoOutputFile(self, 'stdout', IOBinding.encoding)
     self.stderr = PseudoOutputFile(self, 'stderr', IOBinding.encoding)
     self.console = PseudoOutputFile(self, 'console', IOBinding.encoding)
     if not use_subprocess:
         sys.stdout = self.stdout
         sys.stderr = self.stderr
         sys.stdin = self.stdin
     self.history = self.History(self.text)
     self.pollinterval = 50
     return
Ejemplo n.º 13
0
 def __init__(self, flist=None):
     if use_subprocess:
         ms = self.menu_specs
         if ms[2][0] != 'shell':
             ms.insert(2, ('shell', 'She_ll'))
     self.interp = ModifiedInterpreter(self)
     if flist is None:
         root = Tk()
         fixwordbreaks(root)
         root.withdraw()
         flist = PyShellFileList(root)
     OutputWindow.__init__(self, flist, None, None)
     self.usetabs = True
     self.indentwidth = 8
     self.context_use_ps1 = True
     text = self.text
     text.configure(wrap='char')
     text.bind('<<newline-and-indent>>', self.enter_callback)
     text.bind('<<plain-newline-and-indent>>', self.linefeed_callback)
     text.bind('<<interrupt-execution>>', self.cancel_callback)
     text.bind('<<end-of-file>>', self.eof_callback)
     text.bind('<<open-stack-viewer>>', self.open_stack_viewer)
     text.bind('<<toggle-debugger>>', self.toggle_debugger)
     text.bind('<<toggle-jit-stack-viewer>>', self.toggle_jit_stack_viewer)
     if use_subprocess:
         text.bind('<<view-restart>>', self.view_restart_mark)
         text.bind('<<restart-shell>>', self.restart_shell)
     self.save_stdout = sys.stdout
     self.save_stderr = sys.stderr
     self.save_stdin = sys.stdin
     from idlelib import IOBinding
     self.stdout = PseudoFile(self, 'stdout', IOBinding.encoding)
     self.stderr = PseudoFile(self, 'stderr', IOBinding.encoding)
     self.console = PseudoFile(self, 'console', IOBinding.encoding)
     if not use_subprocess:
         sys.stdout = self.stdout
         sys.stderr = self.stderr
         sys.stdin = self
     self.history = self.History(self.text)
     self.pollinterval = 50
     return
Ejemplo n.º 14
0
 def default_command(self, event=None):
     prog = self.engine.getprog()
     if not prog:
         return
     path = self.globvar.get()
     if not path:
         self.top.bell()
         return
     from idlelib.OutputWindow import OutputWindow
     save = sys.stdout
     try:
         sys.stdout = OutputWindow(self.flist)
         self.grep_it(prog, path)
     finally:
         sys.stdout = save
Ejemplo n.º 15
0
 def close(self):
     global matchwin
     matchwin = None
     OutputWindow.close(self)
Ejemplo n.º 16
0
 def close(self):
     global matchwin
     matchwin = None
     OutputWindow.close(self)
Ejemplo n.º 17
0
 def __init__(self,flist,masterwin):
     OutputWindow.__init__(self,flist)
     self.masterwin = masterwin
Ejemplo n.º 18
0
 def __init__(self,flist,masterwin):
     OutputWindow.__init__(self,flist)
     self.masterwin = masterwin