Skip to content

Commit 2851f3d

Browse files
committed
UPDATE: README.md
ADD: LICENSE.md, setup.cfg, setup.py
1 parent 5dff9aa commit 2851f3d

File tree

12 files changed

+141
-23
lines changed

12 files changed

+141
-23
lines changed

.github/workflows/main.yml

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,21 +13,28 @@ jobs:
1313
fail-fast: false
1414
matrix:
1515
os: [ ubuntu-latest, macos-latest, windows-latest ]
16-
python-version: [3.8, 3.9, 3.10]
16+
python-version: [3.7, 3.8, 3.9, "3.10"]
1717

1818
steps:
1919
- uses: actions/checkout@v2
2020
- name: Set up Python ${{ matrix.python-version }}
2121
uses: actions/setup-python@v2
2222
with:
2323
python-version: ${{ matrix.python-version }}
24-
- name: Install dependencies
24+
- name: Install dependencies (Unix like Os)
25+
if: matrix.os != 'windows-latest'
2526
run: |
2627
python -m pip install --upgrade pip
2728
pip install pylint pycodestyle
29+
- name: Install dependencies(Only windows)
30+
if: matrix.os == 'windows-latest'
31+
run: |
32+
python -m pip install --upgrade pip
33+
pip install windows-curses pycodestyle
2834
- name: Tests
2935
run: python -m unittest tests/creation.py
30-
- name: Pylint
36+
- name: Pylint (Unix like Os)
37+
if: matrix.os != 'windows-latest'
3138
run: pylint **/*.py --fail-under 8
3239
- name: Pycodestyle
33-
run: pycodestyle .
40+
run: pycodestyle .

LICENSE.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2022 BaggerFast (Aleksandrov Daniil)
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 54 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,54 @@
1-
# PyConsoleMenu
1+
# PyConsoleMenu
2+
![Language](https://img.shields.io/badge/Language-Python3.7+-blue.svg?style=flat)
3+
[![BUILD-STATUS](https://github.com/BaggerFast/Snake/workflows/CI/badge.svg)](https://github.com/BaggerFast/Snake/actions?query=workflow%3Aci)
4+
5+
A simple Python menu in the terminal using curses.
6+
Ideal for people who want to quickly make a menu without writing their own complicated crutches.
7+
Includes: SelectorMenu, MultipleSelectorMenu, FunctionalMenu
8+
9+
## Installation 💾
10+
- using pip
11+
```
12+
$ pip install py_menu_console
13+
```
14+
15+
- using GitHub *(требуется [git](https://git-scm.com/downloads))*
16+
```
17+
$ git clone https://github.com/BaggerFast/PyConsoleMemu
18+
$ cd PyConsoleMemu
19+
$ pip install -r requirements.txt
20+
```
21+
22+
## Usage example ⌨️
23+
```py
24+
from py_menu_console import MultiSelectorMenu, FunctionalOption, SelectorMenu, FunctionalMenu
25+
26+
27+
def multi_selector():
28+
menu = MultiSelectorMenu(['Cheburashka', 'Parrot', 'Snake', 'Gena'], title='MultiSelector', count=3)
29+
ans = menu.input()
30+
print(ans)
31+
32+
33+
def selector():
34+
menu = SelectorMenu(['Cheburashka', 'Parrot', 'Snake', 'Gena'], title='Selector')
35+
ans = menu.input()
36+
print(ans)
37+
38+
39+
def functional():
40+
data = [
41+
FunctionalOption('Cheburashka', lambda _: print('I am a Parrot')),
42+
FunctionalOption('Parrot', lambda _: print('I am a Cheburashka')),
43+
]
44+
menu = FunctionalMenu(data, title='Functional')
45+
ans = menu.input()
46+
ans()
47+
```
48+
*[See more examples](https://github.com/BaggerFast/PyConsoleMenu/tree/main/examples)*
49+
50+
**Was written in these videos on YouTube 👀** \
51+
[Video#1](https://www.youtube.com/watch?v=wgK90PIzlng&t=118s) \
52+
[Stream#1](https://www.youtube.com/watch?v=7eHcjkM-mTs&t=6046s) \
53+
[Stream#2](https://www.youtube.com/watch?v=ppZoCcmPhpc&t=2941s)
54+

examples/example.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from pymenu import MultiSelectorMenu, FunctionalOption, SelectorMenu, FunctionalMenu
1+
from py_menu_console import MultiSelectorMenu, FunctionalOption, SelectorMenu, FunctionalMenu
22

33

44
def multi_selector():
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
from .menu import MultiSelectorMenu, FunctionalMenu, SelectorMenu
2-
from .misc import FunctionalOption, Option
2+
from .misc import FunctionalOption, Option

pymenu/base.py renamed to py_menu_console/base.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from typing import Any
1+
from typing import Any, List
22
from abc import ABC
33
from curses import wrapper, use_default_colors, curs_set
44
import _curses
@@ -15,7 +15,7 @@ class BaseMenu(ABC):
1515
:param indicator: (optional) customize the selection indicator
1616
"""
1717

18-
def __init__(self, options: list[str], title: str = '', default_index: int = 0, indicator: str = "->") -> None:
18+
def __init__(self, options: List[str], title: str = '', default_index: int = 0, indicator: str = "->") -> None:
1919

2020
# region parse Exceptions
2121

pymenu/menu.py renamed to py_menu_console/menu.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import curses
2-
from typing import Callable, Union
2+
from typing import Callable, Union, List
33
from .base import BaseMenu
44
from .misc import Option, Keyboard, FunctionalOption
55

@@ -35,7 +35,7 @@ class MultiSelectorMenu(BaseMenu):
3535
:param count: a number of max chosen options
3636
"""
3737

38-
def __init__(self, options: list[str], title: str = '', default_index: int = 0, indicator: str = "->",
38+
def __init__(self, options: List[str], title: str = '', default_index: int = 0, indicator: str = "->",
3939
count: int = None) -> None:
4040

4141
count = len(options) if not count else count
@@ -44,7 +44,7 @@ def __init__(self, options: list[str], title: str = '', default_index: int = 0,
4444

4545
super().__init__(options, title, default_index, indicator)
4646
self.__count = count
47-
self.__selected: list[int] = []
47+
self.__selected: List[int] = []
4848
self._control_config[Keyboard.SELECT] = self.__select
4949

5050
# region Private
@@ -71,7 +71,7 @@ def _draw_options(self, screen, max_x: int) -> None:
7171
screen.addnstr(self._y, 0, line, max_x)
7272
self._y += 1
7373

74-
def _get_selected(self) -> Union[list[Option], None]:
74+
def _get_selected(self) -> Union[List[Option], None]:
7575
if not self.__selected:
7676
return
7777
return [Option(index=i, name=self._options[i]) for i in sorted(self.__selected)]
@@ -95,11 +95,11 @@ class FunctionalMenu(BaseMenu):
9595
:param indicator: (optional) customize the selection indicator
9696
"""
9797

98-
def __init__(self, options: list[FunctionalOption], title: str = '', default_index: int = 0,
98+
def __init__(self, options: List[FunctionalOption], title: str = '', default_index: int = 0,
9999
indicator: str = "->") -> None:
100100

101-
self.__functions: list[Callable] = []
102-
local_options: list[str] = []
101+
self.__functions: List[Callable] = []
102+
local_options: List[str] = []
103103
for option in options:
104104
self.__functions.append(option.func)
105105
local_options.append(option.name)

pymenu/misc.py renamed to py_menu_console/misc.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from abc import ABC
22
from curses import KEY_UP, KEY_DOWN, KEY_ENTER
3-
from typing import NamedTuple, Final, Callable
3+
from typing import NamedTuple, Callable
44

55

66
class Option(NamedTuple):
@@ -22,7 +22,7 @@ class FunctionalOption(NamedTuple):
2222

2323

2424
class Keyboard(ABC):
25-
UP: Final = (KEY_UP, ord('w'))
26-
DOWN: Final = (KEY_DOWN, ord('s'))
27-
APPROVE: Final = (KEY_ENTER, ord('\n'))
28-
SELECT: Final = (ord(' '),)
25+
UP = (KEY_UP, ord('w'))
26+
DOWN = (KEY_DOWN, ord('s'))
27+
APPROVE = (KEY_ENTER, ord('\n'))
28+
SELECT = (ord(' '),)

requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
windows-curses; sys_platform=='win32'

setup.cfg

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[metadata]
2+
description-file=README.md
3+
license_files=LICENSE.md

setup.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
from setuptools import setup
2+
3+
setup(
4+
name='py_console_menu',
5+
version='1.0.0',
6+
license='MIT',
7+
author="BaggerFast (Aleksandrov Daniil)",
8+
author_email='riosha3@gmail.com',
9+
description='A simple console menu system using curses',
10+
long_description='Contains: SelectorMenu, MultiSelectorMenu, FunctionalMenu',
11+
url='https://github.com/BaggerFast/PyConsoleMenu',
12+
downoload_url='?',
13+
keywords='?',
14+
install_requires=[
15+
"widows-curses; sys_platform == 'win32'"
16+
],
17+
python_requires='>=3.7',
18+
classifiers=[
19+
'Intended Audience :: Developers',
20+
'License :: OSI Approved :: MIT License',
21+
'Operating System :: OS Independent',
22+
'Programming Language :: Python :: 3'
23+
'Programming Language :: Python :: 3 :: Only',
24+
'Programming Language :: Python :: 3.7',
25+
'Programming Language :: Python :: 3.8',
26+
'Programming Language :: Python :: 3.9',
27+
'Programming Language :: Python :: 3.10',
28+
'Programming Language :: Python :: Implementation :: CPython',
29+
'Programming Language :: Python :: Implementation :: PyPy',
30+
'Programming Language :: Python',
31+
'Topic :: Software Development :: Libraries :: Python Modules',
32+
],
33+
)

tests/creation.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from unittest import TestCase
22

3-
from pymenu.menu import SelectorMenu, MultiSelectorMenu, FunctionalMenu
4-
from pymenu.misc import FunctionalOption
3+
from py_menu_console.menu import SelectorMenu, MultiSelectorMenu, FunctionalMenu
4+
from py_menu_console.misc import FunctionalOption
55

66

77
class TestCreation(TestCase):

0 commit comments

Comments
 (0)