Skip to main content

Simple curses utilities

Project description

CursesUtils

Functions

menu.menu(stdscr, title, options)

Pulls up a select menu.

  • stdscr: The screen to write to.
  • title: The title of the menu.
  • options: A collection of strings to choose from.

Returns the index of the selected item, or None if the user chooses to quit.

number_select.number_select(stdscr, title, num_range, start = None)

Pulls up a number selection menu.

  • stdscr: The screen to write to.
  • title: The title of the selection.
  • num_range: A range object for valid numbers.
  • start: The starting selected number. Defaults to num_range's min value.

Returns the number selected, or None if the user chooses to quit.

keys.set_key_codes(key_name, key_codes)

Sets a key's function by name.

  • key_name: The key name to set.
  • key_codes: A collection of key codes (as returned by stdscr.getkey()) to use.

Make sure to set keys before using them! Internally, CursesUtils uses the following keys:

  • menu_up (for navigating UP through menus)
  • menu_down (for navigating DOWN through menus)
  • menu_confirm (for CONFIRMING on menus)
  • menu_cancel (for QUITTING on menus)

keys.get_key_codes(key_name)

Gets a key's codes by name.

  • key_name: The key name to get the codes of.

Returns the key codes of the given key, or None if it doesn't exist. See set_key_codes for more information.

keys.get_next_key(stdscr)

Gets the next key and saves it.

  • stdscr: The screen to write to.

keys.get_current_key()

Gets the current pressed key.

keys.get_key_with_timeout(stdscr, timeout)

Waits for a timeout, returning immediately on a key. Saves the key, saving None if no key was pressed.

  • stdscr: The screen to write to.
  • timeout: The timeout in milliseconds.

keys.wait_for_key(stdscr)

Waits for a key, but doesn't consume it.

  • stdscr: The screen to write to.

keys.is_pressed(key_name)

Checks if the given key is the current pressed key by name.

  • key_name: The key name to check.

wrapper.wrapper(func)

Wraps a function to set up and shut down, also wrapping using curses.wrapper.

  • func: The function to wrap.

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

curses_utils-0.0.13.tar.gz (3.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

curses_utils-0.0.13-py3-none-any.whl (4.6 kB view details)

Uploaded Python 3

File details

Details for the file curses_utils-0.0.13.tar.gz.

File metadata

  • Download URL: curses_utils-0.0.13.tar.gz
  • Upload date:
  • Size: 3.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/3.10.1 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.8.12

File hashes

Hashes for curses_utils-0.0.13.tar.gz
Algorithm Hash digest
SHA256 d4a361b8df72dfca304502d5a63235e9b6943f6e188ea0eded35b0c6f20623cd
MD5 6044baa51e109caffd9421a292504f6f
BLAKE2b-256 5a0fa9129e55a5b32c4b5765d051f3ec6218750cb4488f152025d23851c5dd92

See more details on using hashes here.

File details

Details for the file curses_utils-0.0.13-py3-none-any.whl.

File metadata

  • Download URL: curses_utils-0.0.13-py3-none-any.whl
  • Upload date:
  • Size: 4.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/3.10.1 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.2 CPython/3.8.12

File hashes

Hashes for curses_utils-0.0.13-py3-none-any.whl
Algorithm Hash digest
SHA256 0aec9e059c42c1d12ce140c43198903e7b13cd2768e220be90087d0bdf5a13e0
MD5 2e53648f6ee1dc8eb474323610be5010
BLAKE2b-256 a2390cfbde60c5404794d9de7730e0e2f55099734c36abaaacf1dc30670730f0

See more details on using hashes here.

Supported by

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