.. DO NOT EDIT.
.. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY.
.. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE:
.. "_gallery/qt/imagewidget.py"
.. LINE NUMBERS ARE GIVEN BELOW.

.. only:: html

    .. note::
        :class: sphx-glr-download-link-note

        :ref:`Go to the end <sphx_glr_download__gallery_qt_imagewidget.py>`
        to download the full example code.

.. rst-class:: sphx-glr-example-title

.. _sphx_glr__gallery_qt_imagewidget.py:


ImageWidget as QtWidget
=======================

This example opens multiple windows to show multiple ImageWidgets.

.. GENERATED FROM PYTHON SOURCE LINES 7-42

.. code-block:: Python


    # test_example = false

    import numpy as np
    from PyQt6 import QtWidgets
    import fastplotlib as fpl
    import imageio.v3 as iio


    images = np.random.rand(100, 512, 512)

    # fastplotlib and wgpu will auto-detect if Qt is imported and then use the Qt canvas
    iw = fpl.ImageWidget(images)
    widget = iw.show()
    widget.resize(800, 800)

    # another image widget with multiple images
    images_list = [np.random.rand(100, 512, 512) for i in range(4)]

    iw_mult = fpl.ImageWidget(
        images_list,
        cmap="viridis"
    )
    widget_multi = iw_mult.show()
    widget_multi.resize(800, 800)

    # image widget with rgb data
    rgb_video = iio.imread("imageio:cockatoo.mp4")
    iw_rgb = fpl.ImageWidget(rgb_video, rgb=[True], figure_kwargs={"size": (800, 500)})
    iw_rgb.show()

    fpl.loop.run()

    # You can also use Qt interactively/in a non-blocking manner in notebooks and ipython
    # by using %gui qt and NOT calling `fpl.loop.run()`, see the user guide for more details


.. _sphx_glr_download__gallery_qt_imagewidget.py:

.. only:: html

  .. container:: sphx-glr-footer sphx-glr-footer-example

    .. container:: sphx-glr-download sphx-glr-download-jupyter

      :download:`Download Jupyter notebook: imagewidget.ipynb <imagewidget.ipynb>`

    .. container:: sphx-glr-download sphx-glr-download-python

      :download:`Download Python source code: imagewidget.py <imagewidget.py>`

    .. container:: sphx-glr-download sphx-glr-download-zip

      :download:`Download zipped: imagewidget.zip <imagewidget.zip>`


.. only:: html

 .. rst-class:: sphx-glr-signature

    `Gallery generated by Sphinx-Gallery <https://sphinx-gallery.github.io>`_