diff --git a/py5jupyter/__init__.py b/py5jupyter/__init__.py index 3269fd0..e511ad4 100644 --- a/py5jupyter/__init__.py +++ b/py5jupyter/__init__.py @@ -1,7 +1,7 @@ # ***************************************************************************** # # Part of the py5jupyter (& py5) library -# Copyright (C) 2022-2023 Jim Schmitz +# Copyright (C) 2022-2024 Jim Schmitz # # This library is free software: you can redistribute it and/or modify it # under the terms of the GNU Lesser General Public License as published by @@ -33,10 +33,12 @@ def _jupyter_labextension_paths(): from `src` directory into /labextensions/ directory during widget installation """ - return [{ - 'src': 'labextension', - 'dest': 'jupyter-py5', - }] + return [ + { + "src": "labextension", + "dest": "jupyter-py5", + } + ] def _jupyter_nbextension_paths(): @@ -55,9 +57,11 @@ def _jupyter_nbextension_paths(): require: Path to importable AMD Javascript module inside the /nbextensions/ directory """ - return [{ - 'section': 'notebook', - 'src': 'nbextension', - 'dest': 'py5jupyter', - 'require': 'py5jupyter/extension' - }] + return [ + { + "section": "notebook", + "src": "nbextension", + "dest": "py5jupyter", + "require": "py5jupyter/extension", + } + ] diff --git a/py5jupyter/_version.py b/py5jupyter/_version.py index 4cae6ad..089865f 100644 --- a/py5jupyter/_version.py +++ b/py5jupyter/_version.py @@ -1,7 +1,7 @@ # ***************************************************************************** # # Part of the py5jupyter (& py5) library -# Copyright (C) 2022-2023 Jim Schmitz +# Copyright (C) 2022-2024 Jim Schmitz # # This library is free software: you can redistribute it and/or modify it # under the terms of the GNU Lesser General Public License as published by @@ -17,5 +17,5 @@ # along with this library. If not, see . # # ***************************************************************************** -version_info = (0, 2, 0, 'a0') +version_info = (0, 2, 0, "a0") __version__ = ".".join(map(str, version_info)) diff --git a/py5jupyter/kernels/__init__.py b/py5jupyter/kernels/__init__.py index 689e2c0..b74991a 100644 --- a/py5jupyter/kernels/__init__.py +++ b/py5jupyter/kernels/__init__.py @@ -1,7 +1,7 @@ # ***************************************************************************** # # Part of the py5jupyter (& py5) library -# Copyright (C) 2022-2023 Jim Schmitz +# Copyright (C) 2022-2024 Jim Schmitz # # This library is free software: you can redistribute it and/or modify it # under the terms of the GNU Lesser General Public License as published by diff --git a/py5jupyter/kernels/py5/__init__.py b/py5jupyter/kernels/py5/__init__.py index f6f0955..cf06661 100644 --- a/py5jupyter/kernels/py5/__init__.py +++ b/py5jupyter/kernels/py5/__init__.py @@ -1,7 +1,7 @@ # ***************************************************************************** # # Part of the py5jupyter (& py5) library -# Copyright (C) 2022-2023 Jim Schmitz +# Copyright (C) 2022-2024 Jim Schmitz # # This library is free software: you can redistribute it and/or modify it # under the terms of the GNU Lesser General Public License as published by diff --git a/py5jupyter/kernels/py5/__main__.py b/py5jupyter/kernels/py5/__main__.py index 04190fc..d0fec25 100644 --- a/py5jupyter/kernels/py5/__main__.py +++ b/py5jupyter/kernels/py5/__main__.py @@ -1,7 +1,7 @@ # ***************************************************************************** # # Part of the py5jupyter (& py5) library -# Copyright (C) 2022-2023 Jim Schmitz +# Copyright (C) 2022-2024 Jim Schmitz # # This library is free software: you can redistribute it and/or modify it # under the terms of the GNU Lesser General Public License as published by diff --git a/py5jupyter/kernels/py5/install.py b/py5jupyter/kernels/py5/install.py index 34dc29d..c46a488 100644 --- a/py5jupyter/kernels/py5/install.py +++ b/py5jupyter/kernels/py5/install.py @@ -1,7 +1,7 @@ # ***************************************************************************** # # Part of the py5jupyter (& py5) library -# Copyright (C) 2022-2023 Jim Schmitz +# Copyright (C) 2022-2024 Jim Schmitz # # This library is free software: you can redistribute it and/or modify it # under the terms of the GNU Lesser General Public License as published by @@ -38,16 +38,15 @@ def install_py5_kernel_spec(user=True, prefix=None): with TemporaryDirectory() as td: os.chmod(td, 0o755) # Starts off as 700, not user readable - with open(Path(td) / 'kernel.json', 'w') as f: + with open(Path(td) / "kernel.json", "w") as f: json.dump(kernel_json, f, sort_keys=True) # Copy any resources - for file in (Path(__file__).parent / 'resources').glob('*'): + for file in (Path(__file__).parent / "resources").glob("*"): shutil.copy(file, Path(td) / file.name) - print('Installing py5 Jupyter kernel spec') - KernelSpecManager().install_kernel_spec( - td, 'py5', user=user, prefix=prefix) + print("Installing py5 Jupyter kernel spec") + KernelSpecManager().install_kernel_spec(td, "py5", user=user, prefix=prefix) def _is_root(): @@ -59,13 +58,21 @@ def _is_root(): def main(argv=None): ap = argparse.ArgumentParser() - ap.add_argument('--user', action='store_true', - help="Install to the per-user kernels registry. Default if not root.") - ap.add_argument('--sys-prefix', action='store_true', - help="Install to sys.prefix (e.g. a virtualenv or conda env)") - ap.add_argument('--prefix', - help="Install to the given prefix. " - "Kernelspec will be installed in {PREFIX}/share/jupyter/kernels/") + ap.add_argument( + "--user", + action="store_true", + help="Install to the per-user kernels registry. Default if not root.", + ) + ap.add_argument( + "--sys-prefix", + action="store_true", + help="Install to sys.prefix (e.g. a virtualenv or conda env)", + ) + ap.add_argument( + "--prefix", + help="Install to the given prefix. " + "Kernelspec will be installed in {PREFIX}/share/jupyter/kernels/", + ) args = ap.parse_args(argv) if args.sys_prefix: @@ -76,5 +83,5 @@ def main(argv=None): install_py5_kernel_spec(user=args.user, prefix=args.prefix) -if __name__ == '__main__': +if __name__ == "__main__": main() diff --git a/py5jupyter/kernels/py5/kernel.py b/py5jupyter/kernels/py5/kernel.py index e63a2f4..2c26a6c 100644 --- a/py5jupyter/kernels/py5/kernel.py +++ b/py5jupyter/kernels/py5/kernel.py @@ -1,7 +1,7 @@ # ***************************************************************************** # # Part of the py5jupyter (& py5) library -# Copyright (C) 2022-2023 Jim Schmitz +# Copyright (C) 2022-2024 Jim Schmitz # # This library is free software: you can redistribute it and/or modify it # under the terms of the GNU Lesser General Public License as published by @@ -30,13 +30,10 @@ from py5_tools import __version__ as __py5_version__ _PY5_HELP_LINKS = [ + {"text": "py5 Documentation", "url": "http://py5coding.org/"}, { - 'text': 'py5 Documentation', - 'url': 'http://py5coding.org/' - }, - { - 'text': 'py5 Function Reference', - 'url': 'http://py5coding.org/reference/sketch.html' + "text": "py5 Function Reference", + "url": "http://py5coding.org/reference/sketch.html", }, ] @@ -51,39 +48,50 @@ from py5_tools import sketch_portal """ -_KERNEL_STARTUP = (_MACOSX_PRE_STARTUP if sys.platform == 'darwin' else "") + _DEFAULT_STARTUP +_KERNEL_STARTUP = ( + _MACOSX_PRE_STARTUP if sys.platform == "darwin" else "" +) + _DEFAULT_STARTUP class Py5Shell(ZMQInteractiveShell): - ast_transformers = List([TransformDynamicVariablesToCalls(), Py5CodeValidation()]).tag(config=True) + ast_transformers = List( + [TransformDynamicVariablesToCalls(), Py5CodeValidation()] + ).tag(config=True) - banner2 = Unicode("py5 " + __py5_version__ + " | py5 kernel 0.1.3a0 | A Python Jupyter kernel plus py5 in imported mode").tag(config=True) + banner2 = Unicode( + "py5 " + + __py5_version__ + + " | py5 kernel 0.1.3a0 | A Python Jupyter kernel plus py5 in imported mode" + ).tag(config=True) InteractiveShellABC.register(Py5Shell) class Py5Kernel(IPythonKernel): - shell = Instance('IPython.core.interactiveshell.InteractiveShellABC', - allow_none=True) + shell = Instance( + "IPython.core.interactiveshell.InteractiveShellABC", allow_none=True + ) shell_class = Type(Py5Shell) - help_links = List([*IPythonKernel.help_links.default(), - *_PY5_HELP_LINKS]).tag(config=True) + help_links = List([*IPythonKernel.help_links.default(), *_PY5_HELP_LINKS]).tag( + config=True + ) - implementation = 'py5' - implementation_version = '0.1.3a0' + implementation = "py5" + implementation_version = "0.1.3a0" class Py5App(IPKernelApp): - name = 'py5-kernel' + name = "py5-kernel" - kernel_class = Type('py5jupyter.kernels.py5.Py5Kernel', - klass='ipykernel.kernelbase.Kernel').tag(config=True) + kernel_class = Type( + "py5jupyter.kernels.py5.Py5Kernel", klass="ipykernel.kernelbase.Kernel" + ).tag(config=True) - exec_lines = List(Unicode(), [ - _KERNEL_STARTUP - ]).tag(config=True) + exec_lines = List(Unicode(), [_KERNEL_STARTUP]).tag(config=True) - extensions = List(Unicode(), ['py5_tools.magics', 'py5_tools.magics.py5bot']).tag(config=True) + extensions = List(Unicode(), ["py5_tools.magics", "py5_tools.magics.py5bot"]).tag( + config=True + ) diff --git a/py5jupyter/kernels/py5bot/__init__.py b/py5jupyter/kernels/py5bot/__init__.py index 4ccad38..292b5a0 100644 --- a/py5jupyter/kernels/py5bot/__init__.py +++ b/py5jupyter/kernels/py5bot/__init__.py @@ -1,7 +1,7 @@ # ***************************************************************************** # # Part of the py5jupyter (& py5) library -# Copyright (C) 2022-2023 Jim Schmitz +# Copyright (C) 2022-2024 Jim Schmitz # # This library is free software: you can redistribute it and/or modify it # under the terms of the GNU Lesser General Public License as published by diff --git a/py5jupyter/kernels/py5bot/__main__.py b/py5jupyter/kernels/py5bot/__main__.py index d1d5090..78642f7 100644 --- a/py5jupyter/kernels/py5bot/__main__.py +++ b/py5jupyter/kernels/py5bot/__main__.py @@ -1,7 +1,7 @@ # ***************************************************************************** # # Part of the py5jupyter (& py5) library -# Copyright (C) 2022-2023 Jim Schmitz +# Copyright (C) 2022-2024 Jim Schmitz # # This library is free software: you can redistribute it and/or modify it # under the terms of the GNU Lesser General Public License as published by diff --git a/py5jupyter/kernels/py5bot/install.py b/py5jupyter/kernels/py5bot/install.py index 9f11b4a..c8b9566 100644 --- a/py5jupyter/kernels/py5bot/install.py +++ b/py5jupyter/kernels/py5bot/install.py @@ -1,7 +1,7 @@ # ***************************************************************************** # # Part of the py5jupyter (& py5) library -# Copyright (C) 2022-2023 Jim Schmitz +# Copyright (C) 2022-2024 Jim Schmitz # # This library is free software: you can redistribute it and/or modify it # under the terms of the GNU Lesser General Public License as published by @@ -29,7 +29,13 @@ kernel_json = { - "argv": [sys.executable, "-m", "py5jupyter.kernels.py5bot", "-f", "{connection_file}"], + "argv": [ + sys.executable, + "-m", + "py5jupyter.kernels.py5bot", + "-f", + "{connection_file}", + ], "display_name": "py5bot", "language": "python", } @@ -38,16 +44,15 @@ def install_py5bot_kernel_spec(user=True, prefix=None): with TemporaryDirectory() as td: os.chmod(td, 0o755) # Starts off as 700, not user readable - with open(Path(td) / 'kernel.json', 'w') as f: + with open(Path(td) / "kernel.json", "w") as f: json.dump(kernel_json, f, sort_keys=True) # Copy any resources - for file in (Path(__file__).parent / 'resources').glob('*'): + for file in (Path(__file__).parent / "resources").glob("*"): shutil.copy(file, Path(td) / file.name) - print('Installing py5bot Jupyter kernel spec') - KernelSpecManager().install_kernel_spec( - td, 'py5bot', user=user, prefix=prefix) + print("Installing py5bot Jupyter kernel spec") + KernelSpecManager().install_kernel_spec(td, "py5bot", user=user, prefix=prefix) def _is_root(): @@ -59,13 +64,21 @@ def _is_root(): def main(argv=None): ap = argparse.ArgumentParser() - ap.add_argument('--user', action='store_true', - help="Install to the per-user kernels registry. Default if not root.") - ap.add_argument('--sys-prefix', action='store_true', - help="Install to sys.prefix (e.g. a virtualenv or conda env)") - ap.add_argument('--prefix', - help="Install to the given prefix. " - "Kernelspec will be installed in {PREFIX}/share/jupyter/kernels/") + ap.add_argument( + "--user", + action="store_true", + help="Install to the per-user kernels registry. Default if not root.", + ) + ap.add_argument( + "--sys-prefix", + action="store_true", + help="Install to sys.prefix (e.g. a virtualenv or conda env)", + ) + ap.add_argument( + "--prefix", + help="Install to the given prefix. " + "Kernelspec will be installed in {PREFIX}/share/jupyter/kernels/", + ) args = ap.parse_args(argv) if args.sys_prefix: @@ -76,5 +89,5 @@ def main(argv=None): install_py5bot_kernel_spec(user=args.user, prefix=args.prefix) -if __name__ == '__main__': +if __name__ == "__main__": main() diff --git a/py5jupyter/kernels/py5bot/kernel.py b/py5jupyter/kernels/py5bot/kernel.py index 87bca10..4184357 100644 --- a/py5jupyter/kernels/py5bot/kernel.py +++ b/py5jupyter/kernels/py5bot/kernel.py @@ -1,7 +1,7 @@ # ***************************************************************************** # # Part of the py5jupyter (& py5) library -# Copyright (C) 2022-2023 Jim Schmitz +# Copyright (C) 2022-2024 Jim Schmitz # # This library is free software: you can redistribute it and/or modify it # under the terms of the GNU Lesser General Public License as published by @@ -27,20 +27,21 @@ from traitlets import Type, Instance, Unicode, List from py5_tools import split_setup -from py5_tools.parsing import TransformDynamicVariablesToCalls, Py5CodeValidation, check_for_problems +from py5_tools.parsing import ( + TransformDynamicVariablesToCalls, + Py5CodeValidation, + check_for_problems, +) from py5_tools import __version__ as __py5_version__ from . import py5bot _PY5_HELP_LINKS = [ + {"text": "py5 Documentation", "url": "http://py5coding.org/"}, { - 'text': 'py5 Documentation', - 'url': 'http://py5coding.org/' - }, - { - 'text': 'py5 Function Reference', - 'url': 'http://py5coding.org/reference/sketch.html' + "text": "py5 Function Reference", + "url": "http://py5coding.org/reference/sketch.html", }, ] @@ -48,53 +49,67 @@ class Py5BotShell(ZMQInteractiveShell): # needed to make sure code using the %%python bypass gets transformed - ast_transformers = List([TransformDynamicVariablesToCalls(), Py5CodeValidation()]).tag(config=True) + ast_transformers = List( + [TransformDynamicVariablesToCalls(), Py5CodeValidation()] + ).tag(config=True) def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self._py5bot_mgr = py5bot.Py5BotManager() - banner2 = Unicode("py5 " + __py5_version__ + " | py5bot kernel 0.1.3a0 | A static drawing environment for py5").tag(config=True) + banner2 = Unicode( + "py5 " + + __py5_version__ + + " | py5bot kernel 0.1.3a0 | A static drawing environment for py5" + ).tag(config=True) def run_cell(self, raw_cell, *args, **kwargs): # check for special code that should bypass py5bot processing - if raw_cell.strip().startswith('%%python\n'): - return super(Py5BotShell, self).run_cell(raw_cell.replace('%%python\n', ''), *args, **kwargs) + if raw_cell.strip().startswith("%%python\n"): + return super(Py5BotShell, self).run_cell( + raw_cell.replace("%%python\n", ""), *args, **kwargs + ) - success, result = check_for_problems(raw_cell, "", tool='py5bot') + success, result = check_for_problems(raw_cell, "", tool="py5bot") if success: py5bot_globals, py5bot_settings, py5bot_setup = result if split_setup.count_noncomment_lines(py5bot_settings) == 0: - py5bot_settings = 'size(100, 100, HIDDEN)' + py5bot_settings = "size(100, 100, HIDDEN)" self._py5bot_mgr.write_code(py5bot_globals, py5bot_settings, py5bot_setup) - return super(Py5BotShell, self).run_cell(self._py5bot_mgr.run_code, *args, **kwargs) + return super(Py5BotShell, self).run_cell( + self._py5bot_mgr.run_code, *args, **kwargs + ) else: print(result, file=sys.stderr) - return super(Py5BotShell, self).run_cell('None', *args, **kwargs) + return super(Py5BotShell, self).run_cell("None", *args, **kwargs) + InteractiveShellABC.register(Py5BotShell) class Py5BotKernel(IPythonKernel): - shell = Instance('IPython.core.interactiveshell.InteractiveShellABC', - allow_none=True) + shell = Instance( + "IPython.core.interactiveshell.InteractiveShellABC", allow_none=True + ) shell_class = Type(Py5BotShell) - help_links = List([*IPythonKernel.help_links.default(), - *_PY5_HELP_LINKS]).tag(config=True) + help_links = List([*IPythonKernel.help_links.default(), *_PY5_HELP_LINKS]).tag( + config=True + ) - implementation = 'py5bot' - implementation_version = '0.1.3a0' + implementation = "py5bot" + implementation_version = "0.1.3a0" class Py5BotApp(IPKernelApp): - name = 'py5bot-kernel' + name = "py5bot-kernel" - kernel_class = Type('py5jupyter.kernels.py5bot.Py5BotKernel', - klass='ipykernel.kernelbase.Kernel').tag(config=True) + kernel_class = Type( + "py5jupyter.kernels.py5bot.Py5BotKernel", klass="ipykernel.kernelbase.Kernel" + ).tag(config=True) - exec_lines = List(Unicode(), [ - '%%python\n' + py5bot.PY5BOT_CODE_STARTUP - ]).tag(config=True) + exec_lines = List(Unicode(), ["%%python\n" + py5bot.PY5BOT_CODE_STARTUP]).tag( + config=True + ) diff --git a/py5jupyter/kernels/py5bot/py5bot.py b/py5jupyter/kernels/py5bot/py5bot.py index 9d82f41..6f5b1a7 100644 --- a/py5jupyter/kernels/py5bot/py5bot.py +++ b/py5jupyter/kernels/py5bot/py5bot.py @@ -1,7 +1,7 @@ # ***************************************************************************** # # Part of the py5jupyter (& py5) library -# Copyright (C) 2022-2023 Jim Schmitz +# Copyright (C) 2022-2024 Jim Schmitz # # This library is free software: you can redistribute it and/or modify it # under the terms of the GNU Lesser General Public License as published by @@ -129,17 +129,19 @@ class Py5BotManager: def __init__(self): self.tempdir = Path(tempfile.TemporaryDirectory().name) self.tempdir.mkdir(parents=True, exist_ok=True) - self.settings_filename = self.tempdir / '_PY5_STATIC_SETTINGS_CODE_.py' - self.setup_filename = self.tempdir / '_PY5_STATIC_SETUP_CODE_.py' + self.settings_filename = self.tempdir / "_PY5_STATIC_SETTINGS_CODE_.py" + self.setup_filename = self.tempdir / "_PY5_STATIC_SETUP_CODE_.py" self.startup_code = PY5BOT_CODE_STARTUP - self.run_code = PY5BOT_CODE.format(self.settings_filename.as_posix(), self.setup_filename.as_posix()) + self.run_code = PY5BOT_CODE.format( + self.settings_filename.as_posix(), self.setup_filename.as_posix() + ) def write_code(self, global_code, settings_code, setup_code): - with open(self.settings_filename, 'w') as f: - f.write('\n' * sum(c == '\n' for c in global_code)) + with open(self.settings_filename, "w") as f: + f.write("\n" * sum(c == "\n" for c in global_code)) f.write(settings_code) - with open(self.setup_filename, 'w') as f: + with open(self.setup_filename, "w") as f: f.write(global_code) - f.write('\n' * sum(c == '\n' for c in settings_code)) + f.write("\n" * sum(c == "\n" for c in settings_code)) f.write(setup_code) diff --git a/py5jupyter/widgets/__init__.py b/py5jupyter/widgets/__init__.py index 9e6a42c..f23515e 100644 --- a/py5jupyter/widgets/__init__.py +++ b/py5jupyter/widgets/__init__.py @@ -1,7 +1,7 @@ # ***************************************************************************** # # Part of the py5jupyter (& py5) library -# Copyright (C) 2022-2023 Jim Schmitz +# Copyright (C) 2022-2024 Jim Schmitz # # This library is free software: you can redistribute it and/or modify it # under the terms of the GNU Lesser General Public License as published by diff --git a/py5jupyter/widgets/_frontend.py b/py5jupyter/widgets/_frontend.py index 307c7d5..8077dff 100644 --- a/py5jupyter/widgets/_frontend.py +++ b/py5jupyter/widgets/_frontend.py @@ -1,7 +1,7 @@ # ***************************************************************************** # # Part of the py5jupyter (& py5) library -# Copyright (C) 2022-2023 Jim Schmitz +# Copyright (C) 2022-2024 Jim Schmitz # # This library is free software: you can redistribute it and/or modify it # under the terms of the GNU Lesser General Public License as published by diff --git a/py5jupyter/widgets/sketchportal.py b/py5jupyter/widgets/sketchportal.py index dc2e678..f5be1ed 100644 --- a/py5jupyter/widgets/sketchportal.py +++ b/py5jupyter/widgets/sketchportal.py @@ -1,7 +1,7 @@ # ***************************************************************************** # # Part of the py5jupyter (& py5) library -# Copyright (C) 2022-2023 Jim Schmitz +# Copyright (C) 2022-2024 Jim Schmitz # # This library is free software: you can redistribute it and/or modify it # under the terms of the GNU Lesser General Public License as published by @@ -31,16 +31,19 @@ class Py5SketchPortal(DOMWidget): _model_module_version = Unicode(module_version).tag(sync=True) _view_module = Unicode(module_name).tag(sync=True) _view_module_version = Unicode(module_version).tag(sync=True) - _view_name = Unicode('Py5SketchPortalView').tag(sync=True) - _model_name = Unicode('Py5SketchPortalModel').tag(sync=True) + _view_name = Unicode("Py5SketchPortalView").tag(sync=True) + _model_name = Unicode("Py5SketchPortalModel").tag(sync=True) # Define the custom state properties to sync with the front-end value = Bytes(help="The frame image as bytes.").tag(sync=True) random_number = CUnicode(help="random number to force change event").tag(sync=True) - width = CUnicode(help="Width of the image in pixels. Use layout.width " - "for styling the widget.").tag(sync=True) - height = CUnicode(help="Height of the image in pixels. Use layout.height " - "for styling the widget.").tag(sync=True) + width = CUnicode( + help="Width of the image in pixels. Use layout.width " "for styling the widget." + ).tag(sync=True) + height = CUnicode( + help="Height of the image in pixels. Use layout.height " + "for styling the widget." + ).tag(sync=True) def __init__(self, sketch, w, h, *args, **kwargs): super(Py5SketchPortal, self).__init__(*args, **kwargs) @@ -64,39 +67,90 @@ def _handle_frontend_event(self, _, content, buffers): event_mod = content.get("mod", 0) is_gl = self._sketch.get_graphics()._instance.isGL() - if event_type.startswith('mouse'): - event_button = bool((b := content.get("buttons", 0)) & 1) * py5.LEFT or bool(b & 4) * py5.CENTER or bool(b & 2) * py5.RIGHT + if event_type.startswith("mouse"): + event_button = ( + bool((b := content.get("buttons", 0)) & 1) * py5.LEFT + or bool(b & 4) * py5.CENTER + or bool(b & 2) * py5.RIGHT + ) if event_type == "mouse_enter": - self._sketch._instance.fakeMouseEvent(Py5MouseEvent.ENTER, event_mod, event_x, event_y, event_button, 0) + self._sketch._instance.fakeMouseEvent( + Py5MouseEvent.ENTER, event_mod, event_x, event_y, event_button, 0 + ) elif event_type == "mouse_down": self._note_mouse_down(event_button) - self._sketch._instance.fakeMouseEvent(Py5MouseEvent.PRESS, event_mod, event_x, event_y, event_button, self._click_count) + self._sketch._instance.fakeMouseEvent( + Py5MouseEvent.PRESS, + event_mod, + event_x, + event_y, + event_button, + self._click_count, + ) elif event_type == "mouse_move": if event_button: - self._sketch._instance.fakeMouseEvent(Py5MouseEvent.DRAG, event_mod, event_x, event_y, event_button, 1 if is_gl else 0) + self._sketch._instance.fakeMouseEvent( + Py5MouseEvent.DRAG, + event_mod, + event_x, + event_y, + event_button, + 1 if is_gl else 0, + ) else: - self._sketch._instance.fakeMouseEvent(Py5MouseEvent.MOVE, event_mod, event_x, event_y, event_button, 0) + self._sketch._instance.fakeMouseEvent( + Py5MouseEvent.MOVE, event_mod, event_x, event_y, event_button, 0 + ) elif event_type == "mouse_up": - self._sketch._instance.fakeMouseEvent(Py5MouseEvent.RELEASE, event_mod, event_x, event_y, self._last_event_button, self._click_count) + self._sketch._instance.fakeMouseEvent( + Py5MouseEvent.RELEASE, + event_mod, + event_x, + event_y, + self._last_event_button, + self._click_count, + ) elif event_type == "mouse_leave": - self._sketch._instance.fakeMouseEvent(Py5MouseEvent.EXIT, event_mod, event_x, event_y, event_button, 0) + self._sketch._instance.fakeMouseEvent( + Py5MouseEvent.EXIT, event_mod, event_x, event_y, event_button, 0 + ) elif event_type == "mouse_click": - self._sketch._instance.fakeMouseEvent(Py5MouseEvent.CLICK, event_mod, event_x, event_y, self._last_event_button, self._click_count) + self._sketch._instance.fakeMouseEvent( + Py5MouseEvent.CLICK, + event_mod, + event_x, + event_y, + self._last_event_button, + self._click_count, + ) elif event_type == "mouse_wheel": event_wheel = np.sign(content.get("wheel", 0)) - self._sketch._instance.fakeMouseEvent(Py5MouseEvent.WHEEL, event_mod, event_x, event_y, event_button, event_wheel) + self._sketch._instance.fakeMouseEvent( + Py5MouseEvent.WHEEL, + event_mod, + event_x, + event_y, + event_button, + event_wheel, + ) elif event_type.startswith("key"): event_key = content.get("key", "") event_repeat = content.get("repeat", False) if event_type == "key_down": - self._sketch._instance.fakeKeyEvent(Py5KeyEvent.PRESS, event_mod, event_key, event_repeat) + self._sketch._instance.fakeKeyEvent( + Py5KeyEvent.PRESS, event_mod, event_key, event_repeat + ) elif event_type == "key_press": - self._sketch._instance.fakeKeyEvent(Py5KeyEvent.TYPE, event_mod, event_key, event_repeat) + self._sketch._instance.fakeKeyEvent( + Py5KeyEvent.TYPE, event_mod, event_key, event_repeat + ) elif event_type == "key_up": - self._sketch._instance.fakeKeyEvent(Py5KeyEvent.RELEASE, event_mod, event_key, event_repeat) + self._sketch._instance.fakeKeyEvent( + Py5KeyEvent.RELEASE, event_mod, event_key, event_repeat + ) def _note_mouse_down(self, event_button): t = time.time() diff --git a/src/extension.ts b/src/extension.ts index 59faa9e..98f5f32 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -1,7 +1,7 @@ // ***************************************************************************** // // Part of the py5jupyter (& py5) library -// Copyright (C) 2022-2023 Jim Schmitz +// Copyright (C) 2022-2024 Jim Schmitz // // This library is free software: you can redistribute it and/or modify it // under the terms of the GNU Lesser General Public License as published by diff --git a/src/index.ts b/src/index.ts index f798d0f..d887be1 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,7 +1,7 @@ // ***************************************************************************** // // Part of the py5jupyter (& py5) library -// Copyright (C) 2022-2023 Jim Schmitz +// Copyright (C) 2022-2024 Jim Schmitz // // This library is free software: you can redistribute it and/or modify it // under the terms of the GNU Lesser General Public License as published by diff --git a/src/plugin.ts b/src/plugin.ts index 0955a96..784854b 100644 --- a/src/plugin.ts +++ b/src/plugin.ts @@ -1,7 +1,7 @@ // ***************************************************************************** // // Part of the py5jupyter (& py5) library -// Copyright (C) 2022-2023 Jim Schmitz +// Copyright (C) 2022-2024 Jim Schmitz // // This library is free software: you can redistribute it and/or modify it // under the terms of the GNU Lesser General Public License as published by diff --git a/src/utils.ts b/src/utils.ts index 829acac..cf26700 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -1,7 +1,7 @@ // ***************************************************************************** // // Part of the py5jupyter (& py5) library -// Copyright (C) 2022-2023 Jim Schmitz +// Copyright (C) 2022-2024 Jim Schmitz // // This library is free software: you can redistribute it and/or modify it // under the terms of the GNU Lesser General Public License as published by diff --git a/src/version.ts b/src/version.ts index 75b7362..19687a3 100644 --- a/src/version.ts +++ b/src/version.ts @@ -1,7 +1,7 @@ // ***************************************************************************** // // Part of the py5jupyter (& py5) library -// Copyright (C) 2022-2023 Jim Schmitz +// Copyright (C) 2022-2024 Jim Schmitz // // This library is free software: you can redistribute it and/or modify it // under the terms of the GNU Lesser General Public License as published by diff --git a/src/widget.ts b/src/widget.ts index 8abe1fd..b1e5488 100644 --- a/src/widget.ts +++ b/src/widget.ts @@ -1,7 +1,7 @@ // ***************************************************************************** // // Part of the py5jupyter (& py5) library -// Copyright (C) 2022-2023 Jim Schmitz +// Copyright (C) 2022-2024 Jim Schmitz // // This library is free software: you can redistribute it and/or modify it // under the terms of the GNU Lesser General Public License as published by