.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples/activateaction.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code .. rst-class:: sphx-glr-example-title .. _sphx_glr_auto_examples_activateaction.py: Action activation triggering API demo ===================================== Activate actions in the current control of a window. Action activation works both in direct and socket APIs but querying the lists of available action methods is only available in direct mode. .. GENERATED FROM PYTHON SOURCE LINES 43-88 .. code-block:: default import anatomist.direct.api as anatomist from soma.qt_gui.qt_backend import Qt import sys runloop = False if Qt.QApplication.instance() is None: runloop = True a = anatomist.Anatomist() vol = a.loadObject('irm.ima') w = a.createWindow('Axial') w.addObjects(vol) w.activateAction(action_type='key_press', method='movie_start_stop') # set backward movie mode w.activateAction(action_type='key_press', method='movie_next_mode') # loop forward w.activateAction(action_type='key_press', method='movie_next_mode') # loop backward w.activateAction(action_type='key_press', method='movie_next_mode') # loop both ways w.activateAction(action_type='key_press', method='movie_next_mode') # query available actions methods c = w.view().controlSwitch().activeControlInstance() print('in control:', c.name()) kpmethods = c.keyPressActionLinkNames() print('* keyPress methods:', kpmethods) mpmethods = c.mousePressActionLinkNames() print('* mousePress methods:', mpmethods) w.setControl('SelectionControl') c = w.view().controlSwitch().activeControlInstance() print('in control:', c.name()) kpmethods = c.keyPressActionLinkNames() print('* keyPress methods:', kpmethods) mpmethods = c.mousePressActionLinkNames() print('* mousePress methods:', mpmethods) if runloop: # and 'sphinx_gallery' not in sys.modules: Qt.QApplication.instance().exec_() if runloop or 'sphinx_gallery' in sys.modules: del c, w, vol, kpmethods, mpmethods .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.000 seconds) .. _sphx_glr_download_auto_examples_activateaction.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: activateaction.py ` .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: activateaction.ipynb ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_