nicegui-command-palette
This plugin adds a command palette for NiceGUI applications.
Installation
pip install nicegui-command-palette
Usage
Register commands to the CommandPalette as a list of either strings or Command objects.
A Command can have a callback attached, which could be cleaner than checking the CommandPalette's result.
Open the CommandPalette by awaiting it. The returned value is the name of the command selected by the user, or None if they dismissed the palette without selecting anything.
from command_palette import CommandPalette, Command
def some_action():
ui.notify('User picked the third option!')
commands = [
'one',
Command('two', 'Second'),
Command('three', 'Third', cb=some_action),
]
if result := await CommandPalette(commands):
# result is the name of the user's selection, or None
ui.notify(f'Selected: {result}')
Full example:
from nicegui import ui
from nicegui.events import KeyEventArguments
from command_palette import CommandPalette, Command
async def handle_key(e: KeyEventArguments):
# open the command palette when the user presses ctrl+shift+p
if e.action.keydown and e.modifiers.ctrl and e.modifiers.shift and e.key == 'P':
commands = [
'one',
Command('two', 'Second'),
Command('three', 'Third', cb=some_action),
]
if result := await CommandPalette(commands):
ui.notify(result)
ui.keyboard(on_key=handle_key)
ui.run()
Screenshots
Todo
- highlighting substring matches like in VSCode
- additional functions like specific prompts?
- improve matching algorithm
- figure out how to use the user fixture with dialogs
Metadata
Release files for nicegui-command-palette 0.3.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| nicegui_command_palette-0.3.2.tar.gz | 1.8 MB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| nicegui_command_palette-0.3.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 1.8 MB
Release files / nicegui_command_palette-0.3.2.tar.gz
| Download URL | nicegui_command_palette-0.3.2.tar.gz |
|---|---|
| Size | 1.8 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
9abf208cb3aec754c6c01e5e075b84ff9146c81d430a2e75e9d4a1f6c75246d2
|
|
BLAKE2b-256 checksum How to use checksums |
362981d9be17f07354f4c556413558c658f825ea81db5005fcc85129699a6853
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.12.4
|
Release files / nicegui_command_palette-0.3.2-py3-none-any.whl
| Download URL | nicegui_command_palette-0.3.2-py3-none-any.whl |
|---|---|
| Size | 5.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d40c39954d5fc3d713bf551d7737f8442bd16ae878308f5081b654cabbd103ea
|
|
BLAKE2b-256 checksum How to use checksums |
90f43b23a3953442f234995911d6ce6820b56beb7ee849ad9420f3f9728f504d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.12.4
|