示例#1
0
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()
示例#2
0
def _grep_dialog(parent):  # htest #
    from idlelib.PyShell import PyShellFileList
    root = Tk()
    root.title("Test GrepDialog")
    width, height, x, y = list(map(int, re.split('[x+]', parent.geometry())))
    root.geometry("+%d+%d" % (x, y + 150))

    flist = PyShellFileList(root)
    text = Text(root, height=5)
    text.pack()

    def show_grep_dialog():
        text.tag_add(SEL, "1.0", END)
        grep(text, flist=flist)
        text.tag_remove(SEL, "1.0", END)

    button = Button(root, text="Show GrepDialog", command=show_grep_dialog)
    button.pack()
    root.mainloop()
示例#3
0
def _stack_viewer(parent):
    root = tk.Tk()
    root.title("Test StackViewer")
    width, height, x, y = list(map(int, re.split('[x+]', parent.geometry())))
    root.geometry("+%d+%d" % (x, y + 150))
    flist = PyShellFileList(root)
    try:  # to obtain a traceback object
        a
    except:
        exc_type, exc_value, exc_tb = sys.exc_info()

    # inject stack trace to sys
    sys.last_type = exc_type
    sys.last_value = exc_value
    sys.last_traceback = exc_tb

    StackBrowser(root, flist=flist, top=root, tb=exc_tb)

    # restore sys to original state
    del sys.last_type
    del sys.last_value
    del sys.last_traceback
示例#4
0
def _path_browser(parent):
    flist = PyShellFileList(parent)
    PathBrowser(flist, _htest=True)
    parent.mainloop()