diff options
Diffstat (limited to 'doc/source/modules/gui/plot/getting_started.rst')
-rw-r--r-- | doc/source/modules/gui/plot/getting_started.rst | 32 |
1 files changed, 21 insertions, 11 deletions
diff --git a/doc/source/modules/gui/plot/getting_started.rst b/doc/source/modules/gui/plot/getting_started.rst index bfea8f2..412cc11 100644 --- a/doc/source/modules/gui/plot/getting_started.rst +++ b/doc/source/modules/gui/plot/getting_started.rst @@ -20,7 +20,9 @@ For a complete description of the API, see :mod:`silx.gui.plot`. Use :mod:`silx.gui.plot` from (I)Python console ----------------------------------------------- -The simplest way is to import the :mod:`silx.sx` module: +We recommend to use (I)Python 3.x and PyQt5. + +From a Python or IPython interpreter, the simplest way is to import the :mod:`silx.sx` module: >>> from silx import sx @@ -28,19 +30,27 @@ The :mod:`silx.sx` module initialises Qt and provides access to :mod:`silx.gui.p .. note:: The :mod:`silx.sx` module does NOT initialise Qt and does NOT expose silx widget in a notebook. +An alternative to run :mod:`silx.gui` widgets from `IPython <http://ipython.org/>`_, +is to set IPython to use Qt(5), e.g., with the `--gui` option:: + + ipython --gui=qt5 + + Compatibility with IPython ++++++++++++++++++++++++++ -To run :mod:`silx.gui` widgets from `IPython <http://ipython.org/>`_, -IPython must be set to use Qt (and in case of using PyQt4 and Python 2.7, -PyQt must be set to use API version 2, see note below for explanation). - -As *silx* is configuring the Qt binding and `matplotlib <http://matplotlib.org/>`_, the safest way to use *silx* from IPython is to import :mod:`silx.gui.plot` first and then run either `%gui <http://ipython.org/ipython-doc/stable/interactive/magics.html#magic-gui>`_ qt or `%pylab <http://ipython.org/ipython-doc/stable/interactive/magics.html#magic-pylab>`_ qt:: +silx widgets require Qt to be initialized. +If Qt is not yet loaded, silx tries to load PyQt5 first before trying other supported bindings. - In [1]: from silx.gui.plot import * - In [2]: %pylab qt +With versions of IPython lower than 3.0 (e.g., on Debian 8), there is an incompatibility between +the way silx loads Qt and the way IPython is doing it through the ``--gui`` option, +`%gui <http://ipython.org/ipython-doc/stable/interactive/magics.html#magic-gui>`_ or +`%pylab <http://ipython.org/ipython-doc/stable/interactive/magics.html#magic-pylab>`_ magics. +In this case, IPython magics that initialize Qt might not work after importing modules from silx.gui. -Alternatively, when using Python 2.7 and PyQt4, you can start IPython with the ``QT_API`` environment variable set to ``pyqt``. +When using Python2.7 and PyQt4, there is another incompatibility to deal with as +silx requires PyQt4 API version 2 (See note below for explanation). +In this case, start IPython with the ``QT_API`` environment variable set to ``pyqt``. On Linux and MacOS X, run from the command line:: @@ -289,7 +299,7 @@ A ``colormap`` is described with a :class:`.Colormap` class as follows: .. code-block:: python - from silx.gui.plot.Colormap import Colormap + from silx.gui.colors import Colormap colormap = Colormap(name='gray', # Name of the colormap normalization='linear', # Either 'linear' or 'log' @@ -317,7 +327,7 @@ It is possible to change the default colormap of the plot widget by :meth:`.Plot .. code-block:: python - from silx.gui.plot.Colormap import Colormap + from silx.gui.colors import Colormap colormap = Colormap(name='viridis', normalization='linear', |