Esempio n. 1
0
    def __init__(self, flist=None):
        self.interp = ModifiedInterpreter(self)
        if flist is None:
            root = Tk()
            fixwordbreaks(root)
            root.withdraw()
            flist = PyShellFileList(root)

        OutputWindow.__init__(self, flist, None, None)

        import __builtin__
        __builtin__.quit = __builtin__.exit = "To exit, type Ctrl-D."

        self.auto = self.extensions["AutoIndent"] # Required extension
        self.auto.config(prefertabs=1)

        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("<<beginning-of-line>>", self.home_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("<<open-python-shell>>", self.flist.open_shell)
        text.bind("<<toggle-jit-stack-viewer>>", self.toggle_jit_stack_viewer)

        sys.stdout = PseudoFile(self, "stdout")
        sys.stderr = PseudoFile(self, "stderr")
        sys.stdin = self
        self.console = PseudoFile(self, "console")

        self.history = self.History(self.text)
Esempio n. 2
0
    def __init__(self, noshell=1):

        global flist, root
        root = Tk(className="Idle")
        fixwordbreaks(root)
        root.withdraw()
        flist = PyShellFileList(root)

        # the following causes lockups and silent failures when debugging
        # changes to EditorWindow.__init__  ; the console works fine for idle
        # debugging in any case, so disable this unnescesary stuff.
        #dbg=OnDemandOutputWindow(flist)
        #dbg.set_title('IDLE Debugging Messages')
        #sys.stdout = PseudoFile(dbg,['stdout'])
        #sys.stderr = PseudoFile(dbg,['stderr'])

        try:
            self.server = protocol.Server(connection_hook=self.address_ok)
            protocol.publish('IDLE', self.connect)
            self.main(sys.argv[1:], noshell)
            return
        except protocol.connectionLost:
            try:
                client = protocol.Client()
                IDLE = client.getobject('IDLE')
                if IDLE:
                    try:
                        IDLE.remote(sys.argv[1:])
                    except usageError, msg:
                        sys.stderr.write("Error: %s\n" % str(msg))
                        sys.stderr.write(usage_msg)
                    return
            except protocol.connectionLost:
                pass

        #maybe the following should be handled by a tkmessagebox for
        #users who don't start idle from a console??
        print """\
IDLE cannot run.

IDLE needs to use a specific TCP/IP port (7454) in order to execute and
debug programs. IDLE is unable to bind to this port, and so cannot
start. Here are some possible causes of this problem:

  1. TCP/IP networking is not installed or not working on this computer
  2. Another program is running that uses this port
  3. Another copy of IDLE stopped responding but is still bound to the port
  4. Personal firewall software is preventing IDLE from using this port

IDLE makes and accepts connections only with this computer, and does not
communicate over the internet in any way. It's use of port 7454 should not 
be a security risk on a single-user machine.
"""
        dbg.owin.gotoline(1)
        dbg.owin.remove_selection()
        root.mainloop()  # wait for user to read message
Esempio n. 3
0
 def __init__(self, flist=None):
     if use_subprocess:
         ms = self.menu_specs
         if ms[2][0] != "shell":
             ms.insert(2, ("shell", "_Shell"))
     self.interp = ModifiedInterpreter(self)
     if flist is None:
         root = Tk()
         fixwordbreaks(root)
         root.withdraw()
         flist = PyShellFileList(root)
     #
     OutputWindow.__init__(self, flist, None, None)
     #
     import __builtin__
     __builtin__.quit = __builtin__.exit = "To exit, type Ctrl-D."
     #
     self.config(usetabs=1, indentwidth=8, context_use_ps1=1)
     #
     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("<<beginning-of-line>>", self.home_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("<<open-python-shell>>", self.flist.open_shell)
     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 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
     if use_subprocess:
         self.interp.start_subprocess()
Esempio n. 4
0
 def __init__(self, flist=None):
     if use_subprocess:
         ms = self.menu_specs
         if ms[2][0] != "shell":
             ms.insert(2, ("shell", "_Shell"))
     self.interp = ModifiedInterpreter(self)
     if flist is None:
         root = Tk()
         fixwordbreaks(root)
         root.withdraw()
         flist = PyShellFileList(root)
     #
     OutputWindow.__init__(self, flist, None, None)
     #
     import __builtin__
     __builtin__.quit = __builtin__.exit = "To exit, type Ctrl-D."
     #
     self.config(usetabs=1, indentwidth=8, context_use_ps1=1)
     #
     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("<<beginning-of-line>>", self.home_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("<<open-python-shell>>", self.flist.open_shell)
     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 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
     if use_subprocess:
         self.interp.start_subprocess()
Esempio n. 5
0
def _test():
    from EditorWindow import fixwordbreaks
    import sys
    root = Tk()
    fixwordbreaks(root)
    root.withdraw()
    flist = FileList(root)
    if sys.argv[1:]:
        for filename in sys.argv[1:]:
            flist.open(filename)
    else:
        flist.new()
    if flist.inversedict:
        root.mainloop()
Esempio n. 6
0
         if not dir in sys.path:
             sys.path.insert(0, dir)
 else:
     dir = os.getcwd()
     if not dir in sys.path:
         sys.path.insert(0, dir)
 # check the IDLE settings configuration (but command line overrides)
 edit_start = idleConf.GetOption('main',
                                 'General',
                                 'editor-on-startup',
                                 type='bool')
 enable_edit = enable_edit or edit_start
 enable_shell = enable_shell or not edit_start
 # start editor and/or shell windows:
 root = Tk(className="Idle")
 fixwordbreaks(root)
 root.withdraw()
 flist = PyShellFileList(root)
 if enable_edit:
     if not (cmd or script):
         for filename in args:
             flist.open(filename)
         if not args:
             flist.new()
 if enable_shell:
     if not flist.open_shell():
         return  # couldn't open shell
 shell = flist.pyshell
 # handle remaining options:
 if debug:
     shell.open_debugger()
Esempio n. 7
0
            dir = os.path.abspath(dir)
            if not dir in sys.path:
                sys.path.insert(0, dir)
    else:
        dir = os.getcwd()
        if not dir in sys.path:
            sys.path.insert(0, dir)
    # check the IDLE settings configuration (but command line overrides)
    edit_start = idleConf.GetOption('main', 'General',
                                    'editor-on-startup', type='bool')
    enable_edit = enable_edit or edit_start
    enable_shell = enable_shell or not edit_start
    # start editor and/or shell windows:
    root = Tk(className="Idle")

    fixwordbreaks(root)
    root.withdraw()
    flist = PyShellFileList(root)
    macosxSupport.setupApp(root, flist)

    if enable_edit:
        if not (cmd or script):
            for filename in args:
                flist.open(filename)
            if not args:
                flist.new()
    if enable_shell:
        shell = flist.open_shell()
        if not shell:
            return # couldn't open shell
Esempio n. 8
0
import os
Esempio n. 9
0
#! /usr/bin/env python
Esempio n. 10
0
import os