[Idle-dev] Extension to handle Cancel

Douglas S. Blank dblank at brynmawr.edu
Thu Aug 16 22:31:26 CEST 2007

I'm working on a plugin extension for IDLE that can run a test when 
Control+C is pressed. Unfortunately, Control+C (or <Cancel> in Tkinter 
bindings) is not handled as other key bindings are. Instead there is a 
cancel_callback in the pyshell instance that is called.

So, I've tried to replace the cancel_callback method from inside the 
extension (I have a working version from an external main---but it is 
really hacky). However, it looks like editwin.flist.pyshell doesn't 
exist yet when the constructor of the extension is called.

Is there any way for my extension module to have some code that gets 
called after the pyshell has been created?


Sample code:

class ExtensionTest:
    def __init__(self, editwin):
       # works for other windows, after the shell is made, but:
       print editwin.flist.pyshell.cancel_callback, "does not exist yet"
       # when constructed for the shell

More information about the IDLE-dev mailing list