A command palette for NiceGUI applications
Project description
nicegui-command-palette
This plugin adds a command palette for NiceGUI applications.
Installation
pip install nicegui-command-palette
Usage
from command_palette import CommandPalette
# create the palette
cmd = CommandPalette()
# add items
cmd.add_item('one')
cmd.add_item('two')
# then open the palette by awaiting it
result = await cmd
ui.notify(result)
# OR create your options as a list
options = ['one', 'two']
# then create the palette and immediately await it
if result := await CommandPalette(options):
ui.notify(result)
# OR create your options as a dict
# return value: display value
options = {
'one': 'The First Option',
'two': 'A Second Option',
}
Full example:
from nicegui import ui
from nicegui.events import KeyEventArguments
from command_palette import CommandPalette
async def handle_key(e: KeyEventArguments):
if e.action.keydown and e.modifiers.shift and e.modifiers.ctrl and e.key == 'P':
options = ['one', 'two']
if result := await CommandPalette(options):
ui.notify(result, position='bottom-right')
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
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
nicegui_command_palette-0.2.0.tar.gz
(262.8 kB
view hashes)
Built Distribution
Close
Hashes for nicegui_command_palette-0.2.0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | a1d5ffdb13a66f665aba4cb7c25a65efcd25f35710305fbe4ddd82cdfc9c2f24 |
|
MD5 | 138a4162f9c41b1360475a7906c2706b |
|
BLAKE2b-256 | 46916156af72859f902e6c79aa869a2d8127e5fa475c01fb2b524143e7bf3fa6 |
Close
Hashes for nicegui_command_palette-0.2.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e56cd1cabdee870be8770329bfce3112bfd280fd08ae0f4c462ce7ae65edfa6b |
|
MD5 | eb7641f884f5135c569d380fd849570d |
|
BLAKE2b-256 | d66ce1264169bd6fc01bb9e43c1e1270ad0417df9fa88765c73cd7bc657362b3 |