{"id":13821042,"url":"https://github.com/jwlodek/py_cui","last_synced_at":"2025-05-14T14:09:03.407Z","repository":{"id":40465317,"uuid":"202261583","full_name":"jwlodek/py_cui","owner":"jwlodek","description":"A python library for intuitively creating CUI/TUI interfaces with widgets, inspired by gocui.","archived":false,"fork":false,"pushed_at":"2024-12-30T15:59:56.000Z","size":20647,"stargazers_count":763,"open_issues_count":49,"forks_count":43,"subscribers_count":13,"default_branch":"master","last_synced_at":"2025-04-20T15:52:40.612Z","etag":null,"topics":["command","command-line","commandline-interface","cui","python","python-library","terminal","terminal-based","tui"],"latest_commit_sha":null,"homepage":"https://jwlodek.github.io/py_cui-docs","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jwlodek.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":"AUTHORS","dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-08-14T02:47:49.000Z","updated_at":"2025-04-11T14:49:17.000Z","dependencies_parsed_at":"2024-01-13T22:04:07.554Z","dependency_job_id":"546b994c-9d3f-4968-a70e-49167d2921b6","html_url":"https://github.com/jwlodek/py_cui","commit_stats":{"total_commits":405,"total_committers":20,"mean_commits":20.25,"dds":0.6271604938271604,"last_synced_commit":"3a7f79cb1cfda4e5aa650a7f92ac04ef7c360e5f"},"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jwlodek%2Fpy_cui","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jwlodek%2Fpy_cui/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jwlodek%2Fpy_cui/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jwlodek%2Fpy_cui/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jwlodek","download_url":"https://codeload.github.com/jwlodek/py_cui/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254130747,"owners_count":22019835,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["command","command-line","commandline-interface","cui","python","python-library","terminal","terminal-based","tui"],"created_at":"2024-08-04T08:01:14.232Z","updated_at":"2025-05-14T14:08:58.396Z","avatar_url":"https://github.com/jwlodek.png","language":"Python","funding_links":[],"categories":["Python","📚 فهرست","Table of Contents"],"sub_categories":["کتابخانه هاي TUI"],"readme":"\u003cdiv align=\"center\"\u003e\n    \u003cimg src=\"docs/assets/py_cui_logo_new.svg\" alt=\"PyCUI\" width=300px\u003e\n\u003c/div\u003e\n\n\u003cdiv align=\"center\"\u003e\n    \u003cp\u003e\u003cstrong\u003e\u003cbr/\u003eA library for creating CUI/TUI interfaces with pre-built widgets in python.\u003c/strong\u003e\u003c/p\u003e\n    \u003cp\u003eEasily build text-based user interfaces on both Linux and Windows.\u003c/p\u003e\n    \u003ca href=\"#\"\u003e\n        \u003cimg src=\"https://github.com/jwlodek/py_cui/workflows/tests/badge.svg?branch=master\" alt=\"Automated Test+Build Status\"\u003e\n    \u003c/a\u003e\n    \u003ca href=\"https://pepy.tech/project/py-cui\"\u003e\n        \u003cimg src=\"https://pepy.tech/badge/py-cui\" alt=\"Download Counter\"\u003e\n    \u003c/a\u003e\n    \u003ca href=\"https://badge.fury.io/py/py-cui\"\u003e\n        \u003cimg src=\"https://badge.fury.io/py/py-cui.svg\" alt=\"PyPI Version\"\u003e\n    \u003c/a\u003e\n    \u003ca href=\"#\"\u003e\n        \u003cimg src=\"https://img.shields.io/github/license/jwlodek/py_cui.svg\" alt=\"License\"\u003e\n    \u003c/a\u003e\n\u003c/div\u003e\n\n---\n\n# py_cui\n\n`py_cui` is a python library meant to simplify writing console user interfaces in python. It relies on `curses` for terminal rendering, which is traditionally unix-specific, however, you may use the [windows-curses](https://github.com/zephyrproject-rtos/windows-curses) module to run `py_cui` on windows.\n\nThe 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. In addition, `py_cui` has support for a rich collection of interactive popups such as menus, forms, file dialogs, and more.\n\nIf you would like to contribute, feel free to make an issue or pull request after reading through the `CONTRIBUTING.md` file.\n\n## Installation\n\nYou may install `py_cui` via pip (use `pip3` if python 2 and 3 are installed side by side)\n\n```bash\npip install py-cui\n```\n\nMake 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\n\n```bash\npip install py_cui\n```\n\nshould work OK.\n\nIf you would like to use `py_cui` directly from source, clone this repository with:\n\n```bash\ngit clone https://github.com/jwlodek/py_cui\n```\n\nThen build/install with `pip`:\n\n```bash\ncd py_cui\npip install .\n```\n\nIf 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`.\n\n## Examples\n\nBelow are some screenshots and gifs of programs written with py_cui. Additional (simpler) examples are available in the `examples/` directory of this repository.\n\n### py_cui_2048 - A command line version of the classic 2048 game\n\n[py_cui_2048](https://github.com/jwlodek/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.\n\n\u003cp align=\"center\"\u003e\n    \u003cimg src=\"docs/assets/py2048-demo.gif\"\u003e\n\u003c/p\u003e\n\n### recoverpy - A TUI that allows for recovering lost or deleted files\n\n[recoverpy](https://github.com/PabloLec/recoverpy) is a utility for recovering files on linux. It will search through every inode to find your requested file block.\n\n\u003cp align=\"center\"\u003e\n    \u003cimg src=\"docs/assets/recoverpy-demo.gif\"\u003e\n\u003c/p\u003e\n\n### pyautogit - A command line interface for managing git repositories\n\n[pyautogit](https://github.com/jwlodek/pyautogit) is the first larger scale project written in `py_cui`. Feel free to use it as a guide to programming with `py_cui`.\n\n\u003cp align=\"center\"\u003e\n    \u003cimg src=\"docs/assets/pyautogit-demo.gif\"\u003e\n\u003c/p\u003e\n\n## Getting started\n\nThe 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:\n\n```bash\npip install cookiecutter\n```\n\nOnce it is installed, navigate to the directory in which you would like your projects to live, and run:\n\n```bash\ncookiecutter https://github.com/jwlodek/py_cui_cookiecutter\n```\n\nThis will clone the template, and show prompts for several variables, including project name and description, as well as some developer information.\nOnce 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:\n\n```bash\ncd myproject\npip install .\nmyproject\n```\n\nYou are now ready to extend this template for your own application!\n\n## Writing a PyCUI\n\nBasic 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:\n\n```Python\nroot = py_cui.PyCUI(7, 9)\n```\n\nThe above line will create a UI with 7 rows and 9 columns. Then, add widgets with the different add commands:\n\n```Python\nlabel = root.add_label('Label Text', 0, 0)\nbutton = root.add_button('Button Text', 1, 2, column_span=2, command=my_function)\n...\n```\n\nFinally, start the CUI with\n\n```Python\nroot.start()\n```\n\n`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](https://jwlodek.github.io/py_cui-docs).\n\n## Using a PyCUI\n\nThere 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.\n\n### Overview Mode\n\nOverview 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.\n\n### Focus Mode\n\nWhen 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`.\n\n### Popup Mode\n\nPopup 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.\n\n## Unit Tests\n\n`py_cui` unit tests are written for `pytest`. Make sure `pytest` is installed, and simply run\n\n```Bash\npytest\n```\n\nin the root directory to run all unit tests.\n\n## Powered by py_cui\n\nBelow 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!\n\nProject | Description\n--------|-------------\n[pypodcasts](https://github.com/jwlodek/pypodcasts) | A TUI for listening to and managing podcast feeds. (Coming Soon)\n[pyautogit](https://github.com/jwlodek/pyautogit) | A command line UI for interfacing with git features for multiple repositories.\n[recoverpy](https://github.com/PabloLec/recoverpy) | A CUI for recovering overwritten or deleted data on linux.\n[py_cui_2048](https://github.com/jwlodek/py_cui_2048) | A CUI version of the classic 2048 game.\n[unipkg](https://github.com/jwlodek/unipkg) | A CUI interface for managing all installed package managers on your system. (In-Progress)\n[CUIAudioPlayer](https://github.com/jupiterbjy/CUIAudioPlayer) | A TUI for playing back audio files in a variety of formats.\n[tinypub](https://github.com/HakierGrzonzo/tinyPub) | A console-based ebook reader.\n[hue-tui](https://github.com/channel-42/hue-tui) | A CUI controlling for Philips Hue lights.\n[mini-radio-player](https://github.com/wdog/mini-radio-player-pycui) | A terminal based radio interface for linux.\n\n## License\n\nBSD 3-Clause License\n\nCopyright (c) 2019-2021, Jakub Wlodek\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjwlodek%2Fpy_cui","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjwlodek%2Fpy_cui","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjwlodek%2Fpy_cui/lists"}