Console bugfixes

This commit is contained in:
Sven Heidemann 2021-03-15 18:36:59 +01:00
parent 6596364027
commit 57bae9f291
8 changed files with 34 additions and 5 deletions

2
.gitignore vendored
View File

@ -37,7 +37,7 @@ MANIFEST
pip-log.txt pip-log.txt
pip-delete-this-directory.txt pip-delete-this-directory.txt
# Unit test / coverage reports # Unit model / coverage reports
htmlcov/ htmlcov/
.tox/ .tox/
.nox/ .nox/

View File

@ -4,7 +4,7 @@
"Version": { "Version": {
"Major": "2021", "Major": "2021",
"Minor": "04", "Minor": "04",
"Micro": "01-4" "Micro": "01-5"
}, },
"Author": "Sven Heidemann", "Author": "Sven Heidemann",
"AuthorEmail": "sven.heidemann@sh-edraft.de", "AuthorEmail": "sven.heidemann@sh-edraft.de",

View File

@ -155,7 +155,11 @@ class Console:
for i in range(0, len(cls._select_menu_items)): for i in range(0, len(cls._select_menu_items)):
Console.set_foreground_color(cls._selected_menu_cursor_foreground_color) Console.set_foreground_color(cls._selected_menu_cursor_foreground_color)
Console.set_background_color(cls._selected_menu_cursor_background_color) Console.set_background_color(cls._selected_menu_cursor_background_color)
Console.write_line(f'{cls._selected_menu_item_char if cls._selected_menu_item_index == i else " "} ') placeholder = ''
for _ in cls._selected_menu_item_char:
placeholder += ' '
Console.write_line(f'{cls._selected_menu_item_char if cls._selected_menu_item_index == i else placeholder} ')
Console.set_foreground_color(cls._selected_menu_option_foreground_color) Console.set_foreground_color(cls._selected_menu_option_foreground_color)
Console.set_background_color(cls._selected_menu_option_background_color) Console.set_background_color(cls._selected_menu_option_background_color)
Console.write(f'{cls._select_menu_items[i]}') Console.write(f'{cls._select_menu_items[i]}')

View File

@ -16,7 +16,7 @@
"LicenseName": "", "LicenseName": "",
"LicenseDescription": "", "LicenseDescription": "",
"Dependencies": [ "Dependencies": [
"sh_cpl==2021.4.1.post3" "sh_cpl==2021.4.1.post4"
], ],
"PythonVersion": ">=3.9.2", "PythonVersion": ">=3.9.2",
"Classifiers": [] "Classifiers": []

View File

@ -1,9 +1,12 @@
from cpl.console.console import Console from cpl.console.console import Console
from model.test_model import TestModel
def main(): def main():
Console.write_line('Hello World') Console.write_line('Hello World')
Console.write_line('Dies ist ein test') Console.write_line('Dies ist ein test')
test = TestModel()
if __name__ == '__main__': if __name__ == '__main__':

View File

@ -0,0 +1,22 @@
import time
from cpl.console import Console
class TestModel:
def __init__(self):
Console.spinner('Waiting: ', self._wait, 3)
option = Console.select('->', 'Select option: ', [
'Option 1',
'Option 2',
'Option 3',
'Option 4',
'Option 5',
'Option 6'
])
Console.write_line('You selected', option)
@staticmethod
def _wait(count: int):
time.sleep(count)

View File

@ -27,7 +27,7 @@ class Application(ApplicationABC):
self._mailer.send_mail(mail) self._mailer.send_mail(mail)
def test_console(self): def test_console(self):
self._logger.debug(__name__, 'Started console_old test') self._logger.debug(__name__, 'Started console_old model')
Console.write_line('Hello World') Console.write_line('Hello World')
Console.write('\nName: ') Console.write('\nName: ')
Console.write_line(' Hello', Console.read_line()) Console.write_line(' Hello', Console.read_line())