2021.4.1 #11

Merged
edraft merged 172 commits from 2021.04.01 into 2021.04 2021-03-21 20:04:24 +01:00
4 changed files with 16 additions and 9 deletions
Showing only changes of commit 26ec121079 - Show all commits

View File

@ -1,4 +1,6 @@
import os
import sys
import time
from collections import Callable
from typing import Union, Optional
@ -148,7 +150,7 @@ class Console:
"""
if not cls._is_first_select_menu_output:
for _ in range(0, len(cls._select_menu_items) + 1):
print('\b', end="\r")
sys.stdout.write('\x1b[1A\x1b[2K')
else:
cls._is_first_select_menu_output = False
@ -159,7 +161,8 @@ class Console:
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.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_background_color(cls._selected_menu_option_background_color)
Console.write(f'{cls._select_menu_items[i]}')
@ -373,7 +376,7 @@ class Console:
Console.set_foreground_color(header_foreground_color)
Console.set_background_color(header_background_color)
Console.write_line(message)
Console.write_line(message, '\n')
cls._show_select_menu()
with keyboard.Listener(
@ -434,10 +437,11 @@ class Console:
return return_value
@classmethod
def write(cls, *args):
def write(cls, *args, end=''):
"""
Prints in active line
:param args:
:param end:
:return:
"""
if cls._disabled:
@ -448,7 +452,7 @@ class Console:
return
string = ' '.join(map(str, args))
cls._output(string, end='')
cls._output(string, end=end)
@classmethod
def write_at(cls, x: int, y: int, *args):

View File

@ -58,7 +58,10 @@ class SpinnerThread(threading.Thread):
rows, columns = os.popen('stty size', 'r').read().split()
end_msg = 'done'
columns = int(columns) - self._msg_len - len(end_msg)
if columns > 0:
print(f'{"" : >{columns}}', end='')
else:
print('', end='')
spinner = self._spinner()
while self._is_spinning:
print(colored(f'{next(spinner): >{len(end_msg)}}', *self._get_color_args()), end='')

View File

@ -7,7 +7,7 @@ def test_spinner():
if __name__ == '__main__':
Console.write_line('Hello World')
Console.write_line('Hello World\n')
Console.spinner('Test:', test_spinner, spinner_foreground_color=ForegroundColorEnum.cyan, text_foreground_color='green')
opts = [
'Option 1',
@ -23,4 +23,4 @@ if __name__ == '__main__':
option_foreground_color=ForegroundColorEnum.green,
cursor_foreground_color=ForegroundColorEnum.red
)
Console.write_line(f'You selected: {selected}')
Console.write_line(f'You selected: {selected}\n')

View File

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