Skip to main content

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

screenshot usage

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)

Uploaded Source

Built Distribution

nicegui_command_palette-0.2.0-py3-none-any.whl (5.5 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page