cpl_core.console
cpl_core.console.background_color_enum
cpl_core.console.console
- class cpl_core.console.console.Console
Bases:
object
Useful functions for handling with input and output
- class property background_color: str
str(object=’’) -> str str(bytes_or_buffer[, encoding[, errors]]) -> str
Create a new string object from the given object. If encoding or errors is specified, then the object must expose a data buffer that will be decoded using the given encoding and error handler. Otherwise, returns the result of object.__str__() (if defined) or repr(object). encoding defaults to sys.getdefaultencoding(). errors defaults to ‘strict’.
- classmethod banner(string: str)
Prints the string as a banner
- string:
str
Message to print as banner
- string:
- classmethod clear()
Clears the console
- classmethod close()
Closes the application
- classmethod color_reset()
Resets the color settings
- classmethod disable()
Disables console interaction
- classmethod enable()
Enables console interaction
- classmethod error(string: str, tb: Optional[str] = None)
Prints an error with traceback
- string:
str
Error message
- tb:
str
Error traceback
- string:
- class property foreground_color: str
str(object=’’) -> str str(bytes_or_buffer[, encoding[, errors]]) -> str
Create a new string object from the given object. If encoding or errors is specified, then the object must expose a data buffer that will be decoded using the given encoding and error handler. Otherwise, returns the result of object.__str__() (if defined) or repr(object). encoding defaults to sys.getdefaultencoding(). errors defaults to ‘strict’.
- classmethod read(output: Optional[str] = None) str
Reads in line
- output:
str
String to print before input
input()
- output:
- classmethod read_line(output: Optional[str] = None) str
Reads in next line
- output:
str
String to print before input
input()
- output:
- classmethod reset_cursor_position()
Resets cursor position
- classmethod select(char: str, message: str, options: list[str], header_foreground_color: Union[str, ForegroundColorEnum] = ForegroundColorEnum.default, header_background_color: Union[str, BackgroundColorEnum] = BackgroundColorEnum.default, option_foreground_color: Union[str, ForegroundColorEnum] = ForegroundColorEnum.default, option_background_color: Union[str, BackgroundColorEnum] = BackgroundColorEnum.default, cursor_foreground_color: Union[str, ForegroundColorEnum] = ForegroundColorEnum.default, cursor_background_color: Union[str, BackgroundColorEnum] = BackgroundColorEnum.default) str
Prints select menu
- char:
str
Character to show which element is selected
- message:
str
Message or header of the selection
- options: List[
str
] Selectable options
- header_foreground_color: Union[
str
,cpl_core.console.foreground_color_enum.ForegroundColorEnum
] Foreground color of the header
- header_background_color: Union[
str
,cpl_core.console.background_color_enum.BackgroundColorEnum
] Background color of the header
- option_foreground_color: Union[
str
,cpl_core.console.foreground_color_enum.ForegroundColorEnum
] Foreground color of the options
- option_background_color: Union[
str
,cpl_core.console.background_color_enum.BackgroundColorEnum
] Background color of the options
- cursor_foreground_color: Union[
str
,cpl_core.console.foreground_color_enum.ForegroundColorEnum
] Foreground color of the cursor
- cursor_background_color: Union[
str
,cpl_core.console.background_color_enum.BackgroundColorEnum
] Background color of the cursor
Selected option as
str
- char:
- classmethod set_background_color(color: Union[BackgroundColorEnum, str])
Sets the background color
- color: Union[
cpl_core.console.background_color_enum.BackgroundColorEnum
,str
] Background color of the console
- color: Union[
- classmethod set_cursor_position(x: int, y: int)
Sets cursor position
- x:
int
X coordinate
- y:
int
Y coordinate
- x:
- classmethod set_foreground_color(color: Union[ForegroundColorEnum, str])
Sets the foreground color
- color: Union[
cpl_core.console.background_color_enum.BackgroundColorEnum
,str
] Foreground color of the console
- color: Union[
- classmethod set_hold_back(value: bool)
- classmethod spinner(message: str, call: Callable, *args, text_foreground_color: Optional[Union[str, ForegroundColorEnum]] = None, spinner_foreground_color: Optional[Union[str, ForegroundColorEnum]] = None, text_background_color: Optional[Union[str, BackgroundColorEnum]] = None, spinner_background_color: Optional[Union[str, BackgroundColorEnum]] = None, **kwargs) any
Shows spinner and calls given function, when function has ended the spinner stops
- message:
str
Message of the spinner
- call:
Callable
Function to call
- args:
list
Arguments of the function
- text_foreground_color: Union[
str
,cpl_core.console.foreground_color_enum.ForegroundColorEnum
] Foreground color of the text
- spinner_foreground_color: Union[
str
,cpl_core.console.foreground_color_enum.ForegroundColorEnum
] Foreground color of the spinner
- text_background_color: Union[
str
,cpl_core.console.background_color_enum.BackgroundColorEnum
] Background color of the text
- spinner_background_color: Union[
str
,cpl_core.console.background_color_enum.BackgroundColorEnum
] Background color of the spinner
- kwargs:
dict
Keyword arguments of the call
Return value of call
- message:
- classmethod table(header: list[str], values: list[list[str]])
Prints a table with header and values
- header: List[
str
] Header of the table
- values: List[List[
str
]] Values of the table
- header: List[
- classmethod write(*args, end='')
Prints in active line
- args:
list
Elements to print
- end:
str
Last character to print
- args:
- classmethod write_at(x: int, y: int, *args)
Prints at given position
- x:
int
X coordinate
- y:
int
Y coordinate
- args:
list
Elements to print
- x:
- classmethod write_line(*args)
Prints to new line
- args:
list
Elements to print
- args:
- classmethod write_line_at(x: int, y: int, *args)
Prints new line at given position
- x:
int
X coordinate
- y:
int
Y coordinate
- args:
list
Elements to print
- x:
cpl_core.console.console_call
cpl_core.console.foreground_color_enum
cpl_core.console.spinner_thread
- class cpl_core.console.spinner_thread.SpinnerThread(msg_len: int, foreground_color: ForegroundColorEnum, background_color: BackgroundColorEnum)
Bases:
Thread
Thread to show spinner in terminal
- msg_len:
int
Length of the message
- foreground_color:
cpl_core.console.foreground_color.ForegroundColorEnum
Foreground color of the spinner
- background_color:
cpl_core.console.background_color.BackgroundColorEnum
Background color of the spinner
- exit()
Stops the spinner
- run() None
Entry point of thread, shows the spinner
- stop_spinning()
Stops the spinner
- msg_len: