def main(): base_path = os.path.dirname(os.path.abspath(__file__)) version_file = os.path.join(base_path, "VERSION") idlelib.PyShell.PyShell.shell_title = "Another Springnote" if os.path.exists(version_file): idlelib.PyShell.PyShell.shell_title += " (ver. {})".format(open(version_file).read().strip()) root = Tk(className="Idle") fixwordbreaks(root) root.withdraw() flist = PyShellFileList(root) idlelib.macosxSupport.setupApp(root, flist) flist.open_shell() shell = flist.pyshell if not shell: return shell.interp.runcommand( """if 1: import sys as _sys _sys.argv = %r del _sys \n""" % (sys.argv,) ) script_path = os.path.normpath(os.path.join(base_path, "run.py")) shell.interp.prepend_syspath(script_path) shell.interp.execfile(script_path) root.mainloop() root.destroy()
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
def main(runme=None): global flist, root, use_subprocess use_subprocess = True enable_shell = False enable_edit = False debug = False cmd = None script = None startup = False enable_shell = True args = [] if runme!=None: script = runme if os.path.isfile(script): pass else: print("Script not found: ", script) script = None use_subprocess = False # ehh? PyShell.shell_title = "durp" if script: sys.argv = [script] + args # start editor and/or shell windows: root = Tk(className="Idle") fixwordbreaks(root) root.withdraw() flist = PyShellFileList(root) macosxSupport.setupApp(root, flist) if enable_shell: shell = flist.open_shell() if not shell: return # couldn't open shell if macosxSupport.runningAsOSXApp() and flist.dict: # On OSX: when the user has double-clicked on a file that causes # IDLE to be launched the shell window will open just in front of # the file she wants to see. Lower the interpreter window when # there are open files. shell.top.lower() shell = flist.pyshell # handle remaining options: if script: shell.interp.runcommand("""if 1: import sys as _sys _sys.argv = %r del _sys \n""" % (sys.argv,)) shell.interp.prepend_syspath(script) shell.interp.execfile(script) root.mainloop() root.destroy()
def edle(filename): root = Tk() fixwordbreaks(root) root.withdraw() edit = EditorWindow(root=root, filename=filename) edit.set_close_hook(root.quit) edit.text.bind("<<close-all-windows>>", edit.close_event) root.mainloop() root.destroy()
def main(runme=None): global flist, root, use_subprocess use_subprocess = True enable_shell = False enable_edit = False debug = False cmd = None script = None startup = False enable_shell = True args = [] script = runme #if script: # if os.path.isfile(script): # pass # else: # print "No script file: ", script # script = None ##screw error checking, idk how to add filepath use_subprocess = False # ehh? PyShell.shell_title = "d2py" if script: sys.argv = [script]+args # start editor and/or shell windows: root = Tk(className="Idle") fixwordbreaks(root) root.withdraw() flist = PyShellFileList(root) if enable_shell: shell = flist.open_shell() if not shell: return # couldn't open shell shell = flist.pyshell if script: shell.interp.runcommand("""if 1: import sys as _sys _sys.argv = %r del _sys \n""" % (sys.argv,)) shell.interp.prepend_syspath(script) shell.interp.execfile(script) root.mainloop() root.destroy()
def _test(): from idlelib.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()
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
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
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
def main(): global flist, root, use_subprocess use_subprocess = True enable_shell = False enable_edit = False debug = False cmd = None script = None startup = False try: opts, args = getopt.getopt(sys.argv[1:], "c:deihnr:st:") except getopt.error as msg: sys.stderr.write("Error: %s\n" % str(msg)) sys.stderr.write(usage_msg) sys.exit(2) for o, a in opts: if o == '-c': cmd = a enable_shell = True if o == '-d': debug = True enable_shell = True if o == '-e': enable_edit = True if o == '-h': sys.stdout.write(usage_msg) sys.exit() if o == '-i': enable_shell = True if o == '-n': use_subprocess = False if o == '-r': script = a if os.path.isfile(script): pass else: print("No script file: ", script) sys.exit() enable_shell = True if o == '-s': startup = True enable_shell = True if o == '-t': PyShell.shell_title = a enable_shell = True if args and args[0] == '-': cmd = sys.stdin.read() enable_shell = True # process sys.argv and sys.path: for i in range(len(sys.path)): sys.path[i] = os.path.abspath(sys.path[i]) if args and args[0] == '-': sys.argv = [''] + args[1:] elif cmd: sys.argv = ['-c'] + args elif script: sys.argv = [script] + args elif args: enable_edit = True pathx = [] for filename in args: pathx.append(os.path.dirname(filename)) for dir in pathx: dir = os.path.abspath(dir) if not dir in sys.path: sys.path.insert(0, dir) else: dir = os.getcwd() if dir not 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 if macosxSupport.runningAsOSXApp() and flist.dict: # On OSX: when the user has double-clicked on a file that causes # IDLE to be launched the shell window will open just in front of # the file she wants to see. Lower the interpreter window when # there are open files. shell.top.lower() shell = flist.pyshell # handle remaining options: if debug: shell.open_debugger() if startup: filename = os.environ.get("IDLESTARTUP") or \ os.environ.get("PYTHONSTARTUP") if filename and os.path.isfile(filename): shell.interp.execfile(filename) if shell and cmd or script: shell.interp.runcommand("""if 1: import sys as _sys _sys.argv = %r del _sys \n""" % (sys.argv,)) if cmd: shell.interp.execsource(cmd) elif script: shell.interp.prepend_syspath(script) shell.interp.execfile(script) root.mainloop() root.destroy()
def main(): global root global flist global use_subprocess use_subprocess = True enable_shell = True enable_edit = False debug = False cmd = None script = None startup = False try: opts, args = getopt.getopt(sys.argv[1:], 'c:deihnr:st:') except getopt.error as msg: sys.stderr.write('Error: %s\n' % str(msg)) sys.stderr.write(usage_msg) sys.exit(2) for o, a in opts: if o == '-c': cmd = a enable_shell = True if o == '-d': debug = True enable_shell = True if o == '-e': enable_edit = True enable_shell = False if o == '-h': sys.stdout.write(usage_msg) sys.exit() if o == '-i': enable_shell = True if o == '-n': use_subprocess = False if o == '-r': script = a if os.path.isfile(script): pass else: print 'No script file: ', script sys.exit() enable_shell = True if o == '-s': startup = True enable_shell = True if o == '-t': PyShell.shell_title = a enable_shell = True if args and args[0] == '-': cmd = sys.stdin.read() enable_shell = True for i in range(len(sys.path)): sys.path[i] = os.path.abspath(sys.path[i]) if args and args[0] == '-': sys.argv = [ ''] + args[1:] elif cmd: sys.argv = [ '-c'] + args elif script: sys.argv = [ script] + args elif args: enable_edit = True pathx = [] for filename in args: pathx.append(os.path.dirname(filename)) for dir in pathx: dir = os.path.abspath(dir) if dir not in sys.path: sys.path.insert(0, dir) else: dir = os.getcwd() if dir not in sys.path: sys.path.insert(0, dir) edit_start = idleConf.GetOption('main', 'General', 'editor-on-startup', type='bool') enable_edit = enable_edit or edit_start 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 if macosxSupport.runningAsOSXApp() and flist.dict: shell.top.lower() shell = flist.pyshell if debug: shell.open_debugger() if startup: filename = os.environ.get('IDLESTARTUP') or os.environ.get('PYTHONSTARTUP') if filename and os.path.isfile(filename): shell.interp.execfile(filename) if shell and cmd or script: shell.interp.runcommand('if 1:\n import sys as _sys\n _sys.argv = %r\n del _sys\n \n' % (sys.argv,)) if cmd: shell.interp.execsource(cmd) elif script: shell.interp.prepend_syspath(script) shell.interp.execfile(script) tkversionwarning = macosxSupport.tkVersionWarning(root) if tkversionwarning: shell.interp.runcommand(''.join(("print('", tkversionwarning, "')"))) root.mainloop() root.destroy() return
pathx.append(os.path.dirname(filename)) for dir in pathx: dir = os.path.abspath(dir) if dir not 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 # 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
def getShell(thread, rootTk = None, subprocess = False, debug=False, enable_shell=False, enable_edit=True): """ This function creates and returns a shell PyShell instance required arguments: thread -- optional arguments: rootTk -- subprocess -- boolean flag when set to True a the pyshell runs a new interpreter in a sub process when set to False it the user has access to the main interpreter. (default = False) enable_shell -- boolean flag when set to True a python shell is created (by default True) enable_edit -- boolean flag when set to True a edit shell is created aware of the python syntax (by default False) debug -- boolean flag when set to True starts the debugger when the pyshell is created. (by default = False) """ cmd = None script = None startup = False # try: # sys.ps1 # except AttributeError: # sys.ps1 = '>>> ' if hasattr(sys, 'ps1') is False: sys.ps1 = '>>> ' global mainThread PyShell.use_subprocess = subprocess mainThread = thread for i in range(len(sys.path)): sys.path[i] = os.path.abspath(sys.path[i]) pathx = [] for dir in pathx: dir = os.path.abspath(dir) if not dir in sys.path: sys.path.insert(0, dir) global flist, root if rootTk is None: root = Tkinter.Tk() else: root = rootTk fixwordbreaks(root) flist = PyShell.PyShellFileList(root) if enable_edit: flist.new() if enable_shell : flist.open_shell() elif enable_shell: flist.pyshell = PyShell.PyShell() #flist.pyshell.begin() shell = flist.pyshell if debug: shell.open_debugger() return shell
sys.exit() else: pass LV_Options=LV_ActiveX_Option_Val.split(",") GUI_Module_Name=LV_Options[0].strip() GUI_Module_Path=LV_Options[1].strip() GUI_Module_App_Name=LV_Options[2].strip() GUI_Module_Info=imp.find_module(GUI_Module_Name,[GUI_Module_Path]) GUI_Module=imp.load_module(GUI_Module_Name,GUI_Module_Info[0],GUI_Module_Info[1],GUI_Module_Info[2]) GUI=GUI_Module.Device_GUI(GUI_Module_App_Name) #GUI.create_activex_server() # start editor and/or shell windows: root = Tk(className="Idle") fixwordbreaks(root) root.withdraw() flist = idlelib.PyShell.PyShellFileList(root) macosxSupport.setupApp(root, flist) if enable_edit: if not (cmd or script): for filename in args: flist.open(filename) if not args: window_handle=flist.new() unique_id=str(uuid.uuid1()) if enable_shell: shell = flist.open_shell() if not shell: return # couldn't open shell
def getShell(thread, rootTk=None, subprocess=False, debug=False, enable_shell=False, enable_edit=True): """ This function creates and returns a shell PyShell instance required arguments: thread -- optional arguments: rootTk -- subprocess -- boolean flag when set to True a the pyshell runs a new interpreter in a sub process when set to False it the user has access to the main interpreter. (default = False) enable_shell -- boolean flag when set to True a python shell is created (by default True) enable_edit -- boolean flag when set to True a edit shell is created aware of the python syntax (by default False) debug -- boolean flag when set to True starts the debugger when the pyshell is created. (by default = False) """ cmd = None script = None startup = False # try: # sys.ps1 # except AttributeError: # sys.ps1 = '>>> ' if hasattr(sys, 'ps1') is False: sys.ps1 = '>>> ' global mainThread PyShell.use_subprocess = subprocess mainThread = thread for i in range(len(sys.path)): sys.path[i] = os.path.abspath(sys.path[i]) pathx = [] for dir in pathx: dir = os.path.abspath(dir) if not dir in sys.path: sys.path.insert(0, dir) global flist, root if rootTk is None: root = Tkinter.Tk() else: root = rootTk fixwordbreaks(root) flist = PyShell.PyShellFileList(root) if enable_edit: flist.new() if enable_shell: flist.open_shell() elif enable_shell: flist.pyshell = PyShell.PyShell() #flist.pyshell.begin() shell = flist.pyshell if debug: shell.open_debugger() return shell
def main(): global use_subprocess global root global flist capture_warnings(True) use_subprocess = True enable_shell = False enable_edit = False debug = False cmd = None script = None startup = False try: opts, args = getopt.getopt(sys.argv[1:], 'c:deihnr:st:') except getopt.error as msg: sys.stderr.write('Error: %s\n' % str(msg)) sys.stderr.write(usage_msg) sys.exit(2) for o, a in opts: if o == '-c': cmd = a enable_shell = True if o == '-d': debug = True enable_shell = True if o == '-e': enable_edit = True if o == '-h': sys.stdout.write(usage_msg) sys.exit() if o == '-i': enable_shell = True if o == '-n': use_subprocess = False if o == '-r': script = a if os.path.isfile(script): pass else: print 'No script file: ', script sys.exit() enable_shell = True if o == '-s': startup = True enable_shell = True if o == '-t': PyShell.shell_title = a enable_shell = True if args and args[0] == '-': cmd = sys.stdin.read() enable_shell = True for i in range(len(sys.path)): sys.path[i] = os.path.abspath(sys.path[i]) if args and args[0] == '-': sys.argv = [''] + args[1:] elif cmd: sys.argv = ['-c'] + args elif script: sys.argv = [script] + args elif args: enable_edit = True pathx = [] for filename in args: pathx.append(os.path.dirname(filename)) for dir in pathx: dir = os.path.abspath(dir) if dir not in sys.path: sys.path.insert(0, dir) else: dir = os.getcwd() if dir not in sys.path: sys.path.insert(0, dir) edit_start = idleConf.GetOption('main', 'General', 'editor-on-startup', type='bool') enable_edit = enable_edit or edit_start enable_shell = enable_shell or not enable_edit root = Tk(className='Idle') icondir = os.path.join(os.path.dirname(__file__), 'Icons') if system() == 'Windows': iconfile = os.path.join(icondir, 'idle.ico') root.wm_iconbitmap(default=iconfile) elif TkVersion >= 8.5: ext = '.png' if TkVersion >= 8.6 else '.gif' iconfiles = [ os.path.join(icondir, 'idle_%d%s' % (size, ext)) for size in (16, 32, 48) ] icons = [ PhotoImage(file=iconfile) for iconfile in iconfiles ] root.tk.call('wm', 'iconphoto', str(root), '-default', *icons) fixwordbreaks(root) root.withdraw() flist = PyShellFileList(root) macosxSupport.setupApp(root, flist) if enable_edit: if not (cmd or script): for filename in args[:]: if flist.open(filename) is None: args.remove(filename) if not args: flist.new() if enable_shell: shell = flist.open_shell() if not shell: return if macosxSupport.isAquaTk() and flist.dict: shell.top.lower() else: shell = flist.pyshell if debug: shell.open_debugger() if startup: filename = os.environ.get('IDLESTARTUP') or os.environ.get('PYTHONSTARTUP') if filename and os.path.isfile(filename): shell.interp.execfile(filename) if cmd or script: shell.interp.runcommand('if 1:\n import sys as _sys\n _sys.argv = %r\n del _sys\n \n' % (sys.argv,)) if cmd: shell.interp.execsource(cmd) elif script: shell.interp.prepend_syspath(script) shell.interp.execfile(script) elif shell: tkversionwarning = macosxSupport.tkVersionWarning(root) if tkversionwarning: shell.interp.runcommand("print('%s')" % tkversionwarning) while flist.inversedict: root.mainloop() root.destroy() capture_warnings(False) return