.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "gallery/cube_qt.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_cube_qt.py: Cube qt ------- Run a wgpu example on the Qt backend. Works with either PySide6, PyQt6, PyQt5 or PySide2. .. GENERATED FROM PYTHON SOURCE LINES 9-35 .. code-block:: Python # ruff: noqa: E402 import importlib # The `rendercanvas.qt` module checks what Qt libs is imported, so we need to import that first. # For the sake of making this example Just Work, we try multiple Qt libs for lib in ("PySide6", "PyQt6", "PySide2", "PyQt5"): try: QtWidgets = importlib.import_module(".QtWidgets", lib) break except ModuleNotFoundError: pass from rendercanvas.qt import RenderCanvas, loop from rendercanvas.utils.cube import setup_drawing_sync canvas = RenderCanvas(title=f"The wgpu cube example on {lib}", update_mode="continuous") draw_frame = setup_drawing_sync(canvas) canvas.request_draw(draw_frame) if __name__ == "__main__": loop.run() .. _sphx_glr_download_gallery_cube_qt.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: cube_qt.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: cube_qt.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: cube_qt.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_