Skip to main content

A GTK inspired widget engine using curses for use with command line interfaces.

Project description

CursesMenu

PyPI GitHub release (latest by date)

Description

CursesMenu is a GTK inspired widget engine using curses for use with command line interfaces. Also inspired by the Ubuntu Live Server installation menus.

Installation

Using pip:

pip3 install cursesmenu

From source:

python3 setup.py install

Tutorial

  • Import the package into your script using:
from CursesMenu import *
  • Create a new CursesMenu object:
myMenu = CursesMenu()
  • Create widgets to add to the menu:
#Creates a text widget that gets a string of text as input from the user
textInput = CursesWidget("text", title="My Text Widget", onClose="listWidget")

#Creates a list widget that gets an index and value of a list item from the user
listInput = CursesWidget("list", title="My List Widget", items=["Item 1", "Item 2", "Item 3"])
  • Add widgets to the menu:
myMenu.addWidget(textInput, id="root")
myMenu.addWidget(listInput, id="listWidget")
  • Draw the menu using Curses:
myMenu.draw()

Documentation

CursesMenu()

  • Menu object to handle widgets and drawing with curses.

Methods

  • CursesMenu.addWidget(widget, margin=0, id=None)
    • Adds a widget to the menu.
    • widget: An instance of CursesWidget to add to the menu.
    • margin: Empty space around the widget. Defaults to 0.
    • id: Identification for use with the onClose property of CursesWidget and also for CursesMenu.draw().
  • CursesMenu.quit()
    • Exits curses in the menu. Intended for use within CursesMenu class.
  • CursesMenu.widgetHandler(widget)
    • Drawing process for the menu. Intended for use within CursesMenu class.
    • widget: Widget for the handler to draw.
  • CursesMenu.draw(startWidget="root", inputWin=None)
    • Initiates curses and hands off execution to CursesMenu.widgetHandler().
    • startWidget: ID of the widget to start drawing. Defaults to "root".
    • inputWin: Curses window object to use for drawing to. Indtended for use with curses.wrapper(), but can be used outside of curses.wrapper(). Defaults to None.

Properties

  • CursesMenu.widgets
    • Python dictionary of widgets with their respective ID's.

CursesWidget(type, title="", onClose=None, items=[], hide=False)

  • Widget object to handle associated data with a widget.
  • type: Type of widget to create. Accepts "text" and "list".
  • title: String to display above widget. Defaults to an empty string.
  • onClose: String with the ID of a widget added to the same menu to go to after drawing the current widget. Defaults to None.
  • items: For use with "list" widget. A Python list of items to be displayed. Converted to strings when displayed. Defaults to an empty list.
  • hide: Boolean value for whether to hide input. Replaces text input for asterisks if set to True. Defaults to False.

Properties

  • CursesWidget.type
    • Parameter of original object.
  • CursesWidget.title
    • Parameter of original object.
  • CursesWidget.id
    • Parameter of original object.
  • CursesWidget.onClose
    • Parameter of original object.
  • CursesWidget.hide
    • Parameter of original object.
  • CursesWidget.data
    • items parameter of original object.
  • CursesWidget.value
    • Dependent on CursesWidget.type. If CursesWidget.type == "text", CursesWidget.value = {"text": ""}. If CursesWidget.type == "list", CursesWidget.value = {"text": "", "index": 0}. Updated during CursesMenu.widgetHandler().

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

CursesMenu-0.0.1a0.tar.gz (4.3 kB view details)

Uploaded Source

Built Distribution

CursesMenu-0.0.1a0-py3-none-any.whl (16.7 kB view details)

Uploaded Python 3

File details

Details for the file CursesMenu-0.0.1a0.tar.gz.

File metadata

  • Download URL: CursesMenu-0.0.1a0.tar.gz
  • Upload date:
  • Size: 4.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/42.0.1 requests-toolbelt/0.9.1 tqdm/4.39.0 CPython/3.6.9

File hashes

Hashes for CursesMenu-0.0.1a0.tar.gz
Algorithm Hash digest
SHA256 527cb695e9c81910a314af22c1ae4f3ae950af9d7ab4eeaa084bdc36892d9a99
MD5 5c8a61bed00c570688080797f73e2837
BLAKE2b-256 a3d979e771b06cb1d2cf4d4ee8ae46c51daea779e4b289b2681482c40052b407

See more details on using hashes here.

File details

Details for the file CursesMenu-0.0.1a0-py3-none-any.whl.

File metadata

  • Download URL: CursesMenu-0.0.1a0-py3-none-any.whl
  • Upload date:
  • Size: 16.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/42.0.1 requests-toolbelt/0.9.1 tqdm/4.39.0 CPython/3.6.9

File hashes

Hashes for CursesMenu-0.0.1a0-py3-none-any.whl
Algorithm Hash digest
SHA256 110dc70b1e0de56ba520884aa2e3e78681f50af20ea426501340f2c7e8de2098
MD5 097ce5730f1351f5f9dffa8d2e5c8329
BLAKE2b-256 befd3d000bcf769586a8aa8d48396b954f4d745203e70bd13d6981c90adb7962

See more details on using hashes here.

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