Skip to content

Commit 379ba30

Browse files
committed
ADD: assets for README.md
UPDATE: setup README.md
1 parent 2851f3d commit 379ba30

File tree

12 files changed

+37
-26
lines changed

12 files changed

+37
-26
lines changed

.github/workflows/main.yml

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,11 @@ jobs:
2121
uses: actions/setup-python@v2
2222
with:
2323
python-version: ${{ matrix.python-version }}
24-
- name: Install dependencies (Unix like Os)
25-
if: matrix.os != 'windows-latest'
24+
- name: Install dependencies
2625
run: |
2726
python -m pip install --upgrade pip
27+
pip install -r requirements.txt
2828
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
3429
- name: Tests
3530
run: python -m unittest tests/creation.py
3631
- name: Pylint (Unix like Os)

.pylintrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ extension-pkg-whitelist=
1717
fail-on=
1818

1919
# Specify a score threshold to be exceeded before program exits with error.
20-
fail-under=10.0
20+
fail-under=8.0
2121

2222
# Files or directories to be skipped. They should be base names, not paths.
2323
ignore=CVS, venv

README.md

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
11
# PyConsoleMenu
22
![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)
3+
[![BUILD-STATUS](https://github.com/BaggerFast/PyConsoleMenu/workflows/CI/badge.svg)](https://github.com/BaggerFast/PyConsoleMenu/actions)
44

55
A simple Python menu in the terminal using curses.
66
Ideal for people who want to quickly make a menu without writing their own complicated crutches.
7-
Includes: SelectorMenu, MultipleSelectorMenu, FunctionalMenu
7+
Includes: SelectorMenu, MultipleSelectorMenu, FunctionalMenu.
8+
9+
## Preview
10+
![Selector](https://github.com/BaggerFast/PyConsoleMenu/tree/main/assets/selector.gif)
11+
12+
[See other](https://github.com/BaggerFast/PyConsoleMenu/tree/main/assets)
813

914
## Installation 💾
1015
- using pip
@@ -14,12 +19,17 @@ $ pip install py_menu_console
1419

1520
- using GitHub *(требуется [git](https://git-scm.com/downloads))*
1621
```
17-
$ git clone https://github.com/BaggerFast/PyConsoleMemu
22+
$ git clone https://github.com/BaggerFast/PyConsoleMenu
1823
$ cd PyConsoleMemu
1924
$ pip install -r requirements.txt
2025
```
2126

22-
## Usage example ⌨️
27+
## Additionally ⌨️
28+
- Docs in code
29+
- Type hints
30+
31+
32+
## Usage example 👨‍💻
2333
```py
2434
from py_menu_console import MultiSelectorMenu, FunctionalOption, SelectorMenu, FunctionalMenu
2535

@@ -38,8 +48,8 @@ def selector():
3848

3949
def functional():
4050
data = [
41-
FunctionalOption('Cheburashka', lambda _: print('I am a Parrot')),
42-
FunctionalOption('Parrot', lambda _: print('I am a Cheburashka')),
51+
FunctionalOption('Cheburashka', lambda: print('I am a Parrot')),
52+
FunctionalOption('Parrot', lambda: print('I am a Cheburashka')),
4353
]
4454
menu = FunctionalMenu(data, title='Functional')
4555
ans = menu.input()

assets/functional.gif

425 KB
Loading

assets/multi_selector.gif

748 KB
Loading

assets/selector.gif

571 KB
Loading

examples/.gitkeep

Whitespace-only changes.

examples/example.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ def selector():
1515

1616
def functional():
1717
data = [
18-
FunctionalOption('Cheburashka', lambda _: print('I am a Parrot')),
19-
FunctionalOption('Parrot', lambda _: print('I am a Cheburashka')),
18+
FunctionalOption('Cheburashka', lambda: print('I am a Parrot')),
19+
FunctionalOption('Parrot', lambda: print('I am a Cheburashka')),
2020
]
2121
menu = FunctionalMenu(data, title='Functional')
2222
ans = menu.input()

py_menu_console/__init__.py

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

py_menu_console/base.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ class BaseMenu(ABC):
1212
:param options: a list of options to choose from
1313
:param title: (optional) a title above options list
1414
:param default_index: (optional) set this if the default selected option is not the first one
15-
:param indicator: (optional) customize the selection indicator
15+
:param indicator: (optional) customize the selection indicator.
1616
"""
1717

1818
def __init__(self, options: List[str], title: str = '', default_index: int = 0, indicator: str = "->") -> None:
@@ -100,6 +100,9 @@ def _draw_options(self, screen, max_x: int) -> None:
100100
# region Public
101101

102102
def input(self) -> Any:
103+
"""
104+
Return input info from menu
105+
"""
103106
return wrapper(self._run_loop)
104107

105108
# endregion

py_menu_console/menu.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,12 @@ class SelectorMenu(BaseMenu):
1111
:param options: a list of options to choose from
1212
:param title: (optional) a title above options list
1313
:param default_index: (optional) set this if the default selected option is not the first one
14-
:param indicator: (optional) customize the selection indicator
14+
:param indicator: (optional) customize the selection indicator.
1515
"""
1616

17+
def __init__(self, options: List[str], title: str = '', default_index: int = 0, indicator: str = "->") -> None:
18+
super().__init__(options, title, default_index, indicator)
19+
1720
def _get_selected(self) -> Option:
1821
return Option(name=self._options[self._index], index=self._index)
1922

@@ -32,13 +35,13 @@ class MultiSelectorMenu(BaseMenu):
3235
:param title: (optional) a title above options list
3336
:param default_index: (optional) set this if the default selected option is not the first one
3437
:param indicator: (optional) customize the selection indicator
35-
:param count: a number of max chosen options
38+
:param count: a number of max chosen options.
3639
"""
3740

3841
def __init__(self, options: List[str], title: str = '', default_index: int = 0, indicator: str = "->",
3942
count: int = None) -> None:
4043

41-
count = len(options) if not count else count
44+
count = len(options) if count <= 0 else count
4245
if 1 <= count > len(options):
4346
raise ValueError('Count must be in [2, len(options)]')
4447

@@ -78,7 +81,7 @@ def _get_selected(self) -> Union[List[Option], None]:
7881

7982
# endregion
8083

81-
def input(self) -> list[Option]:
84+
def input(self) -> List[Option]:
8285
"""
8386
Return list of chosen options as Items
8487
"""
@@ -92,7 +95,7 @@ class FunctionalMenu(BaseMenu):
9295
:param options: a list of options to choose from
9396
:param title: (optional) a title above options list
9497
:param default_index: (optional) set this if the default selected option is not the first one
95-
:param indicator: (optional) customize the selection indicator
98+
:param indicator: (optional) customize the selection indicator.
9699
"""
97100

98101
def __init__(self, options: List[FunctionalOption], title: str = '', default_index: int = 0,

py_menu_console/misc.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55

66
class Option(NamedTuple):
77
"""
8-
:param name: name of chosen item in menu
9-
:param index: index of chosen item in menu
8+
:param name: name of chosen item in a menu
9+
:param index: index of chosen item in a menu.
1010
"""
1111
name: str
1212
index: int
@@ -15,7 +15,7 @@ class Option(NamedTuple):
1515
class FunctionalOption(NamedTuple):
1616
"""
1717
:param name: name of option
18-
:param func: func of option, will be return after functional menu
18+
:param func: func of option, will be return after a functional menu.
1919
"""
2020
name: str
2121
func: Callable

0 commit comments

Comments
 (0)