[chimera-dev] accelerators and stereo

Thomas Goddard goddard at cgl.ucsf.edu
Tue Apr 19 12:11:35 PDT 2005


Hi Matthew,

  Here is a modification of the ChimeraExtension.py code I sent
earlier that will make the F1 function key switch between stereo and
mono viewing.  It directly grabs the F1 key presses from the main
Chimera window since our current accelerator mechanism is ignoring the
function keys.  This code still provides the menu entry
Tools->Utilities->Stereo/Mono and allows you to add a toolbar button
as I described previously.

  To use this code make a directory in your Chimera distribution
chimera/share/Stereo (directory name does not matter) and put the code
below in a file ChimeraExtension.py (name does matter).  This will add
the F1 function key binding and the Tools->Utilities->Stereo/Mono menu
entry to toggle modes.

      Tom

----
ChimeraExtension.py code follows:

# -----------------------------------------------------------------------------
#
import chimera.extension

# -----------------------------------------------------------------------------
#
class Stereo_Mono_EMO(chimera.extension.EMO):

  def name(self):
    return 'Stereo / Mono'
  def description(self):
    return 'Toggle between stereo and mono modes'
  def categories(self):
    return ['Utilities']
  def icon(self):
    return None
  def activate(self):
    import chimera
    c = chimera.viewer.camera
    if c.mode() == 'stereo':
      c.setMode('mono')
    else:
      if not c.setMode('stereo'):
        from chimera import replyobj
	replyobj.status('Start chimera with the --stereo command-line switch to enable stereo')
    #
    # Chimera camera modes:
    #   'VRex row stereo', 'cross-eye stereo', 'mono', 'stereo',
    #   'stereo left eye', 'stereo right eye', 'wall-eye stereo'
    #

# -----------------------------------------------------------------------------
#
emo = Stereo_Mono_EMO(__file__)
chimera.extension.manager.registerExtension(emo)

from chimera.tkgui import app
app.bind('<KeyPress-F1>', lambda event, emo=emo: emo.activate())
app.graphics.bind('<KeyPress-F1>', lambda event, emo=emo: emo.activate())


More information about the Chimera-dev mailing list