pymenu-cli 1.0.4__tar.gz → 1.0.6__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- pymenu_cli-1.0.6/PKG-INFO +277 -0
- pymenu_cli-1.0.6/README.md +265 -0
- pymenu_cli-1.0.6/pymenu_cli/UI/styles.py +58 -0
- pymenu_cli-1.0.6/pymenu_cli/__init__.py +0 -0
- pymenu_cli-1.0.6/pymenu_cli/models/__init__.py +0 -0
- pymenu_cli-1.0.6/pymenu_cli/models/menu.py +108 -0
- pymenu_cli-1.0.6/pymenu_cli/models/menu_item.py +48 -0
- pymenu_cli-1.0.6/pymenu_cli/pymenu.py +101 -0
- pymenu_cli-1.0.6/pymenu_cli.egg-info/PKG-INFO +277 -0
- pymenu_cli-1.0.6/pymenu_cli.egg-info/SOURCES.txt +15 -0
- pymenu_cli-1.0.6/pymenu_cli.egg-info/entry_points.txt +2 -0
- pymenu_cli-1.0.6/pymenu_cli.egg-info/requires.txt +2 -0
- {pymenu_cli-1.0.4 → pymenu_cli-1.0.6}/setup.py +7 -3
- pymenu_cli-1.0.4/PKG-INFO +0 -113
- pymenu_cli-1.0.4/README.md +0 -103
- pymenu_cli-1.0.4/pymenu_cli/menu.py +0 -155
- pymenu_cli-1.0.4/pymenu_cli.egg-info/PKG-INFO +0 -113
- pymenu_cli-1.0.4/pymenu_cli.egg-info/SOURCES.txt +0 -9
- pymenu_cli-1.0.4/pymenu_cli.egg-info/entry_points.txt +0 -2
- {pymenu_cli-1.0.4/pymenu_cli → pymenu_cli-1.0.6/pymenu_cli/UI}/__init__.py +0 -0
- {pymenu_cli-1.0.4 → pymenu_cli-1.0.6}/pymenu_cli.egg-info/dependency_links.txt +0 -0
- {pymenu_cli-1.0.4 → pymenu_cli-1.0.6}/pymenu_cli.egg-info/top_level.txt +0 -0
- {pymenu_cli-1.0.4 → pymenu_cli-1.0.6}/setup.cfg +0 -0
|
@@ -0,0 +1,277 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: pymenu-cli
|
|
3
|
+
Version: 1.0.6
|
|
4
|
+
Summary: A Python library for creating interactive CLI menus
|
|
5
|
+
Home-page: https://github.com/moraneus/pymenu-cli
|
|
6
|
+
Author: Moraneus
|
|
7
|
+
Author-email: moraneus@gmail.com
|
|
8
|
+
License: MIT
|
|
9
|
+
Description-Content-Type: text/markdown
|
|
10
|
+
Requires-Dist: colorama
|
|
11
|
+
Requires-Dist: art
|
|
12
|
+
|
|
13
|
+
# pymenu-cli
|
|
14
|
+
|
|
15
|
+

|
|
16
|
+

|
|
17
|
+
[](https://opensource.org/licenses/MIT)
|
|
18
|
+
|
|
19
|
+
pymenu-cli is a Python library that simplifies the creation of interactive command-line interface (CLI) menus. It provides a convenient way to define hierarchical menu structures and associate actions with menu items.
|
|
20
|
+
|
|
21
|
+
## Features
|
|
22
|
+
|
|
23
|
+
- Define menus and submenus using a simple JSON file format
|
|
24
|
+
- Automatically generate navigation options (e.g., "Back" and "Exit")
|
|
25
|
+
- Execute specific functions based on user selections
|
|
26
|
+
- Customizable menu titles and item labels
|
|
27
|
+
- Flexible and extensible architecture
|
|
28
|
+
- Execute menus directly from the command line
|
|
29
|
+
- Support for color customization of menu titles and items
|
|
30
|
+
- Display a banner using ASCII art with customizable text and font
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
## Installation
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
pip install pymenu-cli
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## Usage
|
|
40
|
+
|
|
41
|
+
1. Define your menu structure in a JSON file (`menu.json`)
|
|
42
|
+
2. Implement the corresponding action functions in a separate Python file (`actions.py`)
|
|
43
|
+
|
|
44
|
+
### Using the Python API
|
|
45
|
+
```python
|
|
46
|
+
from pymenu_cli.pymenu import load_menu
|
|
47
|
+
|
|
48
|
+
# Define the 'menu' and the 'action' files
|
|
49
|
+
menu_file_path = 'menu.json'
|
|
50
|
+
actions_file_path = 'actions.py'
|
|
51
|
+
|
|
52
|
+
# Init the menu with this files
|
|
53
|
+
main_menu = load_menu(menu_file_path, actions_file_path)
|
|
54
|
+
|
|
55
|
+
# Display the menu
|
|
56
|
+
main_menu.display()
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
### Using the Command Line
|
|
60
|
+
```bash
|
|
61
|
+
pymenu-cli --menu menu.json --actions actions.py
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
pymenu-cli takes care of the menu navigation, menu stying, user input handling, and execution of the associated actions based on the user's selections.
|
|
65
|
+
|
|
66
|
+
## Menu JSON Format
|
|
67
|
+
The `menu.json` file defines the structure of your menu. Here's an example:
|
|
68
|
+
|
|
69
|
+
```json
|
|
70
|
+
{
|
|
71
|
+
"banner": {
|
|
72
|
+
"title": "HELLO",
|
|
73
|
+
"font": "white_bubble"
|
|
74
|
+
},
|
|
75
|
+
"title": "Main Menu",
|
|
76
|
+
"color": {
|
|
77
|
+
"text": "light_blue",
|
|
78
|
+
"background": "black"
|
|
79
|
+
},
|
|
80
|
+
"items": [
|
|
81
|
+
{
|
|
82
|
+
"title": "Option 1",
|
|
83
|
+
"color": {
|
|
84
|
+
"text": "yellow",
|
|
85
|
+
"background": "blue"
|
|
86
|
+
},
|
|
87
|
+
"action": "action_function_1"
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
"title": "Option 2",
|
|
91
|
+
"color": {
|
|
92
|
+
"text": "black",
|
|
93
|
+
"background": "light_yellow"
|
|
94
|
+
},
|
|
95
|
+
"submenu": {
|
|
96
|
+
"title": "Submenu",
|
|
97
|
+
"items": [
|
|
98
|
+
{
|
|
99
|
+
"title": "Submenu Option 1",
|
|
100
|
+
"action": "action_function_2"
|
|
101
|
+
},
|
|
102
|
+
{
|
|
103
|
+
"title": "Submenu Option 2",
|
|
104
|
+
"action": "action_function_3"
|
|
105
|
+
}
|
|
106
|
+
]
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
]
|
|
110
|
+
}
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
In the `menu.json` file, you can specify the following properties:
|
|
114
|
+
* `banner` (optional): The banner configuration for the menu.
|
|
115
|
+
* `title`: The text to display in the banner.
|
|
116
|
+
* `font` (optional): The font to use for the banner. If not specified, the default font will be used.
|
|
117
|
+
* `title`: The title of the menu or submenu.
|
|
118
|
+
* `color` (optional): The color settings for the menu or submenu title.
|
|
119
|
+
* `text`: The color of the text (e.g., "red", "light_blue").
|
|
120
|
+
* `background`: The color of the background (e.g., "white", "black").
|
|
121
|
+
* `items`: An array of menu items, each with its own properties:
|
|
122
|
+
* `title`: The title of the menu item.
|
|
123
|
+
* `color` (optional): The color settings for the menu item title.
|
|
124
|
+
* `action` (optional): The name of the action function to execute when the item is selected.
|
|
125
|
+
* `submenu` (optional): A nested submenu with its own title and items.
|
|
126
|
+
|
|
127
|
+
### Banner Customization
|
|
128
|
+
PyMenu CLI supports displaying a banner using ASCII art.
|
|
129
|
+
The banner can be customized by specifying the banner property in the menu.json file.
|
|
130
|
+
The banner property has the following sub-properties:
|
|
131
|
+
* `title`: The text to display in the banner.
|
|
132
|
+
* `font` (optional): The font to use for the banner. If not specified, the default font will be used.
|
|
133
|
+
|
|
134
|
+
PyMenu CLI uses the art library to generate the ASCII art for the banner.
|
|
135
|
+
You can choose from a wide range of available fonts provided by the [art](https://pypi.org/project/art/) library. Here are some font options:
|
|
136
|
+
|
|
137
|
+
* "standard"
|
|
138
|
+
```text
|
|
139
|
+
_____ _
|
|
140
|
+
| ___| ___ _ __ | |_
|
|
141
|
+
| |_ / _ \ | '_ \ | __|
|
|
142
|
+
| _| | (_) || | | || |_
|
|
143
|
+
|_| \___/ |_| |_| \__|
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
* "block"
|
|
147
|
+
```text
|
|
148
|
+
.----------------. .----------------. .-----------------. .----------------.
|
|
149
|
+
| .--------------. || .--------------. || .--------------. || .--------------. |
|
|
150
|
+
| | _________ | || | ____ | || | ____ _____ | || | _________ | |
|
|
151
|
+
| | |_ ___ | | || | .' `. | || ||_ \|_ _| | || | | _ _ | | |
|
|
152
|
+
| | | |_ \_| | || | / .--. \ | || | | \ | | | || | |_/ | | \_| | |
|
|
153
|
+
| | | _| | || | | | | | | || | | |\ \| | | || | | | | |
|
|
154
|
+
| | _| |_ | || | \ `--' / | || | _| |_\ |_ | || | _| |_ | |
|
|
155
|
+
| | |_____| | || | `.____.' | || ||_____|\____| | || | |_____| | |
|
|
156
|
+
| | | || | | || | | || | | |
|
|
157
|
+
| '--------------' || '--------------' || '--------------' || '--------------' |
|
|
158
|
+
'----------------' '----------------' '----------------' '----------------'
|
|
159
|
+
```
|
|
160
|
+
* "bubble"
|
|
161
|
+
```text
|
|
162
|
+
_ _ _ _
|
|
163
|
+
/ \ / \ / \ / \
|
|
164
|
+
( F )( o )( n )( t )
|
|
165
|
+
\_/ \_/ \_/ \_/
|
|
166
|
+
```
|
|
167
|
+
* "white_bubble"
|
|
168
|
+
```text
|
|
169
|
+
Ⓕⓞⓝⓣ
|
|
170
|
+
```
|
|
171
|
+
* "black_bubble"
|
|
172
|
+
```text
|
|
173
|
+
🅕🅞🅝🅣
|
|
174
|
+
```
|
|
175
|
+
* "digital"
|
|
176
|
+
```text
|
|
177
|
+
+-++-++-++-+
|
|
178
|
+
|f||o||n||t|
|
|
179
|
+
+-++-++-++-+
|
|
180
|
+
```
|
|
181
|
+
* "isometric1"
|
|
182
|
+
```text
|
|
183
|
+
___ ___ ___ ___
|
|
184
|
+
/\ \ /\ \ /\__\ /\ \
|
|
185
|
+
/::\ \ /::\ \ /::| | \:\ \
|
|
186
|
+
/:/\:\ \ /:/\:\ \ /:|:| | \:\ \
|
|
187
|
+
/::\~\:\ \ /:/ \:\ \ /:/|:| |__ /::\ \
|
|
188
|
+
/:/\:\ \:\__\ /:/__/ \:\__\ /:/ |:| /\__\ /:/\:\__\
|
|
189
|
+
\/__\:\ \/__/ \:\ \ /:/ / \/__|:|/:/ / /:/ \/__/
|
|
190
|
+
\:\__\ \:\ /:/ / |:/:/ / /:/ /
|
|
191
|
+
\/__/ \:\/:/ / |::/ / \/__/
|
|
192
|
+
\::/ / /:/ /
|
|
193
|
+
\/__/ \/__/
|
|
194
|
+
```
|
|
195
|
+
* "letters"
|
|
196
|
+
```text
|
|
197
|
+
FFFFFFF tt
|
|
198
|
+
FF oooo nn nnn tt
|
|
199
|
+
FFFF oo oo nnn nn tttt
|
|
200
|
+
FF oo oo nn nn tt
|
|
201
|
+
FF oooo nn nn tttt
|
|
202
|
+
```
|
|
203
|
+
* "arrow"
|
|
204
|
+
```text
|
|
205
|
+
>=======> >=>
|
|
206
|
+
>=> >=>
|
|
207
|
+
>=> >=> >==>>==> >=>>==>
|
|
208
|
+
>=====> >=> >=> >=> >=> >=>
|
|
209
|
+
>=> >=> >=> >=> >=> >=>
|
|
210
|
+
>=> >=> >=> >=> >=> >=>
|
|
211
|
+
>=> >=> >==> >=> >=>
|
|
212
|
+
```
|
|
213
|
+
* "slant"
|
|
214
|
+
```text
|
|
215
|
+
______ __
|
|
216
|
+
/ ____/ ____ ____ / /_
|
|
217
|
+
/ /_ / __ \ / __ \ / __/
|
|
218
|
+
/ __/ / /_/ / / / / // /_
|
|
219
|
+
/_/ \____/ /_/ /_/ \__/
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
For a complete list of available fonts,
|
|
223
|
+
please refer to the [art library documentation](https://pypi.org/project/art/).
|
|
224
|
+
If no font is specified in the banner configuration, PyMenu CLI will use the default font provided by the art library.
|
|
225
|
+
|
|
226
|
+
### Color Customization
|
|
227
|
+
PyMenu CLI supports color customization of menu titles and items using the colorama library.
|
|
228
|
+
You can specify the color of the text and background for each menu and item in the menu.json file.
|
|
229
|
+
The available color options are defined in the TextColors and BackgroundColors enums:
|
|
230
|
+
|
|
231
|
+
#### TextColors
|
|
232
|
+
`RED`, `LIGHT_RED`, `BLUE`, `LIGHT_BLUE`, `YELLOW`,
|
|
233
|
+
`LIGHT_YELLOW`, `GREEN`, `LIGHT_GREEN`, `CYAN`, `LIGHT_CYAN`,
|
|
234
|
+
`MAGENTA`, `LIGHT_MAGENTA`, `BLACK`, `LIGHT_BLACK`, `WHITE`,
|
|
235
|
+
`LIGHT_WHITE`
|
|
236
|
+
|
|
237
|
+
|
|
238
|
+
#### BackgroundColors
|
|
239
|
+
`RED`, `LIGHT_RED`, `BLUE`, `LIGHT_BLUE`, `YELLOW`,
|
|
240
|
+
`LIGHT_YELLOW`, `GREEN`, `LIGHT_GREEN`, `CYAN`, `LIGHT_CYAN`,
|
|
241
|
+
`MAGENTA`, `LIGHT_MAGENTA`, `BLACK`, `LIGHT_BLACK`, `WHITE`,
|
|
242
|
+
`LIGHT_WHITE`
|
|
243
|
+
|
|
244
|
+
To apply colors to a menu or item,
|
|
245
|
+
add the color property with the desired `text` and `background` colors in the menu.json file.
|
|
246
|
+
|
|
247
|
+
### Color Example
|
|
248
|
+
|
|
249
|
+
Here's an example of how the menu with colors would look like:
|
|
250
|
+
* [View Color Examples](https://htmlpreview.github.io/?https://github.com/moraneus/pymenu-cli/blob/main/docs/colors_example.html)
|
|
251
|
+
|
|
252
|
+
## Actions Python File
|
|
253
|
+
The `actions.py` file contains the functions that are executed when a menu item is selected. Here's an example:
|
|
254
|
+
```python
|
|
255
|
+
def action_function_1():
|
|
256
|
+
print("Executing action 1")
|
|
257
|
+
|
|
258
|
+
def action_function_2():
|
|
259
|
+
print("Executing action 2")
|
|
260
|
+
|
|
261
|
+
def action_function_3():
|
|
262
|
+
print("Executing action 3")
|
|
263
|
+
```
|
|
264
|
+
|
|
265
|
+
### Examples
|
|
266
|
+
Explore the examples directory for sample menu configurations and action implementations.
|
|
267
|
+
To run an example, follow these steps:
|
|
268
|
+
|
|
269
|
+
1. Clone the project repository.
|
|
270
|
+
2. Open your command line and navigate to the examples directory.
|
|
271
|
+
3. Execute the example by running the following command:
|
|
272
|
+
```python
|
|
273
|
+
python3 menu_example.py
|
|
274
|
+
```
|
|
275
|
+
|
|
276
|
+
### License
|
|
277
|
+
This project is licensed under the MIT License.
|
|
@@ -0,0 +1,265 @@
|
|
|
1
|
+
# pymenu-cli
|
|
2
|
+
|
|
3
|
+

|
|
4
|
+

|
|
5
|
+
[](https://opensource.org/licenses/MIT)
|
|
6
|
+
|
|
7
|
+
pymenu-cli is a Python library that simplifies the creation of interactive command-line interface (CLI) menus. It provides a convenient way to define hierarchical menu structures and associate actions with menu items.
|
|
8
|
+
|
|
9
|
+
## Features
|
|
10
|
+
|
|
11
|
+
- Define menus and submenus using a simple JSON file format
|
|
12
|
+
- Automatically generate navigation options (e.g., "Back" and "Exit")
|
|
13
|
+
- Execute specific functions based on user selections
|
|
14
|
+
- Customizable menu titles and item labels
|
|
15
|
+
- Flexible and extensible architecture
|
|
16
|
+
- Execute menus directly from the command line
|
|
17
|
+
- Support for color customization of menu titles and items
|
|
18
|
+
- Display a banner using ASCII art with customizable text and font
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
## Installation
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
pip install pymenu-cli
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## Usage
|
|
28
|
+
|
|
29
|
+
1. Define your menu structure in a JSON file (`menu.json`)
|
|
30
|
+
2. Implement the corresponding action functions in a separate Python file (`actions.py`)
|
|
31
|
+
|
|
32
|
+
### Using the Python API
|
|
33
|
+
```python
|
|
34
|
+
from pymenu_cli.pymenu import load_menu
|
|
35
|
+
|
|
36
|
+
# Define the 'menu' and the 'action' files
|
|
37
|
+
menu_file_path = 'menu.json'
|
|
38
|
+
actions_file_path = 'actions.py'
|
|
39
|
+
|
|
40
|
+
# Init the menu with this files
|
|
41
|
+
main_menu = load_menu(menu_file_path, actions_file_path)
|
|
42
|
+
|
|
43
|
+
# Display the menu
|
|
44
|
+
main_menu.display()
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
### Using the Command Line
|
|
48
|
+
```bash
|
|
49
|
+
pymenu-cli --menu menu.json --actions actions.py
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
pymenu-cli takes care of the menu navigation, menu stying, user input handling, and execution of the associated actions based on the user's selections.
|
|
53
|
+
|
|
54
|
+
## Menu JSON Format
|
|
55
|
+
The `menu.json` file defines the structure of your menu. Here's an example:
|
|
56
|
+
|
|
57
|
+
```json
|
|
58
|
+
{
|
|
59
|
+
"banner": {
|
|
60
|
+
"title": "HELLO",
|
|
61
|
+
"font": "white_bubble"
|
|
62
|
+
},
|
|
63
|
+
"title": "Main Menu",
|
|
64
|
+
"color": {
|
|
65
|
+
"text": "light_blue",
|
|
66
|
+
"background": "black"
|
|
67
|
+
},
|
|
68
|
+
"items": [
|
|
69
|
+
{
|
|
70
|
+
"title": "Option 1",
|
|
71
|
+
"color": {
|
|
72
|
+
"text": "yellow",
|
|
73
|
+
"background": "blue"
|
|
74
|
+
},
|
|
75
|
+
"action": "action_function_1"
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
"title": "Option 2",
|
|
79
|
+
"color": {
|
|
80
|
+
"text": "black",
|
|
81
|
+
"background": "light_yellow"
|
|
82
|
+
},
|
|
83
|
+
"submenu": {
|
|
84
|
+
"title": "Submenu",
|
|
85
|
+
"items": [
|
|
86
|
+
{
|
|
87
|
+
"title": "Submenu Option 1",
|
|
88
|
+
"action": "action_function_2"
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
"title": "Submenu Option 2",
|
|
92
|
+
"action": "action_function_3"
|
|
93
|
+
}
|
|
94
|
+
]
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
]
|
|
98
|
+
}
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
In the `menu.json` file, you can specify the following properties:
|
|
102
|
+
* `banner` (optional): The banner configuration for the menu.
|
|
103
|
+
* `title`: The text to display in the banner.
|
|
104
|
+
* `font` (optional): The font to use for the banner. If not specified, the default font will be used.
|
|
105
|
+
* `title`: The title of the menu or submenu.
|
|
106
|
+
* `color` (optional): The color settings for the menu or submenu title.
|
|
107
|
+
* `text`: The color of the text (e.g., "red", "light_blue").
|
|
108
|
+
* `background`: The color of the background (e.g., "white", "black").
|
|
109
|
+
* `items`: An array of menu items, each with its own properties:
|
|
110
|
+
* `title`: The title of the menu item.
|
|
111
|
+
* `color` (optional): The color settings for the menu item title.
|
|
112
|
+
* `action` (optional): The name of the action function to execute when the item is selected.
|
|
113
|
+
* `submenu` (optional): A nested submenu with its own title and items.
|
|
114
|
+
|
|
115
|
+
### Banner Customization
|
|
116
|
+
PyMenu CLI supports displaying a banner using ASCII art.
|
|
117
|
+
The banner can be customized by specifying the banner property in the menu.json file.
|
|
118
|
+
The banner property has the following sub-properties:
|
|
119
|
+
* `title`: The text to display in the banner.
|
|
120
|
+
* `font` (optional): The font to use for the banner. If not specified, the default font will be used.
|
|
121
|
+
|
|
122
|
+
PyMenu CLI uses the art library to generate the ASCII art for the banner.
|
|
123
|
+
You can choose from a wide range of available fonts provided by the [art](https://pypi.org/project/art/) library. Here are some font options:
|
|
124
|
+
|
|
125
|
+
* "standard"
|
|
126
|
+
```text
|
|
127
|
+
_____ _
|
|
128
|
+
| ___| ___ _ __ | |_
|
|
129
|
+
| |_ / _ \ | '_ \ | __|
|
|
130
|
+
| _| | (_) || | | || |_
|
|
131
|
+
|_| \___/ |_| |_| \__|
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
* "block"
|
|
135
|
+
```text
|
|
136
|
+
.----------------. .----------------. .-----------------. .----------------.
|
|
137
|
+
| .--------------. || .--------------. || .--------------. || .--------------. |
|
|
138
|
+
| | _________ | || | ____ | || | ____ _____ | || | _________ | |
|
|
139
|
+
| | |_ ___ | | || | .' `. | || ||_ \|_ _| | || | | _ _ | | |
|
|
140
|
+
| | | |_ \_| | || | / .--. \ | || | | \ | | | || | |_/ | | \_| | |
|
|
141
|
+
| | | _| | || | | | | | | || | | |\ \| | | || | | | | |
|
|
142
|
+
| | _| |_ | || | \ `--' / | || | _| |_\ |_ | || | _| |_ | |
|
|
143
|
+
| | |_____| | || | `.____.' | || ||_____|\____| | || | |_____| | |
|
|
144
|
+
| | | || | | || | | || | | |
|
|
145
|
+
| '--------------' || '--------------' || '--------------' || '--------------' |
|
|
146
|
+
'----------------' '----------------' '----------------' '----------------'
|
|
147
|
+
```
|
|
148
|
+
* "bubble"
|
|
149
|
+
```text
|
|
150
|
+
_ _ _ _
|
|
151
|
+
/ \ / \ / \ / \
|
|
152
|
+
( F )( o )( n )( t )
|
|
153
|
+
\_/ \_/ \_/ \_/
|
|
154
|
+
```
|
|
155
|
+
* "white_bubble"
|
|
156
|
+
```text
|
|
157
|
+
Ⓕⓞⓝⓣ
|
|
158
|
+
```
|
|
159
|
+
* "black_bubble"
|
|
160
|
+
```text
|
|
161
|
+
🅕🅞🅝🅣
|
|
162
|
+
```
|
|
163
|
+
* "digital"
|
|
164
|
+
```text
|
|
165
|
+
+-++-++-++-+
|
|
166
|
+
|f||o||n||t|
|
|
167
|
+
+-++-++-++-+
|
|
168
|
+
```
|
|
169
|
+
* "isometric1"
|
|
170
|
+
```text
|
|
171
|
+
___ ___ ___ ___
|
|
172
|
+
/\ \ /\ \ /\__\ /\ \
|
|
173
|
+
/::\ \ /::\ \ /::| | \:\ \
|
|
174
|
+
/:/\:\ \ /:/\:\ \ /:|:| | \:\ \
|
|
175
|
+
/::\~\:\ \ /:/ \:\ \ /:/|:| |__ /::\ \
|
|
176
|
+
/:/\:\ \:\__\ /:/__/ \:\__\ /:/ |:| /\__\ /:/\:\__\
|
|
177
|
+
\/__\:\ \/__/ \:\ \ /:/ / \/__|:|/:/ / /:/ \/__/
|
|
178
|
+
\:\__\ \:\ /:/ / |:/:/ / /:/ /
|
|
179
|
+
\/__/ \:\/:/ / |::/ / \/__/
|
|
180
|
+
\::/ / /:/ /
|
|
181
|
+
\/__/ \/__/
|
|
182
|
+
```
|
|
183
|
+
* "letters"
|
|
184
|
+
```text
|
|
185
|
+
FFFFFFF tt
|
|
186
|
+
FF oooo nn nnn tt
|
|
187
|
+
FFFF oo oo nnn nn tttt
|
|
188
|
+
FF oo oo nn nn tt
|
|
189
|
+
FF oooo nn nn tttt
|
|
190
|
+
```
|
|
191
|
+
* "arrow"
|
|
192
|
+
```text
|
|
193
|
+
>=======> >=>
|
|
194
|
+
>=> >=>
|
|
195
|
+
>=> >=> >==>>==> >=>>==>
|
|
196
|
+
>=====> >=> >=> >=> >=> >=>
|
|
197
|
+
>=> >=> >=> >=> >=> >=>
|
|
198
|
+
>=> >=> >=> >=> >=> >=>
|
|
199
|
+
>=> >=> >==> >=> >=>
|
|
200
|
+
```
|
|
201
|
+
* "slant"
|
|
202
|
+
```text
|
|
203
|
+
______ __
|
|
204
|
+
/ ____/ ____ ____ / /_
|
|
205
|
+
/ /_ / __ \ / __ \ / __/
|
|
206
|
+
/ __/ / /_/ / / / / // /_
|
|
207
|
+
/_/ \____/ /_/ /_/ \__/
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
For a complete list of available fonts,
|
|
211
|
+
please refer to the [art library documentation](https://pypi.org/project/art/).
|
|
212
|
+
If no font is specified in the banner configuration, PyMenu CLI will use the default font provided by the art library.
|
|
213
|
+
|
|
214
|
+
### Color Customization
|
|
215
|
+
PyMenu CLI supports color customization of menu titles and items using the colorama library.
|
|
216
|
+
You can specify the color of the text and background for each menu and item in the menu.json file.
|
|
217
|
+
The available color options are defined in the TextColors and BackgroundColors enums:
|
|
218
|
+
|
|
219
|
+
#### TextColors
|
|
220
|
+
`RED`, `LIGHT_RED`, `BLUE`, `LIGHT_BLUE`, `YELLOW`,
|
|
221
|
+
`LIGHT_YELLOW`, `GREEN`, `LIGHT_GREEN`, `CYAN`, `LIGHT_CYAN`,
|
|
222
|
+
`MAGENTA`, `LIGHT_MAGENTA`, `BLACK`, `LIGHT_BLACK`, `WHITE`,
|
|
223
|
+
`LIGHT_WHITE`
|
|
224
|
+
|
|
225
|
+
|
|
226
|
+
#### BackgroundColors
|
|
227
|
+
`RED`, `LIGHT_RED`, `BLUE`, `LIGHT_BLUE`, `YELLOW`,
|
|
228
|
+
`LIGHT_YELLOW`, `GREEN`, `LIGHT_GREEN`, `CYAN`, `LIGHT_CYAN`,
|
|
229
|
+
`MAGENTA`, `LIGHT_MAGENTA`, `BLACK`, `LIGHT_BLACK`, `WHITE`,
|
|
230
|
+
`LIGHT_WHITE`
|
|
231
|
+
|
|
232
|
+
To apply colors to a menu or item,
|
|
233
|
+
add the color property with the desired `text` and `background` colors in the menu.json file.
|
|
234
|
+
|
|
235
|
+
### Color Example
|
|
236
|
+
|
|
237
|
+
Here's an example of how the menu with colors would look like:
|
|
238
|
+
* [View Color Examples](https://htmlpreview.github.io/?https://github.com/moraneus/pymenu-cli/blob/main/docs/colors_example.html)
|
|
239
|
+
|
|
240
|
+
## Actions Python File
|
|
241
|
+
The `actions.py` file contains the functions that are executed when a menu item is selected. Here's an example:
|
|
242
|
+
```python
|
|
243
|
+
def action_function_1():
|
|
244
|
+
print("Executing action 1")
|
|
245
|
+
|
|
246
|
+
def action_function_2():
|
|
247
|
+
print("Executing action 2")
|
|
248
|
+
|
|
249
|
+
def action_function_3():
|
|
250
|
+
print("Executing action 3")
|
|
251
|
+
```
|
|
252
|
+
|
|
253
|
+
### Examples
|
|
254
|
+
Explore the examples directory for sample menu configurations and action implementations.
|
|
255
|
+
To run an example, follow these steps:
|
|
256
|
+
|
|
257
|
+
1. Clone the project repository.
|
|
258
|
+
2. Open your command line and navigate to the examples directory.
|
|
259
|
+
3. Execute the example by running the following command:
|
|
260
|
+
```python
|
|
261
|
+
python3 menu_example.py
|
|
262
|
+
```
|
|
263
|
+
|
|
264
|
+
### License
|
|
265
|
+
This project is licensed under the MIT License.
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
from enum import Enum
|
|
2
|
+
from colorama import Fore, Style, Back
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
# Used for returning the value from an enum as a string
|
|
6
|
+
class StrEnum(Enum):
|
|
7
|
+
def __str__(self):
|
|
8
|
+
return self.value
|
|
9
|
+
|
|
10
|
+
def __repr__(self):
|
|
11
|
+
return repr(self.value)
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
class TextColors(StrEnum):
|
|
15
|
+
RED = Fore.RED
|
|
16
|
+
LIGHT_RED = Fore.LIGHTRED_EX
|
|
17
|
+
BLUE = Fore.BLUE
|
|
18
|
+
LIGHT_BLUE = Fore.LIGHTBLUE_EX
|
|
19
|
+
YELLOW = Fore.YELLOW
|
|
20
|
+
LIGHT_YELLOW = Fore.LIGHTYELLOW_EX
|
|
21
|
+
GREEN = Fore.GREEN
|
|
22
|
+
LIGHT_GREEN = Fore.LIGHTGREEN_EX
|
|
23
|
+
CYAN = Fore.CYAN
|
|
24
|
+
LIGHT_CYAN = Fore.LIGHTCYAN_EX
|
|
25
|
+
MAGENTA = Fore.MAGENTA
|
|
26
|
+
LIGHT_MAGENTA = Fore.LIGHTMAGENTA_EX
|
|
27
|
+
BLACK = Fore.BLACK
|
|
28
|
+
LIGHT_BLACK = Fore.LIGHTBLACK_EX
|
|
29
|
+
WHITE = Fore.WHITE
|
|
30
|
+
LIGHT_WHITE = Fore.LIGHTWHITE_EX
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
class BackgroundColors(StrEnum):
|
|
34
|
+
RED = Back.RED
|
|
35
|
+
LIGHT_RED = Back.LIGHTRED_EX
|
|
36
|
+
BLUE = Back.BLUE
|
|
37
|
+
LIGHT_BLUE = Back.LIGHTBLUE_EX
|
|
38
|
+
YELLOW = Back.YELLOW
|
|
39
|
+
LIGHT_YELLOW = Back.LIGHTYELLOW_EX
|
|
40
|
+
GREEN = Back.GREEN
|
|
41
|
+
LIGHT_GREEN = Back.LIGHTGREEN_EX
|
|
42
|
+
CYAN = Back.CYAN
|
|
43
|
+
LIGHT_CYAN = Back.LIGHTCYAN_EX
|
|
44
|
+
MAGENTA = Back.MAGENTA
|
|
45
|
+
LIGHT_MAGENTA = Back.LIGHTMAGENTA_EX
|
|
46
|
+
BLACK = Back.BLACK
|
|
47
|
+
LIGHT_BLACK = Back.LIGHTBLACK_EX
|
|
48
|
+
WHITE = Back.WHITE
|
|
49
|
+
LIGHT_WHITE = Back.LIGHTWHITE_EX
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
class Styles(StrEnum):
|
|
53
|
+
BRIGHT = Style.BRIGHT
|
|
54
|
+
NORMAL = Style.NORMAL
|
|
55
|
+
DIM = Style.DIM
|
|
56
|
+
RESET_ALL = Style.RESET_ALL
|
|
57
|
+
|
|
58
|
+
# print(f"{BackgroundColors.WHITE}{TextColors.BLACK}sdfsdfsdfsdf{Styles.RESET_ALL}")
|
|
File without changes
|
|
File without changes
|