.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "_gallery/other/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_other_cube_qt.py: Simple Cube with Qt =================== Example showing a single geometric cube. Alternatively one can import the Qt library of your choice, and then use ``from rendercanvas.qt import RenderCanvas`` to get the corresponding canvas class. .. GENERATED FROM PYTHON SOURCE LINES 10-51 .. code-block:: Python import pygfx as gfx import pylinalg as la # Select one # from rendercanvas.pyqt5 import RenderCanvas # from rendercanvas.pyqt6 import RenderCanvas from rendercanvas.pyside6 import RenderCanvas, loop canvas = RenderCanvas() renderer = gfx.renderers.WgpuRenderer(canvas) scene = gfx.Scene() cube = gfx.Mesh( gfx.box_geometry(200, 200, 200), gfx.MeshPhongMaterial(color=(0.2, 0.4, 0.6, 1.0)), ) scene.add(cube) scene.add(gfx.AmbientLight()) directional_light = gfx.DirectionalLight() directional_light.world.z = 1 scene.add(directional_light) camera = gfx.PerspectiveCamera(70, 16 / 9) camera.world.z = 400 def animate(): rot = la.quaternion.quat_from_euler((0.005, 0.01, 0)) cube.local.rotation = la.quat_mul(rot, cube.local.rotation) renderer.render(scene, camera) canvas.request_draw() if __name__ == "__main__": canvas.request_draw(animate) loop.run() # i.e. app.exec() .. _sphx_glr_download__gallery_other_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 `_ .. only:: html Interactive example ------------------- Try this example in your browser using Pyodide. Might not work with all examples and all devices. Check the output and your browser's console for details. .. raw:: html