This commit is contained in:
BarsTiger
2021-12-31 22:39:01 +02:00
parent f3cf6f3d83
commit fc86ee6132
4 changed files with 9 additions and 12 deletions

View File

@@ -3,7 +3,7 @@ Curses, on Linux pre-installed, on windows you need windows-curses, so you can i
Or just add to your code:
```python
import ezztui
ezztui.check_curses()
ezztui.check_curses() # not needed if you are using ezztui 2.0.0 or later, it will check for curses automatically
```
# Use
@@ -18,7 +18,6 @@ Backspace: Go back
## Print text on center of console
```python
import ezztui
ezztui.check_curses() # check and install windows-curses, if on windows
ezztui.center_message("Hello World!") # prints "Hello World!" on the center of the console
ezztui.center_multiline(["Hello", "multiline", "world!"]) # prints "Hello" on the center of the console, then "multiline" on the next line, then "world!" on the next line
```
@@ -26,7 +25,6 @@ ezztui.center_multiline(["Hello", "multiline", "world!"]) # prints "Hello" on th
## Clear console
```python
import ezztui
ezztui.check_curses() # check and install windows-curses, if on windows
ezztui.cls() # clears the console with a os.system command
ezztui.softcls() # clears the console with a multiple newline
```
@@ -34,15 +32,14 @@ ezztui.softcls() # clears the console with a multiple newline
### Usage
```python
import ezztui
ezztui.check_curses() # check and install windows-curses, if on windows
menu = {
'First menu':
{'Function 1': 'ezztui_return_value',
{'Function 1': 'ezztui_return_value', # use 'return' also from 2.0.0
'Function 2': 'ezztui_return_value',
'Function 3': 'ezztui_return_value',
'Function 4': 'ezztui_return_value',
'Function 5': 'ezztui_return_value',
'Back': 'ezztui_back_value'},
'Back': 'ezztui_back_value'}, # use 'back' also from 2.0.0
'Second menu':
{'Submenu 1': {
@@ -80,7 +77,7 @@ menu = {
'Exit':
{"Exit": 'ezztui_exit_value',
"Back": 'ezztui_back_value'}
"Back": 'ezztui_back_value'} # use 'exit' also from 2.0.0
}
print(ezztui.menu(menu)) # prints the menu and returns name of function and path to it in menu,

View File

@@ -1 +1 @@
from ezztui import *
from ezztui import *

View File

@@ -85,12 +85,12 @@ def menu(menulist: dict):
currentmenu = currentmenu[list(currentmenu.keys())[current_row]]
break
elif key == curses.KEY_ENTER or key in [10, 13] and currentmenu[list(currentmenu.keys())[current_row]] == 'ezztui_return_value':
elif key == curses.KEY_ENTER or key in [10, 13] and currentmenu[list(currentmenu.keys())[current_row]] in ['ezztui_return_value', 'return']:
menupath.append(list(currentmenu)[current_row])
returning = menupath
break
elif key == curses.KEY_BACKSPACE or str(key) in ['KEY_BACKSPACE', '8', '127'] or currentmenu[list(currentmenu.keys())[current_row]] == 'ezztui_back_value':
elif key == curses.KEY_BACKSPACE or str(key) in ['KEY_BACKSPACE', '8', '127'] or currentmenu[list(currentmenu.keys())[current_row]] in ['ezztui_back_value', 'back']:
menupath = menupath[:-1:]
try:
currentmenu = menulist[list(menupath)[0]]
@@ -101,7 +101,7 @@ def menu(menulist: dict):
mainmenu(stdscr)
break
elif key == curses.KEY_ENTER or key in [10, 13] and currentmenu[list(currentmenu.keys())[current_row]] == 'ezztui_exit_value':
elif key == curses.KEY_ENTER or key in [10, 13] and currentmenu[list(currentmenu.keys())[current_row]] in ['ezztui_exit_value', 'exit']:
exit()
print_menu(stdscr, current_row, currentmenu)

View File

@@ -5,7 +5,7 @@ with open("README.md", "r") as fh:
setup(
name="ezztui",
version="1.0.0",
version="2.0.0",
scripts=["ezztui.py"],
author="BarsTiger",
description="Easy TextUI creating package",