2
This commit is contained in:
11
README.md
11
README.md
@@ -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:
|
Or just add to your code:
|
||||||
```python
|
```python
|
||||||
import ezztui
|
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
|
# Use
|
||||||
@@ -18,7 +18,6 @@ Backspace: Go back
|
|||||||
## Print text on center of console
|
## Print text on center of console
|
||||||
```python
|
```python
|
||||||
import ezztui
|
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_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
|
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
|
## Clear console
|
||||||
```python
|
```python
|
||||||
import ezztui
|
import ezztui
|
||||||
ezztui.check_curses() # check and install windows-curses, if on windows
|
|
||||||
ezztui.cls() # clears the console with a os.system command
|
ezztui.cls() # clears the console with a os.system command
|
||||||
ezztui.softcls() # clears the console with a multiple newline
|
ezztui.softcls() # clears the console with a multiple newline
|
||||||
```
|
```
|
||||||
@@ -34,15 +32,14 @@ ezztui.softcls() # clears the console with a multiple newline
|
|||||||
### Usage
|
### Usage
|
||||||
```python
|
```python
|
||||||
import ezztui
|
import ezztui
|
||||||
ezztui.check_curses() # check and install windows-curses, if on windows
|
|
||||||
menu = {
|
menu = {
|
||||||
'First 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 2': 'ezztui_return_value',
|
||||||
'Function 3': 'ezztui_return_value',
|
'Function 3': 'ezztui_return_value',
|
||||||
'Function 4': 'ezztui_return_value',
|
'Function 4': 'ezztui_return_value',
|
||||||
'Function 5': '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':
|
'Second menu':
|
||||||
{'Submenu 1': {
|
{'Submenu 1': {
|
||||||
@@ -80,7 +77,7 @@ menu = {
|
|||||||
|
|
||||||
'Exit':
|
'Exit':
|
||||||
{"Exit": 'ezztui_exit_value',
|
{"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,
|
print(ezztui.menu(menu)) # prints the menu and returns name of function and path to it in menu,
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
from ezztui import *
|
from ezztui import *
|
||||||
|
|||||||
@@ -85,12 +85,12 @@ def menu(menulist: dict):
|
|||||||
currentmenu = currentmenu[list(currentmenu.keys())[current_row]]
|
currentmenu = currentmenu[list(currentmenu.keys())[current_row]]
|
||||||
break
|
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])
|
menupath.append(list(currentmenu)[current_row])
|
||||||
returning = menupath
|
returning = menupath
|
||||||
break
|
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:]
|
menupath = menupath[:-1:]
|
||||||
try:
|
try:
|
||||||
currentmenu = menulist[list(menupath)[0]]
|
currentmenu = menulist[list(menupath)[0]]
|
||||||
@@ -101,7 +101,7 @@ def menu(menulist: dict):
|
|||||||
mainmenu(stdscr)
|
mainmenu(stdscr)
|
||||||
break
|
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()
|
exit()
|
||||||
|
|
||||||
print_menu(stdscr, current_row, currentmenu)
|
print_menu(stdscr, current_row, currentmenu)
|
||||||
|
|||||||
2
setup.py
2
setup.py
@@ -5,7 +5,7 @@ with open("README.md", "r") as fh:
|
|||||||
|
|
||||||
setup(
|
setup(
|
||||||
name="ezztui",
|
name="ezztui",
|
||||||
version="1.0.0",
|
version="2.0.0",
|
||||||
scripts=["ezztui.py"],
|
scripts=["ezztui.py"],
|
||||||
author="BarsTiger",
|
author="BarsTiger",
|
||||||
description="Easy TextUI creating package",
|
description="Easy TextUI creating package",
|
||||||
|
|||||||
Reference in New Issue
Block a user