[wingide-users] How to attach python script to hotkey?

Wing IDE Support support at wingware.com
Tue Jun 22 18:15:44 MDT 2010


On 6/22/10 5:45 PM, Jordan O wrote:
> Hi everybody,
>
> I'm trying to do something as simple as hook up a hotkey to a python
> script on disk. Using Edit > Preferences > Keyboard > Custom Key Bindings.
> Insert: key Ctrl-Y, with command ( print 'ak' ). Then when testing it-
> nothing happens! Is it printing 'ak' to some window I don't know about?
>
> I have a python script in Wing IDE's script's folder- but can't fingure
> out how to bind that to a hotkey if printing 'ak' doesn't work.

What I think you want to do is to define a command in a Wing IDE script 
file, which is then put in the scripts folder.  One way to do this is to 
define a function such as:

def mycommand():
     print 'hello'

Note that print'ed output from a script will appear in the Messages 
tool, which is useful for logging but most scripts work with the objects 
defined in the scripting api.

Then you can bind the command you created ('mycommand') to a key via the 
custom key bindings in preferences.

Please see http://wingware.com/doc/scripting for more information on 
scripting.

Thanks,

John


More information about the wingide-users mailing list