{
  "nbformat_minor": 0, 
  "nbformat": 4, 
  "cells": [
    {
      "execution_count": null, 
      "cell_type": "code", 
      "source": [
        "%matplotlib inline"
      ], 
      "outputs": [], 
      "metadata": {
        "collapsed": false
      }
    }, 
    {
      "source": [
        "\nSyntaxError\n===========\n\nExample script with invalid Python syntax\n\n"
      ], 
      "cell_type": "markdown", 
      "metadata": {}
    }, 
    {
      "execution_count": null, 
      "cell_type": "code", 
      "source": [
        "#  This software and supporting documentation are distributed by\n#      Institut Federatif de Recherche 49\n#      CEA/NeuroSpin, Batiment 145,\n#      91191 Gif-sur-Yvette cedex\n#      France\n#\n# This software is governed by the CeCILL license version 2 under\n# French law and abiding by the rules of distribution of free software.\n# You can  use, modify and/or redistribute the software under the\n# terms of the CeCILL license version 2 as circulated by CEA, CNRS\n# and INRIA at the following URL \"http://www.cecill.info\".\n#\n# As a counterpart to the access to the source code and  rights to copy,\n# modify and redistribute granted by the license, users are provided only\n# with a limited warranty  and the software's author,  the holder of the\n# economic rights,  and the successive licensors  have only  limited\n# liability.\n#\n# In this respect, the user's attention is drawn to the risks associated\n# with loading,  using,  modifying and/or developing or reproducing the\n# software by the user in light of its specific status of free software,\n# that may mean  that it is complicated to manipulate,  and  that  also\n# therefore means  that it is reserved for developers  and  experienced\n# professionals having in-depth computer knowledge. Users are therefore\n# encouraged to load and test the software's suitability as regards their\n# requirements in conditions enabling the security of their systems and/or\n# data to be ensured and,  more generally, to use and operate it in the\n# same conditions as regards security.\n#\n# The fact that you are presently reading this means that you have had\n# knowledge of the CeCILL license version 2 and that you accept its terms.\n\n'''\nAction activation triggering API demo\n=====================================\n\nActivate actions in the current control of a window.\n\nAction activation works both in direct and socket APIs\nbut querying the lists of available action methods is only available in\ndirect mode.\n'''\nfrom __future__ import print_function\n\nimport anatomist.direct.api as anatomist\nfrom soma.qt_gui.qt_backend import Qt\nimport sys\n\nrunloop = False\nif Qt.QApplication.instance() is None:\n    runloop = True\n\na = anatomist.Anatomist()\n\nvol = a.loadObject('irm.ima')\nw = a.createWindow('Axial')\nw.addObjects(vol)\n\nw.activateAction(action_type='key_press', method='movie_start_stop')\n# set backward movie mode\nw.activateAction(action_type='key_press', method='movie_next_mode')\n# loop forward\nw.activateAction(action_type='key_press', method='movie_next_mode')\n# loop backward\nw.activateAction(action_type='key_press', method='movie_next_mode')\n# loop both ways\nw.activateAction(action_type='key_press', method='movie_next_mode')\n\n# query available actions methods\nc = w.view().controlSwitch().activeControlInstance()\nprint('in control:', c.name())\nkpmethods = c.keyPressActionLinkNames()\nprint('* keyPress methods:', kpmethods)\nmpmethods = c.mousePressActionLinkNames()\nprint('* mousePress methods:', mpmethods)\n\nw.setControl('SelectionControl')\nc = w.view().controlSwitch().activeControlInstance()\nprint('in control:', c.name())\nkpmethods = c.keyPressActionLinkNames()\nprint('* keyPress methods:', kpmethods)\nmpmethods = c.mousePressActionLinkNames()\nprint('* mousePress methods:', mpmethods)\n\nif runloop  # and 'sphinx_gallery' not in sys.modules:\n    Qt.QApplication.instance().exec_()\n# if runloop or 'sphinx_gallery' in sys.modules:\n    del c, w, vol, kpmethods, mpmethods"
      ], 
      "outputs": [], 
      "metadata": {
        "collapsed": false
      }
    }
  ], 
  "metadata": {
    "kernelspec": {
      "display_name": "Python 2", 
      "name": "python2", 
      "language": "python"
    }, 
    "language_info": {
      "mimetype": "text/x-python", 
      "nbconvert_exporter": "python", 
      "name": "python", 
      "file_extension": ".py", 
      "version": "2.7.17", 
      "pygments_lexer": "ipython2", 
      "codemirror_mode": {
        "version": 2, 
        "name": "ipython"
      }
    }
  }
}