.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "gallery/wx_app.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_wx_app.py: wx app ------ An example demonstrating a wx app with a wgpu viz inside. .. GENERATED FROM PYTHON SOURCE LINES 7-53 .. code-block:: Python import time import wx from rendercanvas.wx import RenderWidget from rendercanvas.utils.cube import setup_drawing_sync class Example(wx.Frame): def __init__(self): super().__init__(None, title="wgpu triangle embedded in a wx app") self.SetSize(640, 480) # Using present_method 'image' because it reports "The surface texture is suboptimal" self.canvas = RenderWidget( self, update_mode="continuous", present_method="bitmap" ) self.button = wx.Button(self, -1, "Hello world") self.output = wx.StaticText(self) sizer = wx.BoxSizer(wx.HORIZONTAL) sizer.Add(self.button, 0, wx.EXPAND) sizer.Add(self.canvas, 1, wx.EXPAND) sizer.Add(self.output, 1, wx.EXPAND) self.SetSizer(sizer) self.button.Bind(wx.EVT_BUTTON, self.OnClicked) # Force the canvas to be shown, so that it gets a valid handle. # Otherwise GetHandle() is initially 0, and getting a surface will fail. self.Show() def OnClicked(self, event): # noqa: N802 t = self.output.GetLabel() t += f"\nClicked at {time.time():0.1f}" self.output.SetLabel(t) app = wx.App() example = Example() draw_frame = setup_drawing_sync(example.canvas) example.canvas.request_draw(draw_frame) app.MainLoop() .. _sphx_glr_download_gallery_wx_app.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: wx_app.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: wx_app.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: wx_app.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_