.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "gallery/cube_trio.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_trio.py: Cube trio --------- Run a wgpu example on the glfw backend, and the trio loop. .. GENERATED FROM PYTHON SOURCE LINES 7-37 .. code-block:: Python import trio from rendercanvas.glfw import RenderCanvas from rendercanvas.trio import loop from rendercanvas.utils.cube import setup_drawing_sync 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__": # This works, but is not very trio-ish # loop.run() # This looks more like it # trio.run(loop.run_async) # But for the sake of completeness ... async def main(): # ... add Trio stuff here await loop.run_async() trio.run(main) .. _sphx_glr_download_gallery_cube_trio.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: cube_trio.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: cube_trio.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: cube_trio.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_