.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "_gallery/qt/minimal.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__gallery_qt_minimal.py: Minimal Qt ========== Minimal PyQt example that displays an image. `Figure.show()` returns a QWidget that you can use in a Qt app just like any other QWidget! .. GENERATED FROM PYTHON SOURCE LINES 9-36 .. code-block:: Python # test_example = false # import Qt or PySide from PyQt6 import QtWidgets import fastplotlib as fpl import imageio.v3 as iio img = iio.imread("imageio:astronaut.png") # fastplotlib and wgpu will auto-detect if Qt is imported and then use the Qt canvas and Qt output context figure = fpl.Figure() figure[0, 0].add_image(img) # must call fig.show() to start rendering loop and show the QWidget containing the fastplotlib figure qwidget = figure.show() # set QWidget initial size from image width and height qwidget.resize(*img.shape[:2]) # execute Qt app # if this is part of a larger Qt QApplication, you can also call app.exec() where app is the QApplication instance fpl.run() # You can also use Qt interactively/in a non-blocking manner in notebooks and ipython # by using %gui qt and NOT calling `fpl.run()`, see the user guide for more details .. _sphx_glr_download__gallery_qt_minimal.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: minimal.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: minimal.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: minimal.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_