All Projects ā†’ jwlodek ā†’ Py_cui

jwlodek / Py_cui

Licence: bsd-3-clause
A python library for intuitively creating CUI/TUI interfaces with widgets, inspired by gocui.

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to Py cui

Typin
Declarative framework for interactive CLI applications
Stars: āœ­ 126 (-66.84%)
Mutual labels:  terminal-based, terminal, command-line, command
Tsukae
šŸ§‘ā€šŸ’»šŸ“Š Show off your most used shell commands
Stars: āœ­ 345 (-9.21%)
Mutual labels:  terminal-based, terminal, command-line, command
Jquery.terminal
jQuery Terminal Emulator - JavaScript library for creating web-based terminals with custom commands
Stars: āœ­ 2,623 (+590.26%)
Mutual labels:  terminal, command-line, command, tui
Spotui
Spotify in the terminal šŸ’»šŸŽ¶
Stars: āœ­ 302 (-20.53%)
Mutual labels:  terminal-based, terminal, tui
Mandown
man-page inspired Markdown viewer
Stars: āœ­ 173 (-54.47%)
Mutual labels:  terminal, command-line, tui
Goaccess
GoAccess is a real-time web log analyzer and interactive viewer that runs in a terminal in *nix systems or through your browser.
Stars: āœ­ 14,096 (+3609.47%)
Mutual labels:  terminal, command-line, tui
Ftxui
šŸ’» C++ Functional Terminal User Interface. ā¤ļø
Stars: āœ­ 433 (+13.95%)
Mutual labels:  terminal-based, terminal, tui
Pxltrm
šŸ–Œļø pxltrm - [WIP] A pixel art editor inside the terminal
Stars: āœ­ 459 (+20.79%)
Mutual labels:  commandline-interface, terminal, tui
Castero
TUI podcast client for the terminal
Stars: āœ­ 375 (-1.32%)
Mutual labels:  terminal, command-line, tui
Jexer
Java Text User Interface
Stars: āœ­ 174 (-54.21%)
Mutual labels:  terminal-based, terminal, tui
Sad
CLI search and replace | Space Age seD
Stars: āœ­ 350 (-7.89%)
Mutual labels:  terminal, command-line, tui
Smenu
smenu started as a lightweight and flexible terminal menu generator, but quickly evolved into a powerful and versatile CLI selection tool for interactive or scripting use.
Stars: āœ­ 1,906 (+401.58%)
Mutual labels:  terminal, command-line, tui
Nnn
nĀ³ The unorthodox terminal file manager
Stars: āœ­ 13,138 (+3357.37%)
Mutual labels:  terminal, command-line, tui
Mitype
Typing speed test in terminal
Stars: āœ­ 241 (-36.58%)
Mutual labels:  terminal-based, terminal, command-line
Rtv
Browse Reddit from your terminal
Stars: āœ­ 4,558 (+1099.47%)
Mutual labels:  terminal, command-line, tui
Sty
String styling for your terminal.
Stars: āœ­ 129 (-66.05%)
Mutual labels:  terminal-based, terminal, command-line
Ox
An independent Rust text editor that runs in your terminal!
Stars: āœ­ 2,634 (+593.16%)
Mutual labels:  terminal-based, terminal, tui
Moe
A command line based editor inspired by vi/vim. Written in Nim.
Stars: āœ­ 252 (-33.68%)
Mutual labels:  terminal-based, command-line, tui
Pastel
A command-line tool to generate, analyze, convert and manipulate colors
Stars: āœ­ 3,742 (+884.74%)
Mutual labels:  terminal, command-line
Fff
šŸ“ A simple file manager written in bash.
Stars: āœ­ 3,445 (+806.58%)
Mutual labels:  terminal, tui
PyCUI


A library for creating CUI/TUI interfaces with pre-built widgets in python.

Easily build text-based user interfaces on both Linux and Windows.

Automated Test+Build Status Download Counter PyPI Version License

py_cui

py_cui is a python library meant to simplify writing command line user interfaces in python. It relies on curses for terminal rendering, which is traditionally a unix-specific, however, you may use the windows-curses module to run py_cui on windows.

The main advantage py_cui has over typical text-based user interface builders is that it relies on widgets and a grid layout manager like most traditional graphical user interfaces. You may define a grid size, and then drop predefined widgets onto it into specific grid locations. Widgets can also be stretched accross multiple grid rows and columns. If you've ever made a Tkinter GUI, you will feel right at home.

If you would like to contribute, feel free to make an issue or pull request after reading through the CONTRIBUTING.md file.

Installation

You may install py_cui via pip (use pip3 if python 2 and 3 are installed side by side)

pip install py-cui

Make sure to run as root/sudo as required. Note that the library is titled py_cui, but the name of the pypi package is py-cui, though in most cases, installing with

pip install py_cui

should work OK.

If you would like to use py_cui directly from source, clone this repository with:

git clone https://github.com/jwlodek/py_cui

Then build/install with pip:

cd py_cui
pip install .

If you would like to try it out without installing, first make sure that curses is installed (windows-curses if on windows), and then copy one of the example files into the top directory. You may then simply run it with python3.

Examples

Below are some screenshots and gifs of programs written with py_cui. Additional (simpler) examples are available in the examples/ directory of this repository.

py_cui_2048 - A command line version of the classic 2048 game

py_cui_2048 is a demo of using py_cui to build simple CUI games and applications. The entire game was made in under 400 lines of code.

unipkg - A command line utility that will allow for managing all installed package managers on your system through one cli interface

unipkg is currently an in-progress project, check back in the future to see a screenshot, and more information.

pyautogit - A command line interface for managing git repositories

pyautogit is the first larger scale project written in py_cui. Feel free to use it as a guide to programming with py_cui.

Getting started

The easiest way to get set up for developing a full py_cui application is to use the available cookiecutter template. First, install the cookiecutter tool:

pip install cookiecutter

Once it is installed, navigate to the directory in which you would like your projects to live, and run:

cookiecutter https://github.com/jwlodek/py_cui_cookiecutter

This will clone the template, and show prompts for several variables, including project name and description, as well as some developer information. Once it is done, you can enter your project directory, install it with pip, and run it, and you should be able to see a Hello World example:

cd myproject
pip install .
myproject

You are now ready to extend this template for your own application!

Writing a PyCUI

Basic usage of py_cui starts with creating a PyCUI object, and specifiying it's grid size. Keep in mind that grid cell height and width will be measured in terminal characters, not pixels, so there is a lower limit on legal grid size, and heights will be smaller values than widths. Create this object with:

root = py_cui.PyCUI(7, 9)

The above line will create a UI with 7 rows and 9 columns. Then, add widgets with the different add commands:

label = root.add_label('Label Text', 0, 0)
button = root.add_button('Button Text', 1, 2, column_span=2, command=my_function)
...

Finally, start the CUI with

root.start()

py_cui has support for custom key bindings for both the overview mode and focused mode, popup windows and prompts, color rendering rules, and several useful widgets. For more details on writing py_cui based interfaces, be sure to check on the examples and the documentation here.

Using a PyCUI

There are some basic rules that apply to all py_cui based interfaces. There are three key operating modes - overview mode, focus mode, and popup mode.

Overview Mode

Overview mode is the main control view of the interface. In this mode you use the arrow keys to move between widgets, and you may select widgets with the Enter key. By default, you may also press buttons in this mode, unless auto_focus_buttons is set to false when the CUI was created.

Focus Mode

When in focus mode, you enter into a particular widget (For example a text box.). Each widget has some predefined basic controls, such as arrow keys to scroll in a ScrollMenu. You may also add keybindings to functions for each particular widget. These keybindings will only apply to a widget if it is in focus mode. Enter focus mode by navigating to a widget in overview mode and hitting the Enter key. Return to overview mode from focus mode by pressing Escape.

Popup Mode

Popup mode simply displays a popup over the rest of the UI. Each popup type behaves slightly differently. For example, you may exit an info popup mode by pressing Space, Enter, or Escape, while a loading popup will remain onscreen until whatever operation is being run is terminated.

Unit Tests

py_cui unit tests are written for pytest. Make sure pytest is installed, and simply run

pytest

in the root directory to run all unit tests.

Powered by py_cui

Below is a table of python projects developed with the help of py_cui. If you've made something, feel free to make a pull request to add it!

Project Description
pypodcasts A TUI for listening to and managing podcast feeds. (Coming Soon)
pyautogit A command line UI for interfacing with git features for multiple repositories.
recoverpy A CUI for recovering overwritten or deleted data on linux.
py_cui_2048 A CUI version of the classic 2048 game.
unipkg A CUI interface for managing all installed package managers on your system. (In-Progress)
CUIAudioPlayer A TUI for playing back audio files in a variety of formats.
tinypub A console-based ebook reader.
hue-tui A CUI controlling for Philips Hue lights.
mini-radio-player A terminal based radio interface for linux.

License

BSD 3-Clause License

Copyright (c) 2019-2020, Jakub Wlodek

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].