Skip to content

Commit

Permalink
Rename (#7)
Browse files Browse the repository at this point in the history
  • Loading branch information
almarklein authored Nov 6, 2024
1 parent 6d43bf4 commit c04c42c
Show file tree
Hide file tree
Showing 36 changed files with 228 additions and 228 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ by producing rgba images.
pip install rendercanvas
```

To have at least one GUI backend, we recommend:
To have at least one backend, we recommend:
```
pip install rendercanvas glfw
```
Expand All @@ -53,11 +53,11 @@ Also see the [online documentation](https://rendercanvas.readthedocs.io) and the

```py
# Select either the glfw, qt or jupyter backend
from rendercanvas.auto import WgpuCanvas, loop
from rendercanvas.auto import RenderCanvas, loop

# Visualizations can be embedded as a widget in a Qt application.
# Supported qt libs are PySide6, PyQt6, PySide2 or PyQt5.
from rendercanvas.pyside6 import QWgpuWidget
from rendercanvas.pyside6 import QRenderWidget


# Now specify what the canvas should do on a draw
Expand Down
8 changes: 4 additions & 4 deletions docs/api.rst
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
rendercanvas base classes
=========================

.. autoclass:: rendercanvas.base.WgpuCanvasInterface
.. autoclass:: rendercanvas.base.RenderCanvasInterface
:members:

.. autoclass:: rendercanvas.base.WgpuCanvasBase
.. autoclass:: rendercanvas.base.BaseRenderCanvas
:members:

.. .. autoclass:: rendercanvas.base.WgpuLoop
.. .. autoclass:: rendercanvas.base.BaseLoop
.. :members:
.. .. autoclass:: rendercanvas.base.WgpuTimer
.. .. autoclass:: rendercanvas.base.BaseTimer
.. :members:
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
intersphinx_mapping = {
"python": ("https://docs.python.org/3", None),
"numpy": ("https://numpy.org/doc/stable", None),
"wgpu": ("https://wgpu-py.readthedocs.io/en/latest", None),
"wgpu": ("https://wgpu-py.readthedocs.io/en/stable", None),
}

# Add any paths that contain templates here, relative to this directory.
Expand Down
44 changes: 22 additions & 22 deletions docs/gui.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ moment these include GLFW, Jupyter, Qt, and wx.
The Canvas base classes
-----------------------

For each supported GUI toolkit there is a module that implements a ``WgpuCanvas`` class,
which inherits from :class:`WgpuCanvasBase`, providing a common API.
For each supported GUI toolkit there is a module that implements a ``RenderCanvas`` class,
which inherits from :class:`BaseRenderCanvas`, providing a common API.
The GLFW, Qt, and Jupyter backends also inherit from :class:`WgpuAutoGui` to include
support for events (interactivity). In the next sections we demonstrates the different
canvas classes that you can use.
Expand All @@ -23,10 +23,10 @@ canvas classes that you can use.
Events
------

To implement interaction with a ``WgpuCanvas``, use the :func:`WgpuCanvasBase.add_event_handler()` method.
To implement interaction with a ``RenderCanvas``, use the :func:`BaseRenderCanvas.add_event_handler()` method.
Events come in the following flavours:

.. autoclass:: WgpuEventType
.. autoclass:: EventType
:members:


Expand All @@ -47,9 +47,9 @@ for details about the event objects.

.. code-block:: py
from wgpu.gui.auto import WgpuCanvas, run, call_later
from wgpu.gui.auto import RenderCanvas, run, call_later
canvas = WgpuCanvas(title="Example")
canvas = RenderCanvas(title="Example")
canvas.request_draw(your_draw_function)
run()
Expand All @@ -64,9 +64,9 @@ but you can replace ``from rendercanvas.auto`` with ``from rendercanvas.glfw`` t

.. code-block:: py
from wgpu.gui.glfw import WgpuCanvas, run, call_later
from wgpu.gui.glfw import RenderCanvas, run, call_later
canvas = WgpuCanvas(title="Example")
canvas = RenderCanvas(title="Example")
canvas.request_draw(your_draw_function)
run()
Expand All @@ -77,23 +77,23 @@ Support for Qt

There is support for PyQt5, PyQt6, PySide2 and PySide6. The rendercanvas library detects what
library you are using by looking what module has been imported.
For a toplevel widget, the ``rendercanvas.qt.WgpuCanvas`` class can be imported. If you want to
embed the canvas as a subwidget, use ``rendercanvas.qt.WgpuWidget`` instead.
For a toplevel widget, the ``rendercanvas.qt.RenderCanvas`` class can be imported. If you want to
embed the canvas as a subwidget, use ``rendercanvas.qt.QRenderWidget`` instead.

Also see the `Qt triangle example <https://github.com/pygfx/wgpu-py/blob/main/examples/triangle_qt.py>`_
and `Qt triangle embed example <https://github.com/pygfx/wgpu-py/blob/main/examples/triangle_qt_embed.py>`_.

.. code-block:: py
# Import any of the Qt libraries before importing the WgpuCanvas.
# Import any of the Qt libraries before importing the RenderCanvas.
# This way wgpu knows which Qt library to use.
from PySide6 import QtWidgets
from wgpu.gui.qt import WgpuCanvas
from wgpu.gui.qt import RenderCanvas
app = QtWidgets.QApplication([])
# Instantiate the canvas
canvas = WgpuCanvas(title="Example")
canvas = RenderCanvas(title="Example")
# Tell the canvas what drawing function to call
canvas.request_draw(your_draw_function)
Expand All @@ -105,21 +105,21 @@ Support for wx
--------------

There is support for embedding a wgpu visualization in wxPython.
For a toplevel widget, the ``gui.wx.WgpuCanvas`` class can be imported. If you want to
embed the canvas as a subwidget, use ``gui.wx.WgpuWidget`` instead.
For a toplevel widget, the ``gui.wx.RenderCanvas`` class can be imported. If you want to
embed the canvas as a subwidget, use ``gui.wx.RenderWidget`` instead.

Also see the `wx triangle example <https://github.com/pygfx/wgpu-py/blob/main/examples/triangle_wx.py>`_
and `wx triangle embed example <https://github.com/pygfx/wgpu-py/blob/main/examples/triangle_wx_embed.py>`_.

.. code-block:: py
import wx
from wgpu.gui.wx import WgpuCanvas
from wgpu.gui.wx import RenderCanvas
app = wx.App()
# Instantiate the canvas
canvas = WgpuCanvas(title="Example")
canvas = RenderCanvas(title="Example")
# Tell the canvas what drawing function to call
canvas.request_draw(your_draw_function)
Expand All @@ -137,10 +137,10 @@ object, but in some cases it's convenient to do so with a canvas-like API.

.. code-block:: py
from wgpu.gui.offscreen import WgpuCanvas
from wgpu.gui.offscreen import RenderCanvas
# Instantiate the canvas
canvas = WgpuCanvas(size=(500, 400), pixel_ratio=1)
canvas = RenderCanvas(size=(500, 400), pixel_ratio=1)
# ...
Expand All @@ -160,10 +160,10 @@ subclass implementing a remote frame-buffer. There are also some `wgpu examples

.. code-block:: py
# from wgpu.gui.jupyter import WgpuCanvas # Direct approach
from wgpu.gui.auto import WgpuCanvas # Approach compatible with desktop usage
# from wgpu.gui.jupyter import RenderCanvas # Direct approach
from wgpu.gui.auto import RenderCanvas # Approach compatible with desktop usage
canvas = WgpuCanvas()
canvas = RenderCanvas()
# ... wgpu code
Expand Down
4 changes: 2 additions & 2 deletions docs/guide.rst
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ GUI toolkits are supported, see the :doc:`gui`. In general, it's easiest to let

.. code-block:: py
from wgpu.gui.auto import WgpuCanvas, run
from wgpu.gui.auto import RenderCanvas, run
canvas = WgpuCanvas(title="a wgpu example")
canvas = RenderCanvas(title="a wgpu example")
Next, we can setup the render context, which we will need later on.
Expand Down
10 changes: 5 additions & 5 deletions docs/start.rst
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ Since most users will want to render something to screen, we recommend installin
pip install rendercanvas glfw
GUI libraries
-------------
Backends
--------

Multiple GUI backends are supported, see :doc:`the GUI API <gui>` for details:
Multiple backends are supported, including multiple GUI libraries, see :doc:`the GUI API <gui>` for details:

* `glfw <https://github.com/FlorianRhiem/pyGLFW>`_: a lightweight GUI for the desktop
* `jupyter_rfb <https://jupyter-rfb.readthedocs.io>`_: only needed if you plan on using wgpu in Jupyter
* `glfw <https://github.com/FlorianRhiem/pyGLFW>`_: a lightweight canvas for the desktop
* `jupyter_rfb <https://jupyter-rfb.readthedocs.io>`_: only needed if you plan on using Jupyter
* qt (PySide6, PyQt6, PySide2, PyQt5)
* wx
6 changes: 3 additions & 3 deletions examples/gui_auto.py → examples/cube_auto.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
Run a wgpu example on an automatically selected backend.
"""

from rendercanvas.auto import WgpuCanvas, run
from rendercanvas.auto import RenderCanvas, run

from rendercanvas.utils.cube import setup_drawing_sync


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

Expand Down
4 changes: 2 additions & 2 deletions examples/gui_glfw.py → examples/cube_glfw.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
Run a wgpu example on the glfw backend.
"""

from rendercanvas.glfw import WgpuCanvas, run
from rendercanvas.glfw import RenderCanvas, run

from rendercanvas.utils.cube import setup_drawing_sync


canvas = WgpuCanvas(size=(640, 480), title="The wgpu cube example on glfw")
canvas = RenderCanvas(size=(640, 480), title="The wgpu cube example on glfw")
draw_frame = setup_drawing_sync(canvas)


Expand Down
4 changes: 2 additions & 2 deletions examples/gui_qt.py → examples/cube_qt.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@
pass


from rendercanvas.qt import WgpuCanvas, run
from rendercanvas.qt import RenderCanvas, run

from rendercanvas.utils.cube import setup_drawing_sync


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


Expand Down
4 changes: 2 additions & 2 deletions examples/gui_wx.py → examples/cube_wx.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
Run a wgpu example on the wx backend.
"""

from rendercanvas.wx import WgpuCanvas, run
from rendercanvas.wx import RenderCanvas, run

from rendercanvas.utils.cube import setup_drawing_sync


canvas = WgpuCanvas(size=(640, 480), title="The wgpu cube example on wx")
canvas = RenderCanvas(size=(640, 480), title="The wgpu cube example on wx")
draw_frame = setup_drawing_sync(canvas)


Expand Down
4 changes: 2 additions & 2 deletions examples/gui_demo.py → examples/demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@

import time

from rendercanvas.auto import WgpuCanvas, loop
from rendercanvas.auto import RenderCanvas, loop

from cube import setup_drawing_sync


canvas = WgpuCanvas(
canvas = RenderCanvas(
size=(640, 480),
title="Canvas events on $backend - $fps fps",
max_fps=10,
Expand Down
4 changes: 2 additions & 2 deletions examples/gui_events.py → examples/events.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
A simple example to demonstrate events.
"""

from rendercanvas.auto import WgpuCanvas, run
from rendercanvas.auto import RenderCanvas, run


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


@canvas.add_event_handler("*")
Expand Down
6 changes: 3 additions & 3 deletions examples/gui_multiple.py → examples/multiple.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,17 @@

# test_example = true

from rendercanvas.auto import WgpuCanvas, loop
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


canvas1 = WgpuCanvas(title=f"Triangle example on {WgpuCanvas.__name__}")
canvas1 = RenderCanvas(title=f"Triangle example on {RenderCanvas.__name__}")
draw_frame1 = setup_drawing_sync_triangle(canvas1)
canvas1.request_draw(draw_frame1)

canvas2 = WgpuCanvas(title=f"Cube example on {WgpuCanvas.__name__}")
canvas2 = RenderCanvas(title=f"Cube example on {RenderCanvas.__name__}")
draw_frame2 = setup_drawing_sync_cube(canvas2)
canvas2.request_draw(draw_frame2)

Expand Down
4 changes: 2 additions & 2 deletions examples/gui_threading.py → examples/offsceen_threaded.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@
import time
import threading

from rendercanvas.offscreen import WgpuCanvas
from rendercanvas.offscreen import RenderCanvas

from cube import setup_drawing_sync


# create canvas
canvas = WgpuCanvas()
canvas = RenderCanvas()
draw_frame = setup_drawing_sync(canvas)


Expand Down
4 changes: 2 additions & 2 deletions examples/gui_qt_embed.py → examples/qt_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
except ModuleNotFoundError:
pass

from rendercanvas.qt import QWgpuWidget
from rendercanvas.qt import QRenderWidget
from rendercanvas.utils.cube import setup_drawing_sync


Expand All @@ -31,7 +31,7 @@ def __init__(self):
splitter = QtWidgets.QSplitter()

self.button = QtWidgets.QPushButton("Hello world", self)
self.canvas = QWgpuWidget(splitter)
self.canvas = QRenderWidget(splitter)
self.output = QtWidgets.QTextEdit(splitter)

self.button.clicked.connect(self.whenButtonClicked)
Expand Down
6 changes: 3 additions & 3 deletions examples/gui_qt_asyncio.py → examples/qt_app_asyncio.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""
An example demonstrating a qt app with a wgpu viz inside.
This is the same as the ``gui_qt_embed.py`` example, except this uses
This is the same as the ``qt_app.py`` example, except this uses
the asyncio compatible mode that was introduced in Pyside 6.6.
For more info see:
Expand All @@ -17,7 +17,7 @@
import asyncio

from PySide6 import QtWidgets, QtAsyncio
from rendercanvas.qt import QWgpuWidget
from rendercanvas.qt import QRenderWidget
from rendercanvas.utils.cube import setup_drawing_sync


Expand Down Expand Up @@ -49,7 +49,7 @@ def __init__(self):

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

# self.button.clicked.connect(self.whenButtonClicked) # see above :(
Expand Down
Loading

0 comments on commit c04c42c

Please sign in to comment.