Set Key: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
No edit summary |
||
Line 1: | Line 1: | ||
===DESCRIPTION=== | ===DESCRIPTION=== | ||
'''set_key''' binds a specific python function to a key press. | |||
===PYMOL API (ONLY)=== | ===PYMOL API (ONLY)=== | ||
<source lang="python"> | |||
cmd.set_key( string key, function fn, tuple arg=(), dict kw={}) | |||
</source> | |||
===PYTHON EXAMPLE=== | ===PYTHON EXAMPLE=== | ||
<source lang="python"> | |||
from pymol import cmd | |||
def color_blue(object): cmd.color("blue",object) | |||
cmd.set_key( 'F1' , make_it_blue, ( "object1" ) ) | |||
// would turn object1 blue when the F1 key is pressed and | |||
cmd.set_key( 'F2' , make_it_blue, ( "object2" ) ) | |||
// would turn object2 blue when the F2 key is pressed. | |||
cmd.set_key( 'CTRL-C' , cmd.zoom ) | |||
cmd.set_key( 'ALT-A' , cmd.turn, ('x',90) ) | |||
</source> | |||
===KEYS WHICH CAN BE REDEFINED=== | ===KEYS WHICH CAN BE REDEFINED=== | ||
F1 to F12 | |||
left, right, pgup, pgdn, home, insert | |||
CTRL-A to CTRL-Z | |||
ALT-0 to ALT-9, ALT-A to ALT-Z | |||
===SEE ALSO=== | ===SEE ALSO=== | ||
[[Cmd button]] | |||
[[Category:Commands|set_key]] | [[Category:Commands|set_key]] |
Revision as of 13:31, 29 January 2006
DESCRIPTION
set_key binds a specific python function to a key press.
PYMOL API (ONLY)
cmd.set_key( string key, function fn, tuple arg=(), dict kw={})
PYTHON EXAMPLE
from pymol import cmd
def color_blue(object): cmd.color("blue",object)
cmd.set_key( 'F1' , make_it_blue, ( "object1" ) )
// would turn object1 blue when the F1 key is pressed and
cmd.set_key( 'F2' , make_it_blue, ( "object2" ) )
// would turn object2 blue when the F2 key is pressed.
cmd.set_key( 'CTRL-C' , cmd.zoom )
cmd.set_key( 'ALT-A' , cmd.turn, ('x',90) )
KEYS WHICH CAN BE REDEFINED
F1 to F12 left, right, pgup, pgdn, home, insert CTRL-A to CTRL-Z ALT-0 to ALT-9, ALT-A to ALT-Z