Skip to content

Commit fa747dc

Browse files
committed
update subprocess example
1 parent 146ea5c commit fa747dc

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

examples/gui_subprocess.py

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
import time
1717
import subprocess
1818

19-
from wgpu.gui import WgpuCanvasBase
19+
from rendercanvas import BaseRenderCanvas
2020

2121
# Import the function that we must call to run the visualization
2222
from triangle import setup_drawing_sync
@@ -26,31 +26,32 @@
2626
code = """
2727
import sys
2828
import json
29-
from PySide6 import QtWidgets # Use either PySide6 or PyQt6
30-
from wgpu.gui.qt import WgpuCanvas
29+
from PyQt6 import QtWidgets # Use either PySide6 or PyQt6
30+
from rendercanvas.qt import RenderCanvas
3131
3232
app = QtWidgets.QApplication([])
33-
canvas = WgpuCanvas(title="wgpu triangle in Qt subprocess")
33+
canvas = RenderCanvas(title="wgpu triangle in Qt subprocess", update_mode="ondemand")
3434
35-
print(json.dumps(canvas.get_present_methods()))
35+
print(json.dumps(canvas._subwidget._rc_get_present_methods()))
3636
print(canvas.get_physical_size())
3737
sys.stdout.flush()
3838
39-
app.exec_()
39+
app.exec()
4040
"""
4141

4242

43-
class ProxyCanvas(WgpuCanvasBase):
43+
class ProxyCanvas(BaseRenderCanvas):
4444
def __init__(self):
4545
super().__init__()
4646
self._present_methods = json.loads(p.stdout.readline().decode())
47+
print(self._present_methods)
4748
self._psize = tuple(
4849
int(x) for x in p.stdout.readline().decode().strip().strip("()").split(",")
4950
)
5051
print(self._psize)
5152
time.sleep(0.2)
5253

53-
def get_present_methods(self):
54+
def _rc_get_present_methods(self):
5455
return self._present_methods
5556

5657
def get_physical_size(self):
@@ -71,8 +72,8 @@ def close(self):
7172
def is_closed(self):
7273
raise NotImplementedError()
7374

74-
def _request_draw(self):
75-
self.draw_frame()
75+
def _rc_request_draw(self):
76+
self._draw_frame()
7677

7778

7879
# Create subprocess
@@ -84,4 +85,5 @@ def _request_draw(self):
8485
# Go!
8586
draw_frame = setup_drawing_sync(canvas)
8687
canvas.request_draw(draw_frame)
88+
canvas.force_draw()
8789
time.sleep(3)

0 commit comments

Comments
 (0)