diff --git a/zndraw/app.py b/zndraw/app.py index 5dca74f3d..6f6357433 100644 --- a/zndraw/app.py +++ b/zndraw/app.py @@ -430,6 +430,7 @@ def download_request(data): def download_response(data): emit("download:response", data["data"], to=data["sid"]) + @io.on("scene:play") def scene_play(data): print(f"scene:play {data}") @@ -438,6 +439,7 @@ def scene_play(data): else: emit("scene:play", to=session["token"]) + @io.on("scene:pause") def scene_pause(data): print(f"scene:pause {data}") diff --git a/zndraw/zndraw.py b/zndraw/zndraw.py index 502fbbb26..748a31b7b 100644 --- a/zndraw/zndraw.py +++ b/zndraw/zndraw.py @@ -204,10 +204,14 @@ def selection(self, value: list[int]): self.socket.emit("selection:set", data) def play(self): - self.socket.emit("scene:play", {"sid": self._target_sid if self._target_sid else self.token}) + self.socket.emit( + "scene:play", {"sid": self._target_sid if self._target_sid else self.token} + ) def pause(self): - self.socket.emit("scene:pause", {"sid": self._target_sid if self._target_sid else self.token}) + self.socket.emit( + "scene:pause", {"sid": self._target_sid if self._target_sid else self.token} + ) @dataclasses.dataclass @@ -326,14 +330,16 @@ def modifier_run(self, data): size = len(self) - for idx, atoms in enumerate(modifier.run( - atom_ids=selection, - atoms=atoms, - points=points, - segments=segments, - json_data=json_data, - url=data["url"], - )): + for idx, atoms in enumerate( + modifier.run( + atom_ids=selection, + atoms=atoms, + points=points, + segments=segments, + json_data=json_data, + url=data["url"], + ) + ): self[size + idx] = atoms self.play()