wgpu.gui.WgpuCanvasBase

class wgpu.gui.WgpuCanvasBase(*args, max_fps=30, vsync=True, **kwargs)

Bases: WgpuCanvasInterface

A canvas class that provides a basis for all GUI toolkits.

This class implements common functionality, to realize a common API and avoid code duplication. It is convenient (but not strictly necessary) for canvas classes to inherit from this class (all builtin canvases do).

Amongst other things, this class implements draw rate limiting, which can be set with the max_fps attribute (default 30). For benchmarks you may also want to set vsync to False.

close()

Close the window.

draw_frame()

The function that gets called at each draw. You can implement this method in a subclass, or set it via a call to request_draw().

get_logical_size()

Get the logical size in float pixels.

get_physical_size()

Get the physical size in integer pixels.

get_pixel_ratio()

Get the float ratio between logical and physical pixels.

is_closed()

Get whether the window is closed.

request_draw(draw_function=None)

Request from the main loop to schedule a new draw event, so that the canvas will be updated. If draw_function is not given, the last set drawing function is used.

set_logical_size(width, height)

Set the window size (in logical pixels).