Skip to content

Commit

Permalink
Switch to DocumentWidget
Browse files Browse the repository at this point in the history
  • Loading branch information
Alan Fleming committed Nov 8, 2024
1 parent a45fdf6 commit 8c62077
Show file tree
Hide file tree
Showing 21 changed files with 432 additions and 317 deletions.
11 changes: 11 additions & 0 deletions examples/commands.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,17 @@
"source": [
"cmd.close()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Other command registries\n",
"\n",
"It is also possible to create command registries separate to the Jupyterlab command registry.\n",
"\n",
"See [menu->limiting scope](menu.ipynb#Limiting-scope) for an example using one."
]
}
],
"metadata": {
Expand Down
88 changes: 46 additions & 42 deletions examples/dialogs.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -198,37 +198,39 @@
"t = app.dialog.show_dialog(\n",
" \"A custom dialog\",\n",
" \"It returns the raw result, and there is no cancellation\",\n",
" buttons=[\n",
" {\n",
" \"ariaLabel\": \"Accept\",\n",
" \"label\": \"Accept\",\n",
" \"iconClass\": \"\",\n",
" \"iconLabel\": \"\",\n",
" \"caption\": \"Accept the result\",\n",
" \"className\": \"\",\n",
" \"accept\": \"accept\",\n",
" \"actions\": [],\n",
" \"displayType\": \"warn\",\n",
" options={\n",
" \"buttons\": [\n",
" {\n",
" \"ariaLabel\": \"Accept\",\n",
" \"label\": \"Accept\",\n",
" \"iconClass\": \"\",\n",
" \"iconLabel\": \"\",\n",
" \"caption\": \"Accept the result\",\n",
" \"className\": \"\",\n",
" \"accept\": \"accept\",\n",
" \"actions\": [],\n",
" \"displayType\": \"warn\",\n",
" },\n",
" {\n",
" \"ariaLabel\": \"Cancel\",\n",
" \"label\": \"Cancel\",\n",
" \"iconClass\": \"\",\n",
" \"iconLabel\": \"\",\n",
" \"caption\": \"\",\n",
" \"className\": \"\",\n",
" \"accept\": \"cancel\",\n",
" \"actions\": [],\n",
" \"displayType\": \"default\",\n",
" },\n",
" ],\n",
" \"checkbox\": { # Optional checkbox in the dialog footer\n",
" \"label\": \"check me\", # Checkbox label\n",
" \"caption\": \"check me I'm magic\", # Checkbox tooltip\n",
" \"className\": \"my-checkbox\", # Additional checkbox CSS class\n",
" \"checked\": True, # Default checkbox state\n",
" },\n",
" {\n",
" \"ariaLabel\": \"Cancel\",\n",
" \"label\": \"Cancel\",\n",
" \"iconClass\": \"\",\n",
" \"iconLabel\": \"\",\n",
" \"caption\": \"\",\n",
" \"className\": \"\",\n",
" \"accept\": \"cancel\",\n",
" \"actions\": [],\n",
" \"displayType\": \"default\",\n",
" },\n",
" ],\n",
" checkbox={ # Optional checkbox in the dialog footer\n",
" \"label\": \"check me\", # Checkbox label\n",
" \"caption\": \"check me I'm magic\", # Checkbox tooltip\n",
" \"className\": \"my-checkbox\", # Additional checkbox CSS class\n",
" \"checked\": True, # Default checkbox state\n",
" \"hasClose\": False,\n",
" },\n",
" hasClose=False,\n",
")"
]
},
Expand Down Expand Up @@ -266,19 +268,21 @@
"t = app.dialog.show_error_message(\n",
" \"My error\",\n",
" \"Please acknowledge\",\n",
" buttons=[\n",
" {\n",
" \"ariaLabel\": \"Accept\",\n",
" \"label\": \"Accept\",\n",
" \"iconClass\": \"\",\n",
" \"iconLabel\": \"\",\n",
" \"caption\": \"Accept the result\",\n",
" \"className\": \"\",\n",
" \"accept\": \"accept\",\n",
" \"actions\": [],\n",
" \"displayType\": \"warn\",\n",
" }\n",
" ],\n",
" options={\n",
" \"buttons\": [\n",
" {\n",
" \"ariaLabel\": \"Accept\",\n",
" \"label\": \"Accept\",\n",
" \"iconClass\": \"\",\n",
" \"iconLabel\": \"\",\n",
" \"caption\": \"Accept the result\",\n",
" \"className\": \"\",\n",
" \"accept\": \"accept\",\n",
" \"actions\": [],\n",
" \"displayType\": \"warn\",\n",
" }\n",
" ],\n",
" },\n",
")"
]
},
Expand Down
54 changes: 10 additions & 44 deletions examples/icons.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -258,40 +258,10 @@
"cmd = t.result()"
]
},
{
"cell_type": "markdown",
"id": "19",
"metadata": {},
"source": [
"We can use methods on `cmd` (Connection for the cmd registered in the Frontend) to add it to the command pallet, and create a launcher."
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "20",
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"t = cmd.add_to_command_pallet(\"All My Commands\", rank=1000)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "21",
"metadata": {},
"outputs": [],
"source": [
"cmd.add_launcher(\"my launcher\")"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "22",
"id": "19",
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -300,42 +270,38 @@
},
{
"cell_type": "markdown",
"id": "23",
"id": "20",
"metadata": {},
"source": [
"Then open the _Command Palette_ (keyboard shortcut is `CTRL + SHIFT + C`).\n",
"\n",
"The and _Launcher_ is `CTRL + SHIFT + L`. "
"We can use methods on `cmd` (Connection for the cmd registered in the Frontend) to add it to the command pallet, and create a launcher."
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "24",
"id": "21",
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"asyncio.get_running_loop().call_later(1, ipylab.app.commands.execute, \"apputils:activate-command-palette\")"
"t = ipylab.app.command_pallet.add(cmd, \"All My Commands\", rank=100)"
]
},
{
"cell_type": "markdown",
"id": "25",
"id": "22",
"metadata": {},
"source": [
"And run 'Randomize my icon'"
"Then open the _Command Palette_ (keyboard shortcut is `CTRL + SHIFT + C`)."
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "26",
"cell_type": "markdown",
"id": "23",
"metadata": {},
"outputs": [],
"source": [
"ipylab.app.commands.execute(cmd, {\"count\": 1})"
"And run 'Randomize my icon'"
]
}
],
Expand Down
Loading

0 comments on commit 8c62077

Please sign in to comment.