From nabble at traction.de Mon Mar 28 16:28:17 2011 From: nabble at traction.de (phelix) Date: Mon, 28 Mar 2011 07:28:17 -0700 (PDT) Subject: [Idle-dev] IDLE Extension - Prompt goes missing Message-ID: <31258787.post@talk.nabble.com> 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. From tjreedy at udel.edu Wed Mar 30 22:28:16 2011 From: tjreedy at udel.edu (Terry Reedy) Date: Wed, 30 Mar 2011 16:28:16 -0400 Subject: [Idle-dev] IDLE Extension - Prompt goes missing In-Reply-To: <31258787.post@talk.nabble.com> References: <31258787.post@talk.nabble.com> Message-ID: On 3/28/2011 10:28 AM, phelix wrote: > 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. I do not know anything about IDLE extensions. Where are they documented or explained? -- Terry Jan Reedy From taleinat at gmail.com Thu Mar 31 08:13:47 2011 From: taleinat at gmail.com (Tal Einat) Date: Thu, 31 Mar 2011 08:13:47 +0200 Subject: [Idle-dev] IDLE Extension - Prompt goes missing In-Reply-To: References: <31258787.post@talk.nabble.com> Message-ID: On Wed, Mar 30, 2011 at 10:28 PM, Terry Reedy wrote: > On 3/28/2011 10:28 AM, phelix wrote: > > 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. >> > > I do not know anything about IDLE extensions. Where are they documented or > explained? See Lib/idlelib/extend.txt for details on extensions. -------------- next part -------------- An HTML attachment was scrubbed... URL: From taleinat at gmail.com Thu Mar 31 08:25:30 2011 From: taleinat at gmail.com (Tal Einat) Date: Thu, 31 Mar 2011 08:25:30 +0200 Subject: [Idle-dev] IDLE Extension - Prompt goes missing In-Reply-To: <31258787.post@talk.nabble.com> References: <31258787.post@talk.nabble.com> Message-ID: On Mon, Mar 28, 2011 at 4:28 PM, phelix wrote: > > Hello! > Hi, > I am trying to write an extension to add autocompletion for "self". Have you tried adding this functionality to the existing AutoComplete extension? That could save you a lot of work and would be the best way to do it. > 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. > > [snip] Well, your code is doing a lot of things for which I don't understand the reasons. The best tip I can give you is to run IDLE from the command line (on Windows, C:\Python32\python.exe C:\Python32\Lib\idlelib\idle.py). Then you can see output and exceptions printed to the command console. You could also print your own debugging info using "print" instead of using that s_print function, and it won't show up in IDLE's shell, just in the command console. Finally, if you're going for completions in the editor, check out the Rope package which supplies some awesome code-analysis tools. - Tal -------------- next part -------------- An HTML attachment was scrubbed... URL: From nabble at traction.de Thu Mar 31 10:01:06 2011 From: nabble at traction.de (phelix) Date: Thu, 31 Mar 2011 01:01:06 -0700 (PDT) Subject: [Idle-dev] IDLE Extension - Prompt goes missing In-Reply-To: References: <31258787.post@talk.nabble.com> Message-ID: <31284056.post@talk.nabble.com> >> I am trying to write an extension to add autocompletion for "self". >Have you tried adding this functionality to the existing AutoComplete >extension? That could save you a lot of work and would be the best way to do >it. I took a good look at it and also at CodeContext and learned a lot from it. But it was easier to put it into its own extension and seemed cleaner to me. Of course the completions show up in AutoComplete. What it does is that it simply points a global Reference "self" to the classname(s) it finds in the editor above the cursor. >> 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. >Well, your code is doing a lot of things for which I don't understand the >reasons. I should have been a little more verbose. In the update method there are two example lines for a call I need to do to install the class reference: #self.remote_control("get_the_calltip", "mint") # this strategy would require to alter idle-code self.remote_control("runcode", "1+1\n") With either of them I am having the problem of the disapearing prompt. Something similiar works fine from within the CodeContext extension so probably I am missing something here. I will investigate further. >The best tip I can give you is to run IDLE from the command line (on >Windows, C:\Python32\python.exe C:\Python32\Lib\idlelib\idle.py). Then you >can see output and exceptions printed to the command console. You could also >print your own debugging info using "print" instead of using that s_print >function, and it won't show up in IDLE's shell, just in the command console. I figured this out by coincidence just after I had posted this question. Though it seems very obvious to me know this is a very good hint and should by all means be included in the extend.txt file or on some website about IDLE Development. =Phelix= -- View this message in context: http://old.nabble.com/IDLE-Extension---Prompt-goes-missing-tp31258787p31284056.html Sent from the Python - idle-dev mailing list archive at Nabble.com. From nabble at traction.de Thu Mar 31 16:10:43 2011 From: nabble at traction.de (phelix) Date: Thu, 31 Mar 2011 07:10:43 -0700 (PDT) Subject: [Idle-dev] IDLE Extension - Prompt goes missing In-Reply-To: <31284056.post@talk.nabble.com> References: <31258787.post@talk.nabble.com> <31284056.post@talk.nabble.com> Message-ID: <31286762.post@talk.nabble.com> ok, finally I got it. I fell for a bug that Noam Raphael pointed out and supplied a patch for eight years ago (http://old.nabble.com/Fix-freezes!-td1182996.html). It is still present in Idle 3.2. I guess IDLE development really is slow =) - this must change! The problem was that my calls desynced the message loop, though they should not have. I will post my extension here after a little testing, though it will only work with this bug patched. =Phelix= -- View this message in context: http://old.nabble.com/IDLE-Extension---Prompt-goes-missing-tp31258787p31286762.html Sent from the Python - idle-dev mailing list archive at Nabble.com. From taleinat at gmail.com Thu Mar 31 22:54:11 2011 From: taleinat at gmail.com (Tal Einat) Date: Thu, 31 Mar 2011 22:54:11 +0200 Subject: [Idle-dev] IDLE Extension - Prompt goes missing In-Reply-To: <31284056.post@talk.nabble.com> References: <31258787.post@talk.nabble.com> <31284056.post@talk.nabble.com> Message-ID: On Thu, Mar 31, 2011 at 10:01 AM, phelix wrote: > > >> I am trying to write an extension to add autocompletion for "self". > >Have you tried adding this functionality to the existing AutoComplete > >extension? That could save you a lot of work and would be the best way to > >do it. > I took a good look at it and also at CodeContext and learned a lot from it. > But it was easier to put it into its own extension and seemed cleaner to > me. > Of course the completions show up in AutoComplete. What it does is that it > simply points a global Reference "self" to the classname(s) it finds in the > editor above the cursor. > For your own good and for the good of IDLE, I urge you to try implementing this by improving AutoComplete. Your approach (as I understand it) both requires first fixing a delicate bug regarding IDLE's event handling and messes around with the Shell's namespace. I don't think you will manage to get such a patch accepted. >The best tip I can give you is to run IDLE from the command line (on > >Windows, C:\Python32\python.exe C:\Python32\Lib\idlelib\idle.py). Then you > >can see output and exceptions printed to the command console. You could > also > >print your own debugging info using "print" instead of using that s_print > >function, and it won't show up in IDLE's shell, just in the command > console. > I figured this out by coincidence just after I had posted this question. > Though it seems very obvious to me know this is a very good hint and should > by all means be included in the extend.txt file or on some website about > IDLE Development. > Good point. If you submit a patch which updates extend.txt appropriately, I'll review it. - Tal -------------- next part -------------- An HTML attachment was scrubbed... URL: