.. note:: :class: sphx-glr-download-link-note Click :ref:`here ` to download the full example code .. rst-class:: sphx-glr-example-title .. _sphx_glr_auto_examples_customcommands.py: Anatomist commands ------------------ Using the commands interpreter in a generic way .. code-block:: default from __future__ import print_function from __future__ import absolute_import import anatomist.direct.api as anatomist from soma import aims from soma.qt_gui.qt_backend import Qt import sip import sys run_loop = Qt.QApplication.instance() is None \ and 'sphinx_gallery' not in sys.modules a = anatomist.Anatomist() cx = anatomist.cpp.CommandContext.defaultContext() # custom command i = cx.freeID() c = a.execute('CreateWindow', type='Coronal', res_pointer=i) win = c.createdWindow() # otherwise, we can retreive the new window using the context # (which will work if the exact command has no python binding) print(cx.id(win)) print(cx.object(i)) win2 = cx.object(i) print(win2 is win) vol = aims.read('irm.ima') avol = a.toAObject(vol) avol.releaseAppRef() # keywords / real objects test a.execute('AddObject', objects=[avol], windows=[win]) if run_loop: Qt.QApplication.instance().exec_ if run_loop or 'sphinx_gallery' not in sys.modules: del win, win2, avol, vol, cx, i .. rst-class:: sphx-glr-timing **Total running time of the script:** ( 0 minutes 0.000 seconds) .. _sphx_glr_download_auto_examples_customcommands.py: .. only :: html .. container:: sphx-glr-footer :class: sphx-glr-footer-example .. container:: sphx-glr-download :download:`Download Python source code: customcommands.py ` .. container:: sphx-glr-download :download:`Download Jupyter notebook: customcommands.ipynb ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_