Skip to content

Commit

Permalink
Tweak examples
Browse files Browse the repository at this point in the history
  • Loading branch information
almarklein committed Nov 11, 2024
1 parent dedb3bf commit 874ff7f
Show file tree
Hide file tree
Showing 9 changed files with 22 additions and 42 deletions.
9 changes: 2 additions & 7 deletions examples/cube_auto.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,10 @@


canvas = RenderCanvas(
size=(640, 480), title=f"The wgpu cube example on a {RenderCanvas.__name__}"
title="The wgpu cube example on $backend", update_mode="continuous"
)
draw_frame = setup_drawing_sync(canvas)


@canvas.request_draw
def animate():
draw_frame()
canvas.request_draw()
canvas.request_draw(draw_frame)


if __name__ == "__main__":
Expand Down
11 changes: 4 additions & 7 deletions examples/cube_glfw.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,11 @@
from rendercanvas.utils.cube import setup_drawing_sync


canvas = RenderCanvas(size=(640, 480), title="The wgpu cube example on glfw")
canvas = RenderCanvas(
title="The wgpu cube example on $backend", update_mode="continuous"
)
draw_frame = setup_drawing_sync(canvas)


@canvas.request_draw
def animate():
draw_frame()
canvas.request_draw()
canvas.request_draw(draw_frame)


if __name__ == "__main__":
Expand Down
10 changes: 2 additions & 8 deletions examples/cube_qt.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,12 @@


from rendercanvas.qt import RenderCanvas, run

from rendercanvas.utils.cube import setup_drawing_sync


canvas = RenderCanvas(size=(640, 480), title=f"The wgpu cube example on {lib}")
canvas = RenderCanvas(title=f"The wgpu cube example on {lib}", update_mode="continuous")
draw_frame = setup_drawing_sync(canvas)


@canvas.request_draw
def animate():
draw_frame()
canvas.request_draw()
canvas.request_draw(draw_frame)


if __name__ == "__main__":
Expand Down
11 changes: 4 additions & 7 deletions examples/cube_wx.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,11 @@
from rendercanvas.utils.cube import setup_drawing_sync


canvas = RenderCanvas(size=(640, 480), title="The wgpu cube example on wx")
canvas = RenderCanvas(
title="The wgpu cube example on $backend", update_mode="continuous"
)
draw_frame = setup_drawing_sync(canvas)


@canvas.request_draw
def animate():
draw_frame()
canvas.request_draw()
canvas.request_draw(draw_frame)


if __name__ == "__main__":
Expand Down
2 changes: 1 addition & 1 deletion examples/demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@


draw_frame = setup_drawing_sync(canvas)
canvas.request_draw(lambda: (draw_frame(), canvas.request_draw()))
canvas.request_draw(draw_frame)


@canvas.add_event_handler("*")
Expand Down
4 changes: 2 additions & 2 deletions examples/events.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
from rendercanvas.auto import RenderCanvas, run


canvas = RenderCanvas(size=(640, 480), title="RenderCanvas events")
canvas = RenderCanvas(title="RenderCanvas events")


@canvas.add_event_handler("*")
def process_event(event):
if event["event_type"] != "pointer_move":
if event["event_type"] not in ["pointer_move", "before_draw", "draw"]:
print(event)


Expand Down
14 changes: 6 additions & 8 deletions examples/multiple.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,19 @@
"""
Run triangle and cube examples two canvases.
Run cube example in two canvases.
"""

# test_example = true

from rendercanvas.auto import RenderCanvas, loop

from triangle import setup_drawing_sync as setup_drawing_sync_triangle
from cube import setup_drawing_sync as setup_drawing_sync_cube
from rendercanvas.utils.cube import setup_drawing_sync


canvas1 = RenderCanvas(title=f"Triangle example on {RenderCanvas.__name__}")
draw_frame1 = setup_drawing_sync_triangle(canvas1)
canvas1 = RenderCanvas(title="$backend 1", update_mode="continuous")
draw_frame1 = setup_drawing_sync(canvas1)
canvas1.request_draw(draw_frame1)

canvas2 = RenderCanvas(title=f"Cube example on {RenderCanvas.__name__}")
draw_frame2 = setup_drawing_sync_cube(canvas2)
canvas2 = RenderCanvas(title="$backend 2", update_mode="continuous")
draw_frame2 = setup_drawing_sync(canvas2)
canvas2.request_draw(draw_frame2)


Expand Down
2 changes: 1 addition & 1 deletion examples/offsceen_threaded.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

from rendercanvas.offscreen import RenderCanvas

from cube import setup_drawing_sync
from rendercanvas.utils.cube import setup_drawing_sync


# create canvas
Expand Down
1 change: 0 additions & 1 deletion examples/qt_app_asyncio.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ def __init__(self):

splitter = QtWidgets.QSplitter()

# todo: use update_mode = 'continuous' when that feature has arrived
self.button = QtWidgets.QPushButton("Hello world", self)
self.canvas = QRenderWidget(splitter, update_mode="continuous")
self.output = QtWidgets.QTextEdit(splitter)
Expand Down

0 comments on commit 874ff7f

Please sign in to comment.