Skip to content

Commit

Permalink
Added LuminoWidgetConnectionModel to represent a link to a LuminoWidget.
Browse files Browse the repository at this point in the history
Renamed some Python only methods to snake_case.
Added javascript setNestedAttribute.
Change IpylabModel to extend from WidgetModel rather than DOMWidgetModel.
  • Loading branch information
Alan Fleming committed Aug 19, 2024
1 parent 2fc3f6d commit 3a27391
Show file tree
Hide file tree
Showing 23 changed files with 368 additions and 180 deletions.
8 changes: 4 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ default_language_version:
node: system
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
rev: v4.6.0
hooks:
- id: check-case-conflict
- id: check-ast
Expand All @@ -30,23 +30,23 @@ repos:
hooks:
- id: check-json5
- repo: https://github.com/python-jsonschema/check-jsonschema
rev: 0.28.1
rev: 0.29.1
hooks:
- id: check-github-workflows
- repo: https://github.com/ComPWA/mirrors-taplo
rev: 'v0.8.1'
hooks:
- id: taplo
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.3.5
rev: v0.6.1
hooks:
- id: ruff
types_or: [python, jupyter]
args: ['--fix']
- id: ruff-format
types_or: [python, jupyter]
- repo: https://github.com/codespell-project/codespell
rev: 'v2.2.6'
rev: 'v2.3.0'
hooks:
- id: codespell
additional_dependencies:
Expand Down
8 changes: 4 additions & 4 deletions examples/autostart.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@
" console_button.on_click(\n",
" lambda _: ma.load_console(name=\"console\") if ma.console_status == \"unloaded\" else ma.unload_console()\n",
" )\n",
" error_button.on_click(lambda _: ma.executeCommand(\"Not a command\"))\n",
" error_button.on_click(lambda _: ma.execute_command(\"Not a command\"))\n",
" console_status = ipw.HTML()\n",
" ipw.dlink((ma, \"console_status\"), (console_status, \"value\"))\n",
" ma.content.children = [\n",
Expand Down Expand Up @@ -138,7 +138,7 @@
" path=path,\n",
" )\n",
" if launcher_id:\n",
" await app.executeMethod(widget=launcher_id, method=\"dispose\")\n",
" await app.execute_method(widget=launcher_id, method=\"dispose\")\n",
"\n",
"\n",
"async def register_commands():\n",
Expand Down Expand Up @@ -180,7 +180,7 @@
"metadata": {},
"outputs": [],
"source": [
"t = app.executeCommand(\"launcher:create\")"
"t = app.execute_command(\"launcher:create\")"
]
}
],
Expand All @@ -200,7 +200,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.9"
"version": "3.10.14"
}
},
"nbformat": 4,
Expand Down
10 changes: 5 additions & 5 deletions examples/commands.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@
"metadata": {},
"outputs": [],
"source": [
"t = app.executeCommand(\n",
"t = app.execute_command(\n",
" \"console:create\",\n",
" insertMode=\"split-right\",\n",
" kernelPreference={\"id\": app.kernelId},\n",
Expand Down Expand Up @@ -104,7 +104,7 @@
"metadata": {},
"outputs": [],
"source": [
"app.executeCommand(\"apputils:change-theme\", theme=\"JupyterLab Dark\")"
"app.execute_command(\"apputils:change-theme\", theme=\"JupyterLab Dark\")"
]
},
{
Expand All @@ -113,7 +113,7 @@
"metadata": {},
"outputs": [],
"source": [
"t = app.executeCommand(\"apputils:change-theme\", theme=\"JupyterLab Light\")"
"t = app.execute_command(\"apputils:change-theme\", theme=\"JupyterLab Light\")"
]
},
{
Expand All @@ -138,7 +138,7 @@
"metadata": {},
"outputs": [],
"source": [
"app.executeCommand(\"terminal:create-new\")\n",
"app.execute_command(\"terminal:create-new\")\n",
"# It can take up to 10 seconds for the terminal to show up after the cell returns."
]
},
Expand Down Expand Up @@ -225,7 +225,7 @@
"metadata": {},
"outputs": [],
"source": [
"t = app.executeCommand(\"swap_orientation\", transform=ipylab.TransformMode.raw)"
"t = app.execute_command(\"swap_orientation\", transform=ipylab.TransformMode.raw)"
]
},
{
Expand Down
22 changes: 11 additions & 11 deletions examples/generic.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@
"In cases where a method hasn't been implemented in the Python `JupyterFrontEnd`, it may be possible to perform the operation using one of the generic functions.\n",
"\n",
"* schedule_operation('FE_execute', ...)\n",
"* executeMethod\n",
"* listAttributes - to list available attributes\n",
"* listMethods (listAttributes tweaked to list only the methods)\n",
"* execute_method\n",
"* list_attributes - to list available attributes\n",
"* list_methods (list_attributes tweaked to list only the methods)\n",
"* get_attribute"
]
},
Expand Down Expand Up @@ -50,7 +50,7 @@
"metadata": {},
"outputs": [],
"source": [
"t = app.listMethods(\"app.shell\", depth=2)"
"t = app.list_methods(\"app.shell\", depth=2)"
]
},
{
Expand All @@ -67,7 +67,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"Some of the methods above have already been implemented in 'app.shell' on the Python object. And if you look at the code you'll see these methods use the *generic* method (technically, it is a subclass which inserts `'shell.'` in front of the path in the method `executeMethod` to match it's level in the JupyterFrontend Object. So basically the same function call is sent to the frontend.\n",
"Some of the methods above have already been implemented in 'app.shell' on the Python object. And if you look at the code you'll see these methods use the *generic* method (technically, it is a subclass which inserts `'shell.'` in front of the path in the method `execute_method` to match it's level in the JupyterFrontend Object. So basically the same function call is sent to the frontend.\n",
"\n",
"In case you're interested, the custom part of message sent to the frontend looks like this:\n",
"\n",
Expand All @@ -76,7 +76,7 @@
" \"ipylab_BE\": \"83a513b1-0ab3-443f-9521-b740be0b8cd3, # unique per message\n",
" \"operation\": \"FE_execute\",\n",
" \"kwgs\": {\n",
" \"FE_execute\": {\"mode\": \"executeMethod\", \"kwgs\": {\"method\": \"listAttributes\"}},\n",
" \"FE_execute\": {\"mode\": \"execute_method\", \"kwgs\": {\"method\": \"list_attributes\"}},\n",
" \"args\": (\"app.shell\", \"function\", 2),\n",
" },\n",
" \"transform\": \"raw\",\n",
Expand Down Expand Up @@ -123,7 +123,7 @@
"metadata": {},
"outputs": [],
"source": [
"t = app.executeMethod(\"shell.collapseLeft\") # Generic"
"t = app.execute_method(\"shell.collapseLeft\") # Generic"
]
},
{
Expand All @@ -150,7 +150,7 @@
"metadata": {},
"outputs": [],
"source": [
"t = app.listAttributes(depth=2)"
"t = app.list_attributes(depth=2)"
]
},
{
Expand All @@ -169,7 +169,7 @@
"metadata": {},
"outputs": [],
"source": [
"t = app.listAttributes(\"app.shell\", depth=2)"
"t = app.list_attributes(\"app.shell\", depth=2)"
]
},
{
Expand Down Expand Up @@ -197,7 +197,7 @@
"metadata": {},
"outputs": [],
"source": [
"t = app.listAttributes(widget=widget)"
"t = app.list_attributes(widget=widget)"
]
},
{
Expand All @@ -215,7 +215,7 @@
"metadata": {},
"outputs": [],
"source": [
"t = app.getAttribute(\"views\", widget=widget)"
"t = app.get_attribute(\"views\", widget=widget)"
]
},
{
Expand Down
4 changes: 2 additions & 2 deletions examples/icons.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@
},
"outputs": [],
"source": [
"panel.app.executeCommand(\"apputils:activate-command-palette\")"
"panel.app.execute_command(\"apputils:activate-command-palette\")"
]
},
{
Expand All @@ -309,7 +309,7 @@
"metadata": {},
"outputs": [],
"source": [
"panel.app.executeCommand(\"my-icon:randomize\", count=1)"
"panel.app.execute_command(\"my-icon:randomize\", count=1)"
]
}
],
Expand Down
6 changes: 3 additions & 3 deletions examples/ipytree.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@
" fullpath = [*path, name]\n",
" if len(children) == 0:\n",
" leaf = TreeNode(name)\n",
" leaf.fullpath = os.path.join(*fullpath) # noqa: PTH118\n",
" leaf.fullpath = os.path.join(*fullpath)\n",
" leaf.icon = \"file\"\n",
" leaf.icon_style = \"warning\"\n",
" node.add_node(leaf)\n",
Expand Down Expand Up @@ -315,7 +315,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"When the \"Open\" button is clicked, we call `app.executeCommand` with the path to the file to open it in the JupyterLab interface."
"When the \"Open\" button is clicked, we call `app.execute_command` with the path to the file to open it in the JupyterLab interface."
]
},
{
Expand All @@ -328,7 +328,7 @@
" for node in file_tree.selected_nodes:\n",
" filepath = node.fullpath\n",
" if filepath:\n",
" app.executeCommand(\"docmanager:open\", {\"path\": filepath})\n",
" app.execute_command(\"docmanager:open\", {\"path\": filepath})\n",
"\n",
"\n",
"open_button.on_click(on_open_clicked)"
Expand Down
4 changes: 2 additions & 2 deletions examples/sessions.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@
"metadata": {},
"outputs": [],
"source": [
"app.executeCommand(\"console:create\", **app.current_session)"
"app.execute_command(\"console:create\", **app.current_session)"
]
},
{
Expand All @@ -89,7 +89,7 @@
"metadata": {},
"outputs": [],
"source": [
"app.executeCommand(\"notebook:create-console\")"
"app.execute_command(\"notebook:create-console\")"
]
},
{
Expand Down
Loading

0 comments on commit 3a27391

Please sign in to comment.