[Idle-dev] IDLE Extension - Prompt goes missing

phelix nabble at traction.de
Mon Mar 28 16:28:17 CEST 2011


Hello!

I am trying to write an extension to add autocompletion for "self". It works
fine but there is one problem I just can't figure out. Whenever I hit enter
at the shell a couple of times the interpreter seems to be crashing. The
extension still runs fine but the prompt is not comming back. I tried it in
both python 2.62 and 3.2. Here is some example code, any suggestion welcome.

# # to config-extensions.def
# [TestExtension]
# enable=1
# enable_shell=0
# [TestExtension_bindings]
# toggle-test-extension=

debug = 1

if debug:
    import PyShell

UPDATEINTERVAL = 300

class TestExtension():
    def __init__(self, editwin):
        self.s_print("init0\n")
        self.editwin = editwin
        if editwin is None:  # subprocess and test
            return
        self.text = editwin.text

        self.text.after(UPDATEINTERVAL, self.timer_event)
        
        self.s_print("init1")

    def update(self):
        self.s_print("update1")

        #self.remote_control("get_the_calltip", "mint")
        self.remote_control("runcode", "1+1\n")
        
        self.s_print("update2\n")

    def remote_control(self, funcString, *args):
        try:
            rpcclt = self.editwin.flist.pyshell.interp.rpcclt
        except:
            rpcclt = None
        if not rpcclt:
            return(None)
        r = rpcclt.remotecall("exec", funcString,  args , {})
        return(r) 

    def s_print(self, stringy):
        "print to shell to debug"
        if debug:
            try:
                PyShell.flist.pyshell.write(stringy)        
            except:
                pass  

    def timer_event(self):
        self.update()
        self.text.after(UPDATEINTERVAL, self.timer_event)



-- 
View this message in context: http://old.nabble.com/IDLE-Extension---Prompt-goes-missing-tp31258787p31258787.html
Sent from the Python - idle-dev mailing list archive at Nabble.com.



More information about the IDLE-dev mailing list