A GTK inspired widget engine using curses for use with command line interfaces.
Project description
CursesMenu
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
CursesMenuobject:
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
CursesWidgetto add to the menu. - margin: Empty space around the widget. Defaults to
0. - id: Identification for use with the
onCloseproperty ofCursesWidgetand also forCursesMenu.draw().
CursesMenu.quit()- Exits curses in the menu. Intended for use within
CursesMenuclass.
- Exits curses in the menu. Intended for use within
CursesMenu.widgetHandler(widget)- Drawing process for the menu. Intended for use within
CursesMenuclass. - widget: Widget for the handler to draw.
- Drawing process for the menu. Intended for use within
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 ofcurses.wrapper(). Defaults toNone.
- Initiates curses and hands off execution to
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 toFalse.
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.dataitemsparameter of original object.
CursesWidget.value- Dependent on
CursesWidget.type. IfCursesWidget.type == "text",CursesWidget.value = {"text": ""}. IfCursesWidget.type == "list",CursesWidget.value = {"text": "", "index": 0}. Updated duringCursesMenu.widgetHandler().
- Dependent on
Project details
Release history Release notifications | RSS feed
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)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
527cb695e9c81910a314af22c1ae4f3ae950af9d7ab4eeaa084bdc36892d9a99
|
|
| MD5 |
5c8a61bed00c570688080797f73e2837
|
|
| BLAKE2b-256 |
a3d979e771b06cb1d2cf4d4ee8ae46c51daea779e4b289b2681482c40052b407
|
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
110dc70b1e0de56ba520884aa2e3e78681f50af20ea426501340f2c7e8de2098
|
|
| MD5 |
097ce5730f1351f5f9dffa8d2e5c8329
|
|
| BLAKE2b-256 |
befd3d000bcf769586a8aa8d48396b954f4d745203e70bd13d6981c90adb7962
|