Esempio n. 1
0
    def _showEditor(self, fname, onlyIfExists=False):

        # Bail if requesting an already existing editor, but editor not there.
        if onlyIfExists and not self._idleEditor:
            return

        # If editor already exists, just update the file.
        if self._idleEditor:
            self._idleEditor.top.deiconify()
            self._idleEditor.top.tkraise()
            self._idleEditor.io.loadfile(fname)
            return

        from idlelib import PyShell
        flist = PyShell.PyShellFileList(self._master)
        sys.ps1 = 'CDAT> '
        from idlelib import EditorWindow
        self._idleEditor = EditorWindow.EditorWindow(root=self._master,
                                                     filename=fname,
                                                     flist=flist)
        self._idleEditor.top.protocol("WM_DELETE_WINDOW", self._closeEditor)

        # Delete the menubar options from the editor.
        self._idleEditor.menubar.delete('File')
        self._idleEditor.menubar.delete('Edit')
        self._idleEditor.menubar.delete('Format')
        self._idleEditor.menubar.delete('Run')
        self._idleEditor.menubar.delete('Options')
        self._idleEditor.menubar.delete('Windows')
        self._idleEditor.menubar.delete('Help')
Esempio n. 2
0
def _class_browser(parent): #Wrapper for htest
    try:
        file = __file__
    except NameError:
        file = sys.argv[0]
        if sys.argv[1:]:
            file = sys.argv[1]
        else:
            file = sys.argv[0]
    dir, file = os.path.split(file)
    name = os.path.splitext(file)[0]
    flist = PyShell.PyShellFileList(parent)
    ClassBrowser(flist, name, [dir], _htest=True)
    parent.mainloop()
Esempio n. 3
0
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