pyemenu


Namepyemenu JSON
Version 1.0.2 PyPI version JSON
download
home_pagehttps://github.com/FreireAlexander/PyeMenu
SummaryEasy and Simple kit for develop Text User Interfaces
upload_time2023-08-09 17:28:10
maintainer
docs_urlNone
authorFreire Alexander Palomino Palma
requires_python>=3.7
licenseMIT
keywords menu cli command line tui text user interface
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            [![GitHub Repository](https://img.shields.io/badge/-GitHub-%230D0D0D?logo=github&labelColor=gray)](https://github.com/FreireAlexander/PyeMenu)
[![Latest PyPi version](https://img.shields.io/pypi/v/pyemenu.svg)](https://pypi.python.org/pypi/pyemenu)<br>
[![supported Python versions](https://img.shields.io/pypi/pyversions/pyemenu)](https://pypi.python.org/pypi/pyemenu)
[![Project licence](https://img.shields.io/pypi/l/pyemenu?color=blue)](LICENCE) <br>
[![Number of PyPi downloads](https://img.shields.io/pypi/dd/pyemenu.svg)](https://pypi.python.org/pypi/pyemenu)



# Python - PyeMenu Version 1.0.2
PyeMenu is a simple and really easy kit for developing Text User Interface apps in Python. It can be used to develop minimalist apps that run in terminal emulator.

### News
PyeMenu has a lot of new features, starting by it has color now, it is possible to set foreground and background color to text, titles and widgets, there is a special class call colors to get a lot of colors by name taken from this page [this](https://htmlcolorcodes.com/color-names/).<br>
PyeMenu Version 1.0.1 now includes two principal elements, there are widgets and components.

### Widgets and Components
PyeMenu has two main elements group, it has components and widgets.<br>
- Components: The components are elements used inside the widgets to give color to the text or to the background, depending on the widget that you use it is advisable to use a type of component or another, there are 5 types available, the Text, Title, Checkbox, Entry and Button, these are used depending on the widgets but for general uses you can use the Text class to give color to your texts and to the background.
- Widgets: Widgets are used to create a new window or menu where you can gather information, right now there are three possibilities, the Menu, the Checkboxlist and the Form.
    1. Menu : For select just one option from a list, return a text with the answer
    2. Checkboxlist : For select one or multiselect options from a list, return a list with the answers
    3. Form : For get information from user, it return a dictionary with answers
<br>
Moere information on the Wiki
<br>

## Installation

Simply installing it via `pip`:

```bash
pip install pyemenu
```

or installing manually as follow:

For manually installing this module you can download this repo as .zip file and unzip where You need it

After unziping **Don´t forget to install requierements.txt via pip install as follow**

```python
pip install -r requirements.txt
```

## Requierments

This package uses python module [readchar](https://github.com/magmax/python-readchar/tree/master) in their last version, currently in version 4.0.5.

*Copyright (c) 2014-2022 Miguel Ángel García* 

## Examples

It is better to understand the components and widgets by checking an example.<br>
the following example shows how to make a Menu in a simple way, the Menu class is used for single answer questions among a list of options. The options can be of the Text class or of the text type __str__, if the Text class is used it is possible to specify individually a text color, and a background color with the parameters fg and bg. The colors must be a text string with the hexadecimal format that is usually used in web development with html or using the Colors class you can search a color by its name, the references of the color and its name are in [this page](https://htmlcolorcodes.com/color-names/).

```python
from pyemenu import Colors
from pyemenu import Text, Title, Menu

def main():
    # Foreground and Background Colors using Colors Class
    foreground = Colors.BlackOlive
    background = Colors.GhostWhite
    # Options as a Text() type object 
    # It is possible to use just a str 
    language1 = Text('Python')
    language2 = Text('JavaScript')
    language3 = Text('Java')
    language4 = Text('C++')
    language5 = Text('C#')
    language6 = Text('Swift')
    language7 = Text('Go')
    language8 = Text('Kotlin')
    # Options must be pass as a list
    options = [
                language1, language2, language3, language4,
                language5, language6, language7, language8
                ]
    # The title could be pass a str or a Title
    title = Title('What is your favorite?', fg=Colors.DarkBlue, bold=True)
    # The same by the cursor you want to use
    cursor = Text('>>', fg=Colors.DarkBlue)
    # it is possible to create a Menu just passing the options to be choosen
    menu = Menu(options, title=title, cursor=cursor, fg=foreground, bg=background)
    # The method print is used to show the menu on terminal
    menu.print(
                wrap=3,
                highlight=True,
                title_align='center',
                title_decorator='*',
                title_padding_bottom=True, 
                padding_bottom=True,
                padding_up=True
                )
    # Widgets has a attribute call answer to get data input for the user
    print(f"\nThe selected value is: {menu.answer}")

if __name__ == '__main__':
    main()
```
<br>
if you use this example your output would be something like this:
<br>
<div style="text-align:center">
    <img src="https://github.com/FreireAlexander/PyeMenu/blob/master/images/Example_1.png" alt="Example">
</div>
<p></p>

The next code show an example for creating a checkboxlist menu for selecting multiples options from a list

```python
from pyemenu import Colors, Title, Text, Checkboxlist

def main():
    foreground = Colors.IndianRed
    background = Colors.LightGoldenrodYellow
    dog = Text('My Cool Dog', fg=Colors.DarkBlue, bg=Colors.Gold)
    options = [
        'French Poodle', 'Chihuaha', 'Dalmata',
        'Golden Retriever', 'Labrador', 'German Sheppard',
        'Akita', 'Galgo', dog
    ]
    title = Title('What is your favorite/s dog/s?', fg=Colors.SeaGreen, italic=True)
    cursor = Text('➤', blink=True, fg=Colors.Navy)
    question = Checkboxlist(options, multiselect=True ,
                            title=title, cursor=cursor, fg=foreground, bg=background)
    question.print(  
                    wrap=3, highlight=True,
                    fg_hl=Colors.black, bg_hl=Colors.SkyBlue,
                    title_padding_bottom=True, 
                    title_padding_up=True
                    )
    if question.answer == None:
        print(f"\nDo you really like dogs? ")
    elif len(question.answer)==1:
        print(f"\nMy Favorite Dog is {question.answer}")
    else:
        print(f"\nMy Favorites Dog are {question.answer}")
    

if __name__ == '__main__':
    main()
```

<div style="text-align:center">
    <img src="https://github.com/FreireAlexander/PyeMenu/blob/master/images/Example_2.png" alt="Example">
</div>

<p></p>

One of the new features of PyeMenu is the possibility to create a Form for get survey information or whatever you 
want from the users. So, this example show that it is possible to print a logo or your app above the menu.


```python
from pyemenu import Colors, Title, Text, Form, Entry, Button


logo = r"""
  ____        _   _     ____     __     __   U _____ u   __   __ 
 / __"| u  U |"|u| | U |  _"\ u  \ \   /"/u  \| ___"|/   \ \ / / 
<\___ \/    \| |\| |  \| |_) |/   \ \ / //    |  _|"      \ V /  
 u___) |     | |_| |   |  _ <     /\ V /_,-.  | |___     U_|"|_u 
 |____/>>   <<\___/    |_| \_\   U  \_/-(_/   |_____|      |_|   
  )(  (__) (__) )(     //   \\_    //         <<   >>  .-,//|(_  
 (__)          (__)   (__)  (__)  (__)       (__) (__)  \_) (__) 
"""

Logo = Text(logo, fg=Colors.Azure, bg=Colors.Navy)

def main():
    foreground = Colors.BlackOlive
    background = Colors.LightCyan
    placeholder = Colors.LightBlue
    name = Text('Name')
    last_name = Text('Last')
    age = Entry('Age', validation='int')
    email = Entry('Email', validation='email') 
    password = Entry('Password', validation='password')    
    data = [name, last_name, age, email, password]
    title = Title('Creating a New User', italic=True, bold=True)
    cursor = Text('~>')    
    form = Form(data, title=title, cursor=cursor, fg=foreground, bg=background,
                placeholder_bg=placeholder,
                )
    form.print(
                wrap=2,
                highlight=True,
                title_align='center',
                logo=Logo
                )
    print(f"Your Answers are: {form.answer}")

if __name__ == '__main__':
    main()
```

This Form class allows a lot of type of inputs from users even a custom type specifing a custom validation function from the user, for more information visit the Wiki.<br>
<div style="text-align:center">
    <img src="https://github.com/FreireAlexander/PyeMenu/blob/master/images/Example_3a.png" alt="Example">
</div>

<p></p>

You can get something like this<br>
<div style="text-align:center">
    <img src="https://github.com/FreireAlexander/PyeMenu/blob/master/images/Example_3b.png" alt="Example">
</div>

<p></p>

## Wiki
you can view the wiki to understand more about the use of this package. It is really easy and simple for using it.
for more information get a look [here](https://github.com/FreireAlexander/PyeMenu/wiki)

## OS Support
Right now it only been tested on Windows Os and Linux Os, some terminals emulators are not allow to show all text effects as colors, blink, an so on.

## LICENSE

PyeMenu is using a MIT license

*Copyright (c) 2014-2023 Freire Alexander Palomino Palma*

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/FreireAlexander/PyeMenu",
    "name": "pyemenu",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.7",
    "maintainer_email": "",
    "keywords": "MENU,CLI,command line,TUI,Text User Interface",
    "author": "Freire Alexander Palomino Palma",
    "author_email": "freirealexander0214@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/1c/33/c3c43934ed7f2fcfa6e1fbde849933453b3929887a99fcdde209a391d7ae/pyemenu-1.0.2.tar.gz",
    "platform": null,
    "description": "[![GitHub Repository](https://img.shields.io/badge/-GitHub-%230D0D0D?logo=github&labelColor=gray)](https://github.com/FreireAlexander/PyeMenu)\n[![Latest PyPi version](https://img.shields.io/pypi/v/pyemenu.svg)](https://pypi.python.org/pypi/pyemenu)<br>\n[![supported Python versions](https://img.shields.io/pypi/pyversions/pyemenu)](https://pypi.python.org/pypi/pyemenu)\n[![Project licence](https://img.shields.io/pypi/l/pyemenu?color=blue)](LICENCE) <br>\n[![Number of PyPi downloads](https://img.shields.io/pypi/dd/pyemenu.svg)](https://pypi.python.org/pypi/pyemenu)\n\n\n\n# Python - PyeMenu Version 1.0.2\nPyeMenu is a simple and really easy kit for developing Text User Interface apps in Python. It can be used to develop minimalist apps that run in terminal emulator.\n\n### News\nPyeMenu has a lot of new features, starting by it has color now, it is possible to set foreground and background color to text, titles and widgets, there is a special class call colors to get a lot of colors by name taken from this page [this](https://htmlcolorcodes.com/color-names/).<br>\nPyeMenu Version 1.0.1 now includes two principal elements, there are widgets and components.\n\n### Widgets and Components\nPyeMenu has two main elements group, it has components and widgets.<br>\n- Components: The components are elements used inside the widgets to give color to the text or to the background, depending on the widget that you use it is advisable to use a type of component or another, there are 5 types available, the Text, Title, Checkbox, Entry and Button, these are used depending on the widgets but for general uses you can use the Text class to give color to your texts and to the background.\n- Widgets: Widgets are used to create a new window or menu where you can gather information, right now there are three possibilities, the Menu, the Checkboxlist and the Form.\n    1. Menu : For select just one option from a list, return a text with the answer\n    2. Checkboxlist : For select one or multiselect options from a list, return a list with the answers\n    3. Form : For get information from user, it return a dictionary with answers\n<br>\nMoere information on the Wiki\n<br>\n\n## Installation\n\nSimply installing it via `pip`:\n\n```bash\npip install pyemenu\n```\n\nor installing manually as follow:\n\nFor manually installing this module you can download this repo as .zip file and unzip where You need it\n\nAfter unziping **Don\u00b4t forget to install requierements.txt via pip install as follow**\n\n```python\npip install -r requirements.txt\n```\n\n## Requierments\n\nThis package uses python module [readchar](https://github.com/magmax/python-readchar/tree/master) in their last version, currently in version 4.0.5.\n\n*Copyright (c) 2014-2022 Miguel \u00c1ngel Garc\u00eda* \n\n## Examples\n\nIt is better to understand the components and widgets by checking an example.<br>\nthe following example shows how to make a Menu in a simple way, the Menu class is used for single answer questions among a list of options. The options can be of the Text class or of the text type __str__, if the Text class is used it is possible to specify individually a text color, and a background color with the parameters fg and bg. The colors must be a text string with the hexadecimal format that is usually used in web development with html or using the Colors class you can search a color by its name, the references of the color and its name are in [this page](https://htmlcolorcodes.com/color-names/).\n\n```python\nfrom pyemenu import Colors\nfrom pyemenu import Text, Title, Menu\n\ndef main():\n    # Foreground and Background Colors using Colors Class\n    foreground = Colors.BlackOlive\n    background = Colors.GhostWhite\n    # Options as a Text() type object \n    # It is possible to use just a str \n    language1 = Text('Python')\n    language2 = Text('JavaScript')\n    language3 = Text('Java')\n    language4 = Text('C++')\n    language5 = Text('C#')\n    language6 = Text('Swift')\n    language7 = Text('Go')\n    language8 = Text('Kotlin')\n    # Options must be pass as a list\n    options = [\n                language1, language2, language3, language4,\n                language5, language6, language7, language8\n                ]\n    # The title could be pass a str or a Title\n    title = Title('What is your favorite?', fg=Colors.DarkBlue, bold=True)\n    # The same by the cursor you want to use\n    cursor = Text('>>', fg=Colors.DarkBlue)\n    # it is possible to create a Menu just passing the options to be choosen\n    menu = Menu(options, title=title, cursor=cursor, fg=foreground, bg=background)\n    # The method print is used to show the menu on terminal\n    menu.print(\n                wrap=3,\n                highlight=True,\n                title_align='center',\n                title_decorator='*',\n                title_padding_bottom=True, \n                padding_bottom=True,\n                padding_up=True\n                )\n    # Widgets has a attribute call answer to get data input for the user\n    print(f\"\\nThe selected value is: {menu.answer}\")\n\nif __name__ == '__main__':\n    main()\n```\n<br>\nif you use this example your output would be something like this:\n<br>\n<div style=\"text-align:center\">\n    <img src=\"https://github.com/FreireAlexander/PyeMenu/blob/master/images/Example_1.png\" alt=\"Example\">\n</div>\n<p></p>\n\nThe next code show an example for creating a checkboxlist menu for selecting multiples options from a list\n\n```python\nfrom pyemenu import Colors, Title, Text, Checkboxlist\n\ndef main():\n    foreground = Colors.IndianRed\n    background = Colors.LightGoldenrodYellow\n    dog = Text('My Cool Dog', fg=Colors.DarkBlue, bg=Colors.Gold)\n    options = [\n        'French Poodle', 'Chihuaha', 'Dalmata',\n        'Golden Retriever', 'Labrador', 'German Sheppard',\n        'Akita', 'Galgo', dog\n    ]\n    title = Title('What is your favorite/s dog/s?', fg=Colors.SeaGreen, italic=True)\n    cursor = Text('\u27a4', blink=True, fg=Colors.Navy)\n    question = Checkboxlist(options, multiselect=True ,\n                            title=title, cursor=cursor, fg=foreground, bg=background)\n    question.print(  \n                    wrap=3, highlight=True,\n                    fg_hl=Colors.black, bg_hl=Colors.SkyBlue,\n                    title_padding_bottom=True, \n                    title_padding_up=True\n                    )\n    if question.answer == None:\n        print(f\"\\nDo you really like dogs? \")\n    elif len(question.answer)==1:\n        print(f\"\\nMy Favorite Dog is {question.answer}\")\n    else:\n        print(f\"\\nMy Favorites Dog are {question.answer}\")\n    \n\nif __name__ == '__main__':\n    main()\n```\n\n<div style=\"text-align:center\">\n    <img src=\"https://github.com/FreireAlexander/PyeMenu/blob/master/images/Example_2.png\" alt=\"Example\">\n</div>\n\n<p></p>\n\nOne of the new features of PyeMenu is the possibility to create a Form for get survey information or whatever you \nwant from the users. So, this example show that it is possible to print a logo or your app above the menu.\n\n\n```python\nfrom pyemenu import Colors, Title, Text, Form, Entry, Button\n\n\nlogo = r\"\"\"\n  ____        _   _     ____     __     __   U _____ u   __   __ \n / __\"| u  U |\"|u| | U |  _\"\\ u  \\ \\   /\"/u  \\| ___\"|/   \\ \\ / / \n<\\___ \\/    \\| |\\| |  \\| |_) |/   \\ \\ / //    |  _|\"      \\ V /  \n u___) |     | |_| |   |  _ <     /\\ V /_,-.  | |___     U_|\"|_u \n |____/>>   <<\\___/    |_| \\_\\   U  \\_/-(_/   |_____|      |_|   \n  )(  (__) (__) )(     //   \\\\_    //         <<   >>  .-,//|(_  \n (__)          (__)   (__)  (__)  (__)       (__) (__)  \\_) (__) \n\"\"\"\n\nLogo = Text(logo, fg=Colors.Azure, bg=Colors.Navy)\n\ndef main():\n    foreground = Colors.BlackOlive\n    background = Colors.LightCyan\n    placeholder = Colors.LightBlue\n    name = Text('Name')\n    last_name = Text('Last')\n    age = Entry('Age', validation='int')\n    email = Entry('Email', validation='email') \n    password = Entry('Password', validation='password')    \n    data = [name, last_name, age, email, password]\n    title = Title('Creating a New User', italic=True, bold=True)\n    cursor = Text('~>')    \n    form = Form(data, title=title, cursor=cursor, fg=foreground, bg=background,\n                placeholder_bg=placeholder,\n                )\n    form.print(\n                wrap=2,\n                highlight=True,\n                title_align='center',\n                logo=Logo\n                )\n    print(f\"Your Answers are: {form.answer}\")\n\nif __name__ == '__main__':\n    main()\n```\n\nThis Form class allows a lot of type of inputs from users even a custom type specifing a custom validation function from the user, for more information visit the Wiki.<br>\n<div style=\"text-align:center\">\n    <img src=\"https://github.com/FreireAlexander/PyeMenu/blob/master/images/Example_3a.png\" alt=\"Example\">\n</div>\n\n<p></p>\n\nYou can get something like this<br>\n<div style=\"text-align:center\">\n    <img src=\"https://github.com/FreireAlexander/PyeMenu/blob/master/images/Example_3b.png\" alt=\"Example\">\n</div>\n\n<p></p>\n\n## Wiki\nyou can view the wiki to understand more about the use of this package. It is really easy and simple for using it.\nfor more information get a look [here](https://github.com/FreireAlexander/PyeMenu/wiki)\n\n## OS Support\nRight now it only been tested on Windows Os and Linux Os, some terminals emulators are not allow to show all text effects as colors, blink, an so on.\n\n## LICENSE\n\nPyeMenu is using a MIT license\n\n*Copyright (c) 2014-2023 Freire Alexander Palomino Palma*\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Easy and Simple kit for develop Text User Interfaces",
    "version": "1.0.2",
    "project_urls": {
        "Bug Tracker": "https://github.com/FreireAlexander/PyeMenu/issues",
        "Download": "https://github.com/FreireAlexander/PyeMenu/releases/tag/1.0.2",
        "Homepage": "https://github.com/FreireAlexander/PyeMenu"
    },
    "split_keywords": [
        "menu",
        "cli",
        "command line",
        "tui",
        "text user interface"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "1c33c3c43934ed7f2fcfa6e1fbde849933453b3929887a99fcdde209a391d7ae",
                "md5": "ed07991c8ea44a5eb43e0619e247851a",
                "sha256": "a2928d6b9f002955d6f36a7c5aeacc9e1cff76ac474e9f3da9eae146fbaffc16"
            },
            "downloads": -1,
            "filename": "pyemenu-1.0.2.tar.gz",
            "has_sig": false,
            "md5_digest": "ed07991c8ea44a5eb43e0619e247851a",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7",
            "size": 20973,
            "upload_time": "2023-08-09T17:28:10",
            "upload_time_iso_8601": "2023-08-09T17:28:10.816806Z",
            "url": "https://files.pythonhosted.org/packages/1c/33/c3c43934ed7f2fcfa6e1fbde849933453b3929887a99fcdde209a391d7ae/pyemenu-1.0.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-08-09 17:28:10",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "FreireAlexander",
    "github_project": "PyeMenu",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "pyemenu"
}
        
Elapsed time: 0.11219s