def _test(): # TODO check and convert to htest from tkinter import Tk from idlelib.editor import fixwordbreaks from idlelib.run import fix_scaling root = Tk() fix_scaling(root) fixwordbreaks(root) root.withdraw() flist = FileList(root) flist.new() if flist.inversedict: root.mainloop()
def _test(): # TODO check and convert to htest from tkinter import Tk from idlelib.editor import fixwordbreaks from idlelib.run import fix_scaling root = Tk() fix_scaling(root) fixwordbreaks(root) root.withdraw() flist = FileList(root) flist.new() if flist.inversedict: root.mainloop()
def _test(): from idlelib.editor 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 _test(): from idlelib.editor 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 setUpClass(cls): requires('gui') cls.root = root = tk.Tk() root.withdraw() fix_scaling(root) fixwordbreaks(root) fix_x11_paste(root) cls.flist = flist = PyShellFileList(root) # See #43981 about macosx.setupApp(root, flist) causing failure. root.update_idletasks() cls.init_shell()
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 iomenu self.stdin = PseudoInputFile(self, 'stdin', iomenu.encoding) self.stdout = PseudoOutputFile(self, 'stdout', iomenu.encoding) self.stderr = PseudoOutputFile(self, 'stderr', iomenu.encoding) self.console = PseudoOutputFile(self, 'console', iomenu.encoding) if not use_subprocess: sys.stdout = self.stdout sys.stderr = self.stderr sys.stdin = self.stdin try: import pydoc pydoc.pager = pydoc.plainpager except: sys.stderr = sys.__stderr__ raise self.history = self.History(self.text) self.pollinterval = 50
def main(): import getopt from platform import system from idlelib import testing from idlelib import macosx global flist, root, use_subprocess 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: print('Error: %s\n%s' % (msg, usage_msg), file=sys.stderr) 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': print(' Warning: running IDLE without a subprocess is deprecated.', file=sys.stderr) 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 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) 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 if use_subprocess and not testing: NoDefaultRoot() root = Tk(className='Idle') root.withdraw() icondir = os.path.join(os.path.dirname(__file__), 'Icons') if system() == 'Windows': iconfile = os.path.join(icondir, 'idle.ico') root.wm_iconbitmap(default=iconfile) else: 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(master=root, file=iconfile) for iconfile in iconfiles ] root.wm_iconphoto(True, *icons) fixwordbreaks(root) fix_x11_paste(root) flist = PyShellFileList(root) macosx.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 macosx.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: import sys as _sys _sys.argv = %r del _sys """ % (sys.argv, )) if cmd: shell.interp.execsource(cmd) elif script: shell.interp.prepend_syspath(script) shell.interp.execfile(script) elif shell: tkversionwarning = macosx.tkVersionWarning(root) if tkversionwarning: shell.interp.runcommand("print('%s')" % tkversionwarning) while flist.inversedict: root.mainloop() root.destroy() capture_warnings(False)