Default Canvas
See original GitHub issueIn a previous discussion (https://github.com/pygfx/pygfx/pull/371#discussion_r1014485572) I learned that you often don’t need to interact with the canvas object directly when using pygfx. There are, of course, exceptions when this can be advantageous, but in general this is not the case. Because of this, we have introduced renderer.request_draw
which wraps canvas.request_draw
.
Taking this thought and thinking it to its conclusion I think it would make sense to also see if we can avoid all calls to canvas
by default so that we only have to instantiate it when needed. In particular, I was wondering if we could change
from wgpu.gui.auto import WgpuCanvas, run
import pygfx as gfx
renderer = gfx.renderers.WgpuRenderer(WgpuCanvas())
to
import pygfx as gfx, run
renderer = gfx.renderers.WgpuRenderer()
and make wgpu.gui.auto.WgpuCanvas
the default canvas. We would, of course, keep the parameter and allow users to set it manually if needed. My angle here is to see if we can reduce boilerplate code.
On the same token, we could wrap run
and avoid the import of wgpu
for minimal examples. It’s always nice to not have to import lower-level functionality when dealing with something on a more high level.
Issue Analytics
- State:
- Created a year ago
- Comments:19 (6 by maintainers)
Top GitHub Comments
That’s funny! Have a look at
gfx.show
, and the example.Could perhaps be an arg to
show
? But yeah, let’s discuss elsewhere.