.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "gallery/cube_asyncio.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_asyncio.py: Cube asyncio ------------ Run a wgpu example on the glfw backend, and the asyncio loop .. GENERATED FROM PYTHON SOURCE LINES 7-32 .. code-block:: Python import asyncio from rendercanvas.glfw import RenderCanvas from rendercanvas.asyncio import loop from rendercanvas.utils.cube import setup_drawing_sync # The asyncio loop is the default, but this may change, so better be explicit. RenderCanvas.select_loop(loop) canvas = RenderCanvas( title="The wgpu cube on $backend with $loop", update_mode="continuous" ) draw_frame = setup_drawing_sync(canvas) canvas.request_draw(draw_frame) if __name__ == "__main__": async def main(): # ... add asyncio stuff here await loop.run_async() asyncio.run(main()) .. _sphx_glr_download_gallery_cube_asyncio.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: cube_asyncio.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: cube_asyncio.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: cube_asyncio.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_