Hi folks:
I know a trivial amount of python, but have trouble figuring out coot
commands in python. I am scheme/guile-illiterate, but there are more
examples in coot. I've managed to get next to nowhere in each. I've
been using the key-binding example scheme in coot, and I can bind
keys (eg, the arrow keys), but I can't seem to figure out how to
dynamically reassign them like I do in the pymol example pasted below.
I'm trying to write a script, in either python or guile, that will
enable me to use my powermate dial to do x, y, and z directions. In
pymol, I am able to do this as follows:
I assign function keys to rotations, and the up and down arrow keys
allow me to toggle between three functions that dynamically assign
the left and right arrows to +/- x, +/- y, or +/- z. I'd like to do
something similar in coot, but it is driving me nuts.
Here is how I do it in pymol:
from pymol import cmd
# Define aliases for mapping in [x,y,z] rotations and translations
into a single Powermate
# dial. Toggling between the three is possible if you then assign
these to special keys.
# Functions for x,y,z rotations and translations using Powermate dial
# Program F1 and F2 for Rotate Right and Rotate Left
# Program F3 and F4 for Click & Rotate Right and Click & Rotate Left
# Program F5 for Click (to toggle between dialsets)
# dialset = 2
def dialx(): \
global dialset \
dialset = 1 \
cmd.set_key ('F1', cmd.turn,('x',-2.0)) \
cmd.set_key ('F2', cmd.turn,('x',2.0)) \
cmd.set_key ('F3', cmd.move,('x',-0.5)) \
cmd.set_key ('F4', cmd.move,('x',0.5)) \
print "dialset ", dialset, " [ X ]\n" \
return dialset
def dialy(): \
global dialset \
dialset = 2 \
cmd.set_key ('F1', cmd.turn,('y',-2.0)) \
cmd.set_key ('F2', cmd.turn,('y',2.0)) \
cmd.set_key ('F3', cmd.move,('y',-0.5)) \
cmd.set_key ('F4', cmd.move,('y',0.5)) \
print "dialset ", dialset, " [ Y ]\n" \
return dialset
def dialz(): \
global dialset \
dialset = 3 \
cmd.set_key ('F1', cmd.turn,('z',-2.0)) \
cmd.set_key ('F2', cmd.turn,('z',2.0)) \
cmd.set_key ('F3', cmd.move,('z',-0.5)) \
cmd.set_key ('F4', cmd.move,('z',0.5)) \
print "dialset ", dialset, " [ Z ]\n" \
return dialset
def toggle_dial(): \
if dialset == 1 : \
print "Changing to y" \
dialy() \
elif dialset == 2 : \
print "Changing to z" \
dialz() \
elif dialset == 3 : \
print "Changing to x" \
dialx() \
else: print "Dial assignment isn't working"
cmd.set_key ('F5', toggle_dial)
# Start default dial state for rotate y (arbitrary choice)
dialy()
William G. Scott
contact info: http://chemistry.ucsc.edu/~wgscott
|