framed_text package
Submodules
framed_text.color module
- class framed_text.color.Color(color: str | tuple | Color | None = None, mode: Literal['rgb', 'hex', 'hsl', 'hsv'] = 'rgb')[source]
Bases:
object- __init__(color: str | tuple | Color | None = None, mode: Literal['rgb', 'hex', 'hsl', 'hsv'] = 'rgb')[source]
Converts a color to a termcolor-supported color
Available Color Types
Termcolor color code (Any)
RGB tuple (rgb)
HEX code (hex)
HSV code (hsv)
HSL code (hsl)
- Parameters:
color – Color to convert
mode – Color type
framed_text.frame_chain module
- class framed_text.frame_chain.FrameChain(frames: list[FramedText], inherit_from: FramedText | None = None, layout: Literal['vertical', 'horizontal'] = 'vertical', columns: int | None = None, cutoff_mode: Literal['char', 'word', 'middle'] = 'char', group_title: str | None = None, show_titles: bool = True, frame_color: str | tuple[int, int, int] | Color | None = None, title_color: str | tuple[int, int, int] | Color | None = None, g_title_color: str | tuple[int, int, int] | Color | None = None, title_attrs: list[str] | None = None, g_title_attrs: list[str] | None = None)[source]
Bases:
object- __init__(frames: list[FramedText], inherit_from: FramedText | None = None, layout: Literal['vertical', 'horizontal'] = 'vertical', columns: int | None = None, cutoff_mode: Literal['char', 'word', 'middle'] = 'char', group_title: str | None = None, show_titles: bool = True, frame_color: str | tuple[int, int, int] | Color | None = None, title_color: str | tuple[int, int, int] | Color | None = None, g_title_color: str | tuple[int, int, int] | Color | None = None, title_attrs: list[str] | None = None, g_title_attrs: list[str] | None = None)[source]
Chains multiple
FramedTextobjects into a single object.Each
FramedText’s text and title are preservedProviding a
FramedTexttoinherit_fromwill inherit the following to the whole group:frame_colortitle_color(Also applies tog_title_color)title_attrs(Also applies tog_title_attrs)
Layouts:
vertical: Stacks frames verticallyhorizontal: Places frames side by side
Column Sizes:
static: Fixed column size for all columns. Based on 1st frameeven: Evenly distribute column size (term width / n columns)
NOTE:
cutoffis forced enabled forJoinFramesCutoff Modes:
char: Cutoff char at end of text (The quick brown fox jumped ove…)word: Cutoff word at end of text (The quick brown fox jumped…)middle: Cutoff chars at middle of text (The quick brown…the lazy dog)
- Parameters:
frames – List of
FramedTextobjects to group together.inherit_from –
FramedTextobject to inherit styling variables from.layout – The layout of the frames. Vertical will wrap frames to next line if exceeds terminal width.
columns – Will cap the number of columns to this value when using horizontal layout. If blank, will use recommended value.
cutoff_mode – Mode for cutoff. “char” for character cutoff, “word” for word cutoff, “middle” for middle cutoff.
group_title – If provided, will add a title for the whole group.
show_titles – If True, will display each frame’s title.
frame_color – Color for the frame. Overrides value from
inherit_from.title_color – Color for each frame’s title. Overrides value from
inherit_from.g_title_color – Color for the group title. Overrides value from
inherit_from.title_attrs – Attributes for each frame’s title. Overrides value from
inherit_from.g_title_attrs – Attributes for the group title. Overrides value from
inherit_from.
framed_text.framed_header module
- class framed_text.framed_header.FramedHeader(title: str = '', divider: str = '─', frame_color: str | tuple[int, int, int] | Color | None = None, title_color: str | tuple[int, int, int] | Color | None = None, title_attrs: list[str] | None = None)[source]
Bases:
object- __init__(title: str = '', divider: str = '─', frame_color: str | tuple[int, int, int] | Color | None = None, title_color: str | tuple[int, int, int] | Color | None = None, title_attrs: list[str] | None = None)[source]
Creates a string with a customizable divider. Can include a title. Matches the style of FramedText.
Attributes:
All
termcolorattributes are supported:"bold","dark","italic","underline","reverse","concealed","strike"- Parameters:
title – Title to display in the header
frame_color – Color of the frame. Valid colors based off of termcolor’s color options: string color code or RGB tuple
title_color – Color of the title. Valid colors based off of termcolor’s color options: string color code or RGB tuple
divider – Divider to use. Will be repeated to fill the terminal width
title_attrs – Attributes to apply to the title. See list above for valid attributes
framed_text.framed_text module
- class framed_text.framed_text.FramedText(text: str | String | Number | Boolean | Path | Date | Bytes | Info | Action | Success | Fail | Warn | Hidden | list[str | String | Number | Boolean | Path | Date | Bytes | Info | Action | Success | Fail | Warn | Hidden] = '', title: str = '', cutoff: bool = True, mode: Literal['char', 'word', 'middle'] = 'char', center_text: bool = False, frame_size: Literal['full', 'dynamic'] = 'full', frame_align: Literal['left', 'center', 'right'] = 'left', frame_color: str | tuple[int, int, int] | Color | None = None, title_color: str | tuple[int, int, int] | Color | None = None, title_attrs: list[str] | None = None)[source]
Bases:
object- __init__(text: str | String | Number | Boolean | Path | Date | Bytes | Info | Action | Success | Fail | Warn | Hidden | list[str | String | Number | Boolean | Path | Date | Bytes | Info | Action | Success | Fail | Warn | Hidden] = '', title: str = '', cutoff: bool = True, mode: Literal['char', 'word', 'middle'] = 'char', center_text: bool = False, frame_size: Literal['full', 'dynamic'] = 'full', frame_align: Literal['left', 'center', 'right'] = 'left', frame_color: str | tuple[int, int, int] | Color | None = None, title_color: str | tuple[int, int, int] | Color | None = None, title_attrs: list[str] | None = None)[source]
Creates a string with a customizable frame around it. Frame is based off of prompt_toolkit’s show_frame option, but with more customization and designed for print statements.
Cutoff Modes:
char: Cutoff char at end of text (The quick brown fox jumped ove…)word: Cutoff word at end of text (The quick brown fox jumped…)middle: Cutoff chars at middle of text (The quick brown…the lazy dog)
Frame Sizes: -
full: Frame will be the size of the terminal -dynamic: Frame will be the size of the text based on longest line.Attributes:
All
termcolorattributes are supported:"bold","dark","italic","underline","reverse","concealed","strike"NOTE:
allow_ansionly applies to strings- Parameters:
text – Text to be framed. Can be a regular string or a LabeledData object
title – Title of the frame
mode – Mode for cutoff. “char” for character cutoff, “word” for word cutoff, “middle” for middle cutoff
frame_color – Color of the frame. Valid colors based off of termcolor’s color options: string color code or RGB tuple
title_color – Color of the title. Valid colors based off of termcolor’s color options: string color code or RGB tuple
cutoff – If true, cut off text if it exceeds terminal width. Default is True (Recommended)
center_text – If True, centers the text inside frame. Ignored if
frame_sizeis “dynamic”frame_size – Size of the frame. “full” for terminal size, “dynamic” for text size
frame_align – Align of the frame. Only used if
frame_sizeis “dynamic”title_attrs – Attributes to apply to the title. See list above for valid attributes
- property longest_line: int
- Returns:
Longest line of the text
- property title: str
- Returns:
Title of the frame
- property title_attrs: list[str] | None
- Returns:
Attributes to apply to the title.
framed_text.labeled_data module
- class framed_text.labeled_data.LabeledData[source]
Bases:
objectClass for creating a string with a label and different types of data. Each item can be configured to include colored text.
- class Boolean(label: str, value: bool, suffix: str = '', t_text: str = 'True', f_text: str = 'False', quotes: bool = False, colon_match: bool = True, no_colon: bool = False, label_color: str | tuple[int, int, int] | Color | None = None, t_color: str | tuple[int, int, int] | Color | None = 'green', f_color: str | tuple[int, int, int] | Color | None = 'red', suffix_color: str | tuple[int, int, int] | Color | None = None, label_attrs: list[str] | None = None, val_attrs: list[str] | None = None, suffix_attrs: list[str] | None = None)[source]
Bases:
_Base- __init__(label: str, value: bool, suffix: str = '', t_text: str = 'True', f_text: str = 'False', quotes: bool = False, colon_match: bool = True, no_colon: bool = False, label_color: str | tuple[int, int, int] | Color | None = None, t_color: str | tuple[int, int, int] | Color | None = 'green', f_color: str | tuple[int, int, int] | Color | None = 'red', suffix_color: str | tuple[int, int, int] | Color | None = None, label_attrs: list[str] | None = None, val_attrs: list[str] | None = None, suffix_attrs: list[str] | None = None)[source]
Creates a string with a label and boolean value
- Parameters:
label – Label for boolean value.
value – Boolean value.
suffix – Optional text to appear after the value.
t_text – Text to display for true value.
f_text – Text to display for false value.
quotes – If true, wrap text in single quotes (‘)
colon_match – If true, the colon will match the style of the label.
no_colon – If true, the colon will be removed. Overrides
colon_matchlabel_color – Color of label.
t_color – Color of true value.
f_color – Color of false value.
suffix_color – Color of suffix.
label_attrs – Attributes to apply to the label.
val_attrs – Attributes to apply to the value.
suffix_attrs – Attributes to apply to the suffix.
- cutoff_text(limit: int) str[source]
Cuts off text if it exceeds limit. Will first try to shorten bool value. If there isn’t enough space for just an ellipsis, it will try to shorten the label, so that the output will be 50/50 (label: value).
- Parameters:
limit – Maximum length of text
- Returns:
Shortened text
- class Bytes(label: str, value: int, suffix: str = '', quotes: bool = False, colon_match: bool = True, no_colon: bool = False, unit_match: bool = True, show_unit: bool = True, unit_type: Literal['iec', 'si'] = 'iec', label_color: str | tuple[int, int, int] | Color | None = None, val_color: str | tuple[int, int, int] | Color | None = 'yellow', unit_color: str | tuple[int, int, int] | Color | None = None, suffix_color: str | tuple[int, int, int] | Color | None = None, label_attrs: list[str] | None = None, val_attrs: list[str] | None = None, unit_attrs: list[str] | None = None, suffix_attrs: list[str] | None = None)[source]
Bases:
_Base- __init__(label: str, value: int, suffix: str = '', quotes: bool = False, colon_match: bool = True, no_colon: bool = False, unit_match: bool = True, show_unit: bool = True, unit_type: Literal['iec', 'si'] = 'iec', label_color: str | tuple[int, int, int] | Color | None = None, val_color: str | tuple[int, int, int] | Color | None = 'yellow', unit_color: str | tuple[int, int, int] | Color | None = None, suffix_color: str | tuple[int, int, int] | Color | None = None, label_attrs: list[str] | None = None, val_attrs: list[str] | None = None, unit_attrs: list[str] | None = None, suffix_attrs: list[str] | None = None)[source]
Creates a string with a label and bytes value
- Parameters:
label – Label for string value
value – Integer value. Value MUST be in bytes
suffix – Optional text to appear after the value
quotes – If true, wrap text in single quotes (‘)
colon_match – If true, the colon will match the style of the label.
no_colon – If true, the colon will be removed. Overrides
colon_matchshow_unit – If true, the unit will be shown.
unit_match – If true, the unit will match the style of the value.
unit_type – Unit type: IEC is base 2, SI is base 10
label_color – Color of label.
val_color – Color of string value.
unit_color – Color of unit. Overrides
unit_match.suffix_color – Color of suffix.
label_attrs – Attributes to apply to the label.
val_attrs – Attributes to apply to the value.
unit_attrs – Attributes to apply to the unit. Overrides
unit_match.suffix_attrs – Attributes to apply to the suffix.
- cutoff_text(limit: int) str[source]
Cuts off text if it exceeds limit. Will NOT shorten the value, only suffix (if there is one). If there isn’t enough space for just an ellipsis, it will try to shorten the label, so that the output will be 50/50 (label: value).
- Parameters:
limit – Maximum length of text
- Returns:
Shortened text
- class Date(label: str, value: str | datetime = '', suffix: str = '', quotes: bool = True, colon_match: bool = True, no_colon: bool = False, strftime: str = '%Y-%m-%d %H:%M:%S', label_color: str | tuple[int, int, int] | Color | None = None, val_color: str | tuple[int, int, int] | Color | None = 'blue', suffix_color: str | tuple[int, int, int] | Color | None = None, label_attrs: list[str] | None = None, val_attrs: list[str] | None = None, suffix_attrs: list[str] | None = None)[source]
Bases:
_Base- __init__(label: str, value: str | datetime = '', suffix: str = '', quotes: bool = True, colon_match: bool = True, no_colon: bool = False, strftime: str = '%Y-%m-%d %H:%M:%S', label_color: str | tuple[int, int, int] | Color | None = None, val_color: str | tuple[int, int, int] | Color | None = 'blue', suffix_color: str | tuple[int, int, int] | Color | None = None, label_attrs: list[str] | None = None, val_attrs: list[str] | None = None, suffix_attrs: list[str] | None = None)[source]
Creates a string with a label and a date value
If no value is passed, will print current time using
strftimeparameter :param label: Label for string value :param value: Value, either as a datetime object or string :param suffix: Optional text to appear after the value :param quotes: If true, wrap text in single quotes (‘) :param colon_match: If true, the colon will match the style of the label. :param no_colon: If true, the colon will be removed. Overridescolon_match:param strftime: Formatter for datetime value :param label_color: Color of label. :param val_color: Color of string value. :param suffix_color: Color of suffix. :param label_attrs: Attributes to apply to the label. :param val_attrs: Attributes to apply to the value. :param suffix_attrs: Attributes to apply to the suffix.
- cutoff_text(limit: int) str[source]
Cuts off text if it exceeds limit. Will first try to shorten string. If there isn’t enough space for just an ellipsis, it will try to shorten the label, so that the output will be 50/50 (label: value).
- Parameters:
limit – Maximum length of text
- Returns:
Shortened text
- class Number(label: str, value: int | float, suffix: str = '', quotes: bool = False, colon_match: bool = True, no_colon: bool = False, round_to: int | None = None, leading_zeros: int | None = None, int_no_round: bool = False, label_color: str | tuple[int, int, int] | Color | None = None, val_color: str | tuple[int, int, int] | Color | None = 'yellow', suffix_color: str | tuple[int, int, int] | Color | None = None, label_attrs: list[str] | None = None, val_attrs: list[str] | None = None, suffix_attrs: list[str] | None = None)[source]
Bases:
_Base- __init__(label: str, value: int | float, suffix: str = '', quotes: bool = False, colon_match: bool = True, no_colon: bool = False, round_to: int | None = None, leading_zeros: int | None = None, int_no_round: bool = False, label_color: str | tuple[int, int, int] | Color | None = None, val_color: str | tuple[int, int, int] | Color | None = 'yellow', suffix_color: str | tuple[int, int, int] | Color | None = None, label_attrs: list[str] | None = None, val_attrs: list[str] | None = None, suffix_attrs: list[str] | None = None)[source]
Creates a string with a label and number value
- Parameters:
label – Label for number value
value – Number value
suffix – Optional text to appear after the value
quotes – If true, wrap text in single quotes (‘)
colon_match – If true, the colon will match the style of the label.
no_colon – If true, the colon will be removed. Overrides
colon_matchround_to – Number of decimal places to round to. Leave blank to not round.
leading_zeros – Number of leading zeros to add to the number. Leave blank to not add leading zeros.
int_no_round – If true, displays number as integer without rounding. Overrides
round_tolabel_color – Color of label.
val_color – Color of number value.
suffix_color – Color of suffix.
label_attrs – Attributes to apply to the label.
val_attrs – Attributes to apply to the value.
suffix_attrs – Attributes to apply to the suffix.
- cutoff_text(limit: int) str[source]
Cuts off text if it exceeds limit. Will NOT shorten the number, only the suffix (if there is one). If there isn’t enough space for just an ellipsis, it will try to shorten the label, so that the output will be 50/50 (label: value).
- Parameters:
limit – Maximum length of text
- Returns:
Shortened text
- class Path(label: str, value: Path | str, suffix: str = '', quotes: bool = True, colon_match: bool = True, no_colon: bool = False, label_color: str | tuple[int, int, int] | Color | None = None, val_color: str | tuple[int, int, int] | Color | None = 'cyan', suffix_color: str | tuple[int, int, int] | Color | None = None, label_attrs: list[str] | None = None, val_attrs: list[str] | None = None, suffix_attrs: list[str] | None = None)[source]
Bases:
_Base- __init__(label: str, value: Path | str, suffix: str = '', quotes: bool = True, colon_match: bool = True, no_colon: bool = False, label_color: str | tuple[int, int, int] | Color | None = None, val_color: str | tuple[int, int, int] | Color | None = 'cyan', suffix_color: str | tuple[int, int, int] | Color | None = None, label_attrs: list[str] | None = None, val_attrs: list[str] | None = None, suffix_attrs: list[str] | None = None)[source]
Creates a string with a label and path to a file or directory
- Parameters:
label – Label for path
value – Path to file or directory
suffix – Optional text to appear after the value
quotes – If true, wrap path in single quotes (‘)
colon_match – If true, the colon will match the style of the label.
no_colon – If true, the colon will be removed. Overrides
colon_matchlabel_color – Color of label.
val_color – Color of path value.
suffix_color – Color of suffix.
label_attrs – Attributes to apply to the label.
val_attrs – Attributes to apply to the value.
suffix_attrs – Attributes to apply to the suffix.
- cutoff_text(limit: int, mode: Literal['char', 'word', 'middle'] = 'char') str[source]
Shortens path to limit.
Modes: - char: Cutoff char at end of string (/path/to/a/f…) - word: Cutoff path at end, preserve the deepest directory/file (/path/to/…/file.txt) - middle: Cutoff chars at middle of string (/long/path/t…/an/file.txt)
- Parameters:
limit – Character limit for full labeled path string
mode – How to cut off path.
- Returns:
LabeledData.Path string with shortened path if it exceeds limit, else returns original string
- class String(label: str, value: str, suffix: str = '', quotes: bool = True, colon_match: bool = True, no_colon: bool = False, label_color: str | tuple[int, int, int] | Color | None = None, val_color: str | tuple[int, int, int] | Color | None = 'cyan', suffix_color: str | tuple[int, int, int] | Color | None = None, label_attrs: list[str] | None = None, val_attrs: list[str] | None = None, suffix_attrs: list[str] | None = None)[source]
Bases:
_Base- __init__(label: str, value: str, suffix: str = '', quotes: bool = True, colon_match: bool = True, no_colon: bool = False, label_color: str | tuple[int, int, int] | Color | None = None, val_color: str | tuple[int, int, int] | Color | None = 'cyan', suffix_color: str | tuple[int, int, int] | Color | None = None, label_attrs: list[str] | None = None, val_attrs: list[str] | None = None, suffix_attrs: list[str] | None = None)[source]
Creates a string with a label and string value
- Parameters:
label – Label for string value
value – String value
suffix – Optional text to appear after the value
suffix_color – Color of suffix
val_color – Color of string value.
label_color – Color of label.
quotes – If true, wrap text in single quotes (‘)
colon_match – If true, the colon will match the style of the label.
no_colon – If true, the colon will be removed. Overrides
colon_matchval_attrs – Attributes to apply to the value.
label_attrs – Attributes to apply to the label.
- cutoff_text(limit: int, mode: Literal['char', 'word', 'middle'] = 'char') str[source]
Cuts off text if it exceeds limit. Will first try to shorten string. If there isn’t enough space for just an ellipsis, it will try to shorten the label, so that the output will be 50/50 (label: value).
Modes: - char: Cutoff char at end of string (The quick brown fox jumped ove…) - word: Cutoff word at end of string (The quick brown fox jumped…) - middle: Cutoff words at middle of string (The quick brown…the lazy dog)
- Parameters:
limit – Maximum length of text
mode – How to cut off value text
- Returns:
Shortened text
framed_text.progress_bar module
- class framed_text.progress_bar.ProgressBar(value: int, total: int, label: str = '', show_frame: bool = False, show_percent: bool = True, show_values: bool = False, safe_mode: bool = False, skip_init: bool = False, progress_icon: str = '#', empty_icon: str = '.', brackets: tuple[str, str] = ('[', ']'), value_color: str | tuple[int, int, int] | Color | None = None, label_color: str | tuple[int, int, int] | Color | None = None, percent_color: str | tuple[int, int, int] | Color | None = None, progress_color: str | tuple[int, int, int] | Color | None = None, empty_color: str | tuple[int, int, int] | Color | None = None, brackets_color: str | tuple[int, int, int] | Color | None = None, frame_color: str | tuple[int, int, int] | Color | None = None)[source]
Bases:
object- __init__(value: int, total: int, label: str = '', show_frame: bool = False, show_percent: bool = True, show_values: bool = False, safe_mode: bool = False, skip_init: bool = False, progress_icon: str = '#', empty_icon: str = '.', brackets: tuple[str, str] = ('[', ']'), value_color: str | tuple[int, int, int] | Color | None = None, label_color: str | tuple[int, int, int] | Color | None = None, percent_color: str | tuple[int, int, int] | Color | None = None, progress_color: str | tuple[int, int, int] | Color | None = None, empty_color: str | tuple[int, int, int] | Color | None = None, brackets_color: str | tuple[int, int, int] | Color | None = None, frame_color: str | tuple[int, int, int] | Color | None = None)[source]
Display a progress bar that shows the progress from a value to a total.
The progress bar will snap to the bottom of the terminal.
- Parameters:
value – Current value.
total – Total value.
label – Optional label for the Progress Bar.
show_frame – If true, will show a frame around the progress bar, similar to
FramedText.show_percent – If true, will show percentage of progress. Will replace values display unless
show_valuesis true.show_values – If true, will show current value and total value. If false and
show_percentis false, will not display any values.safe_mode – If true, will clear the terminal and move cursor to top to ensure room for progress bar and any other data.
skip_init – If true, will only initialize when
displayorupdate_progressis called.progress_icon – Icon used for the progress display.
empty_icon – Icon used for the empty space in the progress display.
brackets – Brackets to surround the progress display. First value is the left bracket, second value is the right bracket.
value_color – Color of the label.
label_color – Color of the label.
percent_color – Color of the percentage.
progress_color – Color of the progress display.
empty_color – Color of the empty space in the progress display.
brackets_color – Color of the brackets.
frame_color – Color of the frame.
- static force_reset(show_frame: bool = False, label: bool = False)[source]
Force resets the terminal. This should only be used in the
exceptblock of a try-except block.Make sure to pass the same values to this function that were passed to the
ProgressBarconstructor, otherwise the reset may not work as expected.NOTE: This method does not change
ProgressBar._term_is_init. If you plan to re-use the progress bar after a force reset, you will need to callProgressBar._init_termmanually.This function behaves like
ProgressBar.reset- Parameters:
show_frame – Whether
show_framewas enabled for the progress bar.label – Whether
labelwas enabled for the progress bar.
framed_text.shorten_text module
- class framed_text.shorten_text.ShortenText(text: str | Info | Action | Success | Fail | Warn | Hidden | String | Number | Boolean | Path | Date | Bytes, limit: int | None = None, mode: Literal['char', 'word', 'middle'] = 'char')[source]
Bases:
object- __init__(text: str | Info | Action | Success | Fail | Warn | Hidden | String | Number | Boolean | Path | Date | Bytes, limit: int | None = None, mode: Literal['char', 'word', 'middle'] = 'char')[source]
Shorten text to a specified limit. Supports
LabeledData,Statusand regular strings.Modes
char: Cutoff char at end of text (The quick brown fox jumped ove…)word: Cutoff word at end of text (The quick brown fox jumped…)middle: Cutoff chars at middle of text (The quick brown…the lazy dog)
- Parameters:
text – Text to shorten
limit – Limit. Text will be shortened to this length. If no limit is passed, will default to the width of the terminal.
mode – Mode to use to shorten text. See above for more info.
framed_text.spinner module
- class framed_text.spinner.Spinner(text: str | Info | Action | Success | Fail | Warn | Hidden | String | Number | Boolean | Path | Date | Bytes = '', icons_id: str = 'default', done_icon: str = '', custom_icons: list[str] | None = None, interval: float = 0.2, position: Literal['start', 'end'] = 'start', indent: int = 1, spinner_color: str | tuple[int, int, int] | Color | None = 'yellow', done_color: str | tuple[int, int, int] | Color | None = 'green')[source]
Bases:
object- BUILTIN_ICONS: dict[str, list[str]] = {'cube': ['⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧', '⠇', '⠏'], 'default': ['/', '-', '\\', '|'], 'dots': [' ', '. ', '.. ', '...'], 'dots2': [' ', '. ', '.. ', '...', ' ..', ' .']}
- __init__(text: str | Info | Action | Success | Fail | Warn | Hidden | String | Number | Boolean | Path | Date | Bytes = '', icons_id: str = 'default', done_icon: str = '', custom_icons: list[str] | None = None, interval: float = 0.2, position: Literal['start', 'end'] = 'start', indent: int = 1, spinner_color: str | tuple[int, int, int] | Color | None = 'yellow', done_color: str | tuple[int, int, int] | Color | None = 'green')[source]
Draws a spinner on a screen
Position
"start": The spinner will be placed at the start of the line."end": The spinner will be placed at the end of the line.
- Parameters:
text – Text to display next to the spinner. Omit for no text.
icons_id – ID string of one of the built-in icon sets from
Spinner.BUILTIN_ICONSdone_icon – Icon to use for when the spinner is complete
custom_icons – A list of strings to use as the spinner icon. Overrides
icons_idinterval – The delay between spinner icon updates.
position – Where the spinner should be placed on a line.
indent – How many spaces the line should be indented.
spinner_color – Color of the spinner icon while active.
done_color – Color for the spinner icon when stopped.
- start(text: str = '')[source]
Start the spinner
- Parameters:
text – Text to display next to the spinner. Omit for no text.
- stop(done_icon: str | None = None, done_color: str | tuple[int, int, int] | Color | None = None)[source]
Stop the spinner
Optionally, allow custom done icon and color for the current spinner.
- Parameters:
done_icon – Icon to use for when the spinner is complete
done_color – Color for the done icon
- update(text: str | Info | Action | Success | Fail | Warn | Hidden | String | Number | Boolean | Path | Date | Bytes | None = None, icons_id: str | None = None, done_icon: str | None = None, custom_icons: list[str] | None = None, interval: float | None = None, position: Literal['start', 'end'] | None = None, indent: int | None = None, spinner_color: str | tuple[int, int, int] | Color | None = None, done_color: str | tuple[int, int, int] | Color | None = None)[source]
Update values for the spinner.
Some values can only be updated when the spinner is not running. See documentation for more details.
Position
"start": The spinner will be placed at the start of the line."end": The spinner will be placed at the end of the line.
- Parameters:
text – Text to display next to the spinner. Omit for no text.
icons_id – ID string of one of the built-in icon sets from
Spinner.BUILTIN_ICONSdone_icon – Icon to use for when the spinner is complete
custom_icons – A list of strings to use as the spinner icon. Overrides
icons_idinterval – The delay between spinner icon updates.
position – Where the spinner should be placed on a line.
indent – How many spaces the line should be indented.
spinner_color – Color of the spinner icon while active.
done_color – Color for the spinner icon when stopped.
framed_text.status module
- class framed_text.status.BaseStatus(msg: str | String | Number | Boolean | Path | Date | Bytes | None = None, icon: str = '>', sep: str = ' ', overwrite: bool = False, icon_color: Color | None = None, msg_color: Color | None = None, icon_attrs: list[str] | None = None, msg_attrs: list[str] | None = None)[source]
Bases:
object- __init__(msg: str | String | Number | Boolean | Path | Date | Bytes | None = None, icon: str = '>', sep: str = ' ', overwrite: bool = False, icon_color: Color | None = None, msg_color: Color | None = None, icon_attrs: list[str] | None = None, msg_attrs: list[str] | None = None)[source]
Status base class. Can be used to create custom status classes.
Predefined Status classes are available in the Status class.
- Parameters:
msg – Message to display after the icon
icon – Character(s) to use as the icon. Icon can be any size. If no icon, seperator is not used.
sep – Separator between icon and message. Will only be used when message is provided.
overwrite – If true, will overwrite the previous line with a new status.
icon_color – Color of the icon.
msg_color – Color of the message.
icon_attrs – Attributes of the icon. Can be a list of termcolor attributes
msg_attrs – Attributes of the message. Can be a list of termcolor attributes
- cutoff_text(limit: int, mode: Literal['char', 'word', 'middle'] = 'char') str[source]
Cutoffs text if it exceeds limit. Icon and seperator will always be shortened by character.
Modes
char: Cutoff char at end of text (The quick brown fox jumped ove…)word: Cutoff word at end of text (The quick brown fox jumped…)middle: Cutoff chars at middle of text (The quick brown…the lazy dog)
- Parameters:
limit – Maximum length of text
mode – Mode to use for shortening. See above for info.
- Returns:
Cutoff text
- class framed_text.status.Status[source]
Bases:
objectPredefined Status classes. Can be used with LabeledData and regular strings. Each Status optionally takes a message and text color which creates a string in the format: <icon> <message>
Custom Status classes can be created from the BaseStatus class.
- class Action(msg: str | String | Number | Boolean | Path | Date | Bytes | None = None, icon: str = '➤', sep: str = ' ', overwrite: bool = False, icon_color: str | tuple[int, int, int] | Color | None = 'blue', msg_color: str | tuple[int, int, int] | Color | None = None, icon_attrs: list[str] | None = None, msg_attrs: list[str] | None = None)[source]
Bases:
BaseStatus- Parameters:
msg – Message to display after the icon
icon – Character(s) to use as the icon. Icon can be any size.
sep – Separator between icon and message. Will only be used when message is provided.
overwrite – If true, will overwrite the previous line with a new status.
icon_color – Color of the icon.
msg_color – Color of the message.
icon_attrs – Attributes to apply to the icon. Can be a list of termcolor attributes
msg_attrs – Attributes to apply to the message. Can be a list of termcolor attributes
- __init__(msg: str | String | Number | Boolean | Path | Date | Bytes | None = None, icon: str = '➤', sep: str = ' ', overwrite: bool = False, icon_color: str | tuple[int, int, int] | Color | None = 'blue', msg_color: str | tuple[int, int, int] | Color | None = None, icon_attrs: list[str] | None = None, msg_attrs: list[str] | None = None)[source]
Status base class. Can be used to create custom status classes.
Predefined Status classes are available in the Status class.
- Parameters:
msg – Message to display after the icon
icon – Character(s) to use as the icon. Icon can be any size. If no icon, seperator is not used.
sep – Separator between icon and message. Will only be used when message is provided.
overwrite – If true, will overwrite the previous line with a new status.
icon_color – Color of the icon.
msg_color – Color of the message.
icon_attrs – Attributes of the icon. Can be a list of termcolor attributes
msg_attrs – Attributes of the message. Can be a list of termcolor attributes
- class Fail(msg: str | String | Number | Boolean | Path | Date | Bytes | None = None, icon: str = '✗', sep: str = ' ', overwrite: bool = False, icon_color: str | tuple[int, int, int] | Color | None = 'red', msg_color: str | tuple[int, int, int] | Color | None = 'red', icon_attrs: list[str] | None = None, msg_attrs: list[str] | None = None)[source]
Bases:
BaseStatus- Parameters:
msg – Message to display after the icon
icon – Character(s) to use as the icon. Icon can be any size.
sep – Separator between icon and message. Will only be used when message is provided.
overwrite – If true, will overwrite the previous line with a new status.
icon_color – Color of the icon.
msg_color – Color of the message.
icon_attrs – Attributes to apply to the icon. Can be a list of termcolor attributes
msg_attrs – Attributes to apply to the message. Can be a list of termcolor attributes
- __init__(msg: str | String | Number | Boolean | Path | Date | Bytes | None = None, icon: str = '✗', sep: str = ' ', overwrite: bool = False, icon_color: str | tuple[int, int, int] | Color | None = 'red', msg_color: str | tuple[int, int, int] | Color | None = 'red', icon_attrs: list[str] | None = None, msg_attrs: list[str] | None = None)[source]
Status base class. Can be used to create custom status classes.
Predefined Status classes are available in the Status class.
- Parameters:
msg – Message to display after the icon
icon – Character(s) to use as the icon. Icon can be any size. If no icon, seperator is not used.
sep – Separator between icon and message. Will only be used when message is provided.
overwrite – If true, will overwrite the previous line with a new status.
icon_color – Color of the icon.
msg_color – Color of the message.
icon_attrs – Attributes of the icon. Can be a list of termcolor attributes
msg_attrs – Attributes of the message. Can be a list of termcolor attributes
- class Hidden(msg: str | String | Number | Boolean | Path | Date | Bytes | None = None, icon: str = '➤', sep: str = ' ', overwrite: bool = False, icon_color: str | tuple[int, int, int] | Color | None = (125, 125, 125), msg_color: str | tuple[int, int, int] | Color | None = (125, 125, 125), icon_attrs: list[str] | None = None, msg_attrs: list[str] | None = None)[source]
Bases:
BaseStatus- Parameters:
msg – Message to display after the icon
icon – Character(s) to use as the icon. Icon can be any size.
sep – Separator between icon and message. Will only be used when message is provided.
overwrite – If true, will overwrite the previous line with a new status.
icon_color – Color of the icon.
msg_color – Color of the message.
icon_attrs – Attributes to apply to the icon. Can be a list of termcolor attributes
msg_attrs – Attributes to apply to the message. Can be a list of termcolor attributes
- __init__(msg: str | String | Number | Boolean | Path | Date | Bytes | None = None, icon: str = '➤', sep: str = ' ', overwrite: bool = False, icon_color: str | tuple[int, int, int] | Color | None = (125, 125, 125), msg_color: str | tuple[int, int, int] | Color | None = (125, 125, 125), icon_attrs: list[str] | None = None, msg_attrs: list[str] | None = None)[source]
Status base class. Can be used to create custom status classes.
Predefined Status classes are available in the Status class.
- Parameters:
msg – Message to display after the icon
icon – Character(s) to use as the icon. Icon can be any size. If no icon, seperator is not used.
sep – Separator between icon and message. Will only be used when message is provided.
overwrite – If true, will overwrite the previous line with a new status.
icon_color – Color of the icon.
msg_color – Color of the message.
icon_attrs – Attributes of the icon. Can be a list of termcolor attributes
msg_attrs – Attributes of the message. Can be a list of termcolor attributes
- class Info(msg: str | String | Number | Boolean | Path | Date | Bytes | None = None, icon: str = '?', sep: str = ' ', overwrite: bool = False, icon_color: str | tuple[int, int, int] | Color | None = 'yellow', msg_color: str | tuple[int, int, int] | Color | None = None, icon_attrs: list[str] | None = None, msg_attrs: list[str] | None = None)[source]
Bases:
BaseStatus- Parameters:
msg – Message to display after the icon
icon – Character(s) to use as the icon. Icon can be any size.
sep – Separator between icon and message. Will only be used when message is provided.
overwrite – If true, will overwrite the previous line with a new status.
icon_color – Color of the icon.
msg_color – Color of the message.
icon_attrs – Attributes to apply to the icon. Can be a list of termcolor attributes
msg_attrs – Attributes to apply to the message. Can be a list of termcolor attributes
- __init__(msg: str | String | Number | Boolean | Path | Date | Bytes | None = None, icon: str = '?', sep: str = ' ', overwrite: bool = False, icon_color: str | tuple[int, int, int] | Color | None = 'yellow', msg_color: str | tuple[int, int, int] | Color | None = None, icon_attrs: list[str] | None = None, msg_attrs: list[str] | None = None)[source]
Status base class. Can be used to create custom status classes.
Predefined Status classes are available in the Status class.
- Parameters:
msg – Message to display after the icon
icon – Character(s) to use as the icon. Icon can be any size. If no icon, seperator is not used.
sep – Separator between icon and message. Will only be used when message is provided.
overwrite – If true, will overwrite the previous line with a new status.
icon_color – Color of the icon.
msg_color – Color of the message.
icon_attrs – Attributes of the icon. Can be a list of termcolor attributes
msg_attrs – Attributes of the message. Can be a list of termcolor attributes
- class Success(msg: str | String | Number | Boolean | Path | Date | Bytes | None = None, icon: str = '✔', sep: str = ' ', overwrite: bool = False, icon_color: str | tuple[int, int, int] | Color | None = 'green', msg_color: str | tuple[int, int, int] | Color | None = 'green', icon_attrs: list[str] | None = None, msg_attrs: list[str] | None = None)[source]
Bases:
BaseStatus- Parameters:
msg – Message to display after the icon
icon – Character(s) to use as the icon. Icon can be any size.
sep – Separator between icon and message. Will only be used when message is provided.
overwrite – If true, will overwrite the previous line with a new status.
icon_color – Color of the icon.
msg_color – Color of the message.
icon_attrs – Attributes to apply to the icon. Can be a list of termcolor attributes
msg_attrs – Attributes to apply to the message. Can be a list of termcolor attributes
- __init__(msg: str | String | Number | Boolean | Path | Date | Bytes | None = None, icon: str = '✔', sep: str = ' ', overwrite: bool = False, icon_color: str | tuple[int, int, int] | Color | None = 'green', msg_color: str | tuple[int, int, int] | Color | None = 'green', icon_attrs: list[str] | None = None, msg_attrs: list[str] | None = None)[source]
Status base class. Can be used to create custom status classes.
Predefined Status classes are available in the Status class.
- Parameters:
msg – Message to display after the icon
icon – Character(s) to use as the icon. Icon can be any size. If no icon, seperator is not used.
sep – Separator between icon and message. Will only be used when message is provided.
overwrite – If true, will overwrite the previous line with a new status.
icon_color – Color of the icon.
msg_color – Color of the message.
icon_attrs – Attributes of the icon. Can be a list of termcolor attributes
msg_attrs – Attributes of the message. Can be a list of termcolor attributes
- class Warn(msg: str | String | Number | Boolean | Path | Date | Bytes | None = None, icon: str = '⚠️', sep: str = '', overwrite: bool = False, icon_color: str | tuple[int, int, int] | Color | None = (239, 202, 19), msg_color: str | tuple[int, int, int] | Color | None = 'yellow', icon_attrs: list[str] | None = None, msg_attrs: list[str] | None = None)[source]
Bases:
BaseStatus- Parameters:
msg – Message to display after the icon
icon – Character(s) to use as the icon. Icon can be any size.
sep – Separator between icon and message. Will only be used when message is provided.
overwrite – If true, will overwrite the previous line with a new status.
icon_color – Color of the icon.
msg_color – Color of the message.
icon_attrs – Attributes to apply to the icon. Can be a list of termcolor attributes
msg_attrs – Attributes to apply to the message. Can be a list of termcolor attributes
- __init__(msg: str | String | Number | Boolean | Path | Date | Bytes | None = None, icon: str = '⚠️', sep: str = '', overwrite: bool = False, icon_color: str | tuple[int, int, int] | Color | None = (239, 202, 19), msg_color: str | tuple[int, int, int] | Color | None = 'yellow', icon_attrs: list[str] | None = None, msg_attrs: list[str] | None = None)[source]
Status base class. Can be used to create custom status classes.
Predefined Status classes are available in the Status class.
- Parameters:
msg – Message to display after the icon
icon – Character(s) to use as the icon. Icon can be any size. If no icon, seperator is not used.
sep – Separator between icon and message. Will only be used when message is provided.
overwrite – If true, will overwrite the previous line with a new status.
icon_color – Color of the icon.
msg_color – Color of the message.
icon_attrs – Attributes of the icon. Can be a list of termcolor attributes
msg_attrs – Attributes of the message. Can be a list of termcolor attributes
- class framed_text.status.StatusColors[source]
Bases:
objectA collection of the default colors used by the Status classes. Pre-formatted
Available Colors
INFO:
"yellow"ACTION:
"blue"SUCCESS:
"green"FAIL:
"red"WARN:
(239, 202, 19)HIDDEN:
(125, 125, 125)
- ACTION: str = 'blue'
- FAIL: str = 'red'
- HIDDEN: tuple[int, int, int] = (125, 125, 125)
- INFO: str = 'yellow'
- SUCCESS: str = 'green'
- WARN: tuple[int, int, int] = (239, 202, 19)
- class framed_text.status.StatusIcons[source]
Bases:
objectA collection of the default icons used by the Status classes. Pre-formatted
Available Icons
INFO:
'?'ACTION:
'➤'SUCCESS:
'✔'FAIL:
'✗'WARN:
'⚠️'HIDDEN:
'➤'
- ACTION: str = '➤'
- FAIL: str = '✗'
- HIDDEN: str = '➤'
- INFO: str = '?'
- SUCCESS: str = '✔'
- WARN: str = '⚠️'
framed_text.utils module
- class framed_text.utils.ANSIEscape[source]
Bases:
objectANSI Escape Codes used throughout framed-text
- ALT_BUFFER_OFF: str = '\x1b[?1049l'
- ALT_BUFFER_ON: str = '\x1b[?1049h'
- ERASE_LINE: str = '\x1b[2K'
- ERASE_SCREEN: str = '\x1b[2J'
- HIDE_CURSOR: str = '\x1b[?25l'
- RESTORE_POS: str = '\x1b8'
- SAVE_POS: str = '\x1b7'
- SHOW_CURSOR: str = '\x1b[?25h'
- static move_down(lines: int = 1)[source]
ANSI Code to move a set number of lines down
- Parameters:
lines – number of lines. Must be greater than 1
- Returns:
ANSI code
- static move_to(line: int = 0, column: int = 0) str[source]
ANSI Code to move to a specific line and column
Line and column must be positive
- Parameters:
line – Line to move to (row)
column – Column to move to (char)
- Returns:
ANSI code
- static move_to_col(column: int = 0) str[source]
ANSI Code to move to a specific column on the same line
Line and column must be positive
- Parameters:
column – Column to move to (char)
- Returns:
ANSI code
- static move_up(lines: int = 1) str[source]
ANSI Code to move a set number of lines up
- Parameters:
lines – number of lines. Must be greater than 1
- Returns:
ANSI code
Module contents
- class framed_text.ANSIEscape[source]
Bases:
objectANSI Escape Codes used throughout framed-text
- ALT_BUFFER_OFF: str = '\x1b[?1049l'
- ALT_BUFFER_ON: str = '\x1b[?1049h'
- ERASE_LINE: str = '\x1b[2K'
- ERASE_SCREEN: str = '\x1b[2J'
- HIDE_CURSOR: str = '\x1b[?25l'
- RESTORE_POS: str = '\x1b8'
- SAVE_POS: str = '\x1b7'
- SHOW_CURSOR: str = '\x1b[?25h'
- static move_down(lines: int = 1)[source]
ANSI Code to move a set number of lines down
- Parameters:
lines – number of lines. Must be greater than 1
- Returns:
ANSI code
- static move_to(line: int = 0, column: int = 0) str[source]
ANSI Code to move to a specific line and column
Line and column must be positive
- Parameters:
line – Line to move to (row)
column – Column to move to (char)
- Returns:
ANSI code
- static move_to_col(column: int = 0) str[source]
ANSI Code to move to a specific column on the same line
Line and column must be positive
- Parameters:
column – Column to move to (char)
- Returns:
ANSI code
- static move_up(lines: int = 1) str[source]
ANSI Code to move a set number of lines up
- Parameters:
lines – number of lines. Must be greater than 1
- Returns:
ANSI code
- class framed_text.BaseStatus(msg: str | String | Number | Boolean | Path | Date | Bytes | None = None, icon: str = '>', sep: str = ' ', overwrite: bool = False, icon_color: Color | None = None, msg_color: Color | None = None, icon_attrs: list[str] | None = None, msg_attrs: list[str] | None = None)[source]
Bases:
object- __init__(msg: str | String | Number | Boolean | Path | Date | Bytes | None = None, icon: str = '>', sep: str = ' ', overwrite: bool = False, icon_color: Color | None = None, msg_color: Color | None = None, icon_attrs: list[str] | None = None, msg_attrs: list[str] | None = None)[source]
Status base class. Can be used to create custom status classes.
Predefined Status classes are available in the Status class.
- Parameters:
msg – Message to display after the icon
icon – Character(s) to use as the icon. Icon can be any size. If no icon, seperator is not used.
sep – Separator between icon and message. Will only be used when message is provided.
overwrite – If true, will overwrite the previous line with a new status.
icon_color – Color of the icon.
msg_color – Color of the message.
icon_attrs – Attributes of the icon. Can be a list of termcolor attributes
msg_attrs – Attributes of the message. Can be a list of termcolor attributes
- cutoff_text(limit: int, mode: Literal['char', 'word', 'middle'] = 'char') str[source]
Cutoffs text if it exceeds limit. Icon and seperator will always be shortened by character.
Modes
char: Cutoff char at end of text (The quick brown fox jumped ove…)word: Cutoff word at end of text (The quick brown fox jumped…)middle: Cutoff chars at middle of text (The quick brown…the lazy dog)
- Parameters:
limit – Maximum length of text
mode – Mode to use for shortening. See above for info.
- Returns:
Cutoff text
- text: str
- text_shorten: str
- class framed_text.Color(color: str | tuple | Color | None = None, mode: Literal['rgb', 'hex', 'hsl', 'hsv'] = 'rgb')[source]
Bases:
object- __init__(color: str | tuple | Color | None = None, mode: Literal['rgb', 'hex', 'hsl', 'hsv'] = 'rgb')[source]
Converts a color to a termcolor-supported color
Available Color Types
Termcolor color code (Any)
RGB tuple (rgb)
HEX code (hex)
HSV code (hsv)
HSL code (hsl)
- Parameters:
color – Color to convert
mode – Color type
- class framed_text.FrameChain(frames: list[FramedText], inherit_from: FramedText | None = None, layout: Literal['vertical', 'horizontal'] = 'vertical', columns: int | None = None, cutoff_mode: Literal['char', 'word', 'middle'] = 'char', group_title: str | None = None, show_titles: bool = True, frame_color: str | tuple[int, int, int] | Color | None = None, title_color: str | tuple[int, int, int] | Color | None = None, g_title_color: str | tuple[int, int, int] | Color | None = None, title_attrs: list[str] | None = None, g_title_attrs: list[str] | None = None)[source]
Bases:
object- __init__(frames: list[FramedText], inherit_from: FramedText | None = None, layout: Literal['vertical', 'horizontal'] = 'vertical', columns: int | None = None, cutoff_mode: Literal['char', 'word', 'middle'] = 'char', group_title: str | None = None, show_titles: bool = True, frame_color: str | tuple[int, int, int] | Color | None = None, title_color: str | tuple[int, int, int] | Color | None = None, g_title_color: str | tuple[int, int, int] | Color | None = None, title_attrs: list[str] | None = None, g_title_attrs: list[str] | None = None)[source]
Chains multiple
FramedTextobjects into a single object.Each
FramedText’s text and title are preservedProviding a
FramedTexttoinherit_fromwill inherit the following to the whole group:frame_colortitle_color(Also applies tog_title_color)title_attrs(Also applies tog_title_attrs)
Layouts:
vertical: Stacks frames verticallyhorizontal: Places frames side by side
Column Sizes:
static: Fixed column size for all columns. Based on 1st frameeven: Evenly distribute column size (term width / n columns)
NOTE:
cutoffis forced enabled forJoinFramesCutoff Modes:
char: Cutoff char at end of text (The quick brown fox jumped ove…)word: Cutoff word at end of text (The quick brown fox jumped…)middle: Cutoff chars at middle of text (The quick brown…the lazy dog)
- Parameters:
frames – List of
FramedTextobjects to group together.inherit_from –
FramedTextobject to inherit styling variables from.layout – The layout of the frames. Vertical will wrap frames to next line if exceeds terminal width.
columns – Will cap the number of columns to this value when using horizontal layout. If blank, will use recommended value.
cutoff_mode – Mode for cutoff. “char” for character cutoff, “word” for word cutoff, “middle” for middle cutoff.
group_title – If provided, will add a title for the whole group.
show_titles – If True, will display each frame’s title.
frame_color – Color for the frame. Overrides value from
inherit_from.title_color – Color for each frame’s title. Overrides value from
inherit_from.g_title_color – Color for the group title. Overrides value from
inherit_from.title_attrs – Attributes for each frame’s title. Overrides value from
inherit_from.g_title_attrs – Attributes for the group title. Overrides value from
inherit_from.
- class framed_text.FramedHeader(title: str = '', divider: str = '─', frame_color: str | tuple[int, int, int] | Color | None = None, title_color: str | tuple[int, int, int] | Color | None = None, title_attrs: list[str] | None = None)[source]
Bases:
object- __init__(title: str = '', divider: str = '─', frame_color: str | tuple[int, int, int] | Color | None = None, title_color: str | tuple[int, int, int] | Color | None = None, title_attrs: list[str] | None = None)[source]
Creates a string with a customizable divider. Can include a title. Matches the style of FramedText.
Attributes:
All
termcolorattributes are supported:"bold","dark","italic","underline","reverse","concealed","strike"- Parameters:
title – Title to display in the header
frame_color – Color of the frame. Valid colors based off of termcolor’s color options: string color code or RGB tuple
title_color – Color of the title. Valid colors based off of termcolor’s color options: string color code or RGB tuple
divider – Divider to use. Will be repeated to fill the terminal width
title_attrs – Attributes to apply to the title. See list above for valid attributes
- class framed_text.FramedText(text: str | String | Number | Boolean | Path | Date | Bytes | Info | Action | Success | Fail | Warn | Hidden | list[str | String | Number | Boolean | Path | Date | Bytes | Info | Action | Success | Fail | Warn | Hidden] = '', title: str = '', cutoff: bool = True, mode: Literal['char', 'word', 'middle'] = 'char', center_text: bool = False, frame_size: Literal['full', 'dynamic'] = 'full', frame_align: Literal['left', 'center', 'right'] = 'left', frame_color: str | tuple[int, int, int] | Color | None = None, title_color: str | tuple[int, int, int] | Color | None = None, title_attrs: list[str] | None = None)[source]
Bases:
object- __init__(text: str | String | Number | Boolean | Path | Date | Bytes | Info | Action | Success | Fail | Warn | Hidden | list[str | String | Number | Boolean | Path | Date | Bytes | Info | Action | Success | Fail | Warn | Hidden] = '', title: str = '', cutoff: bool = True, mode: Literal['char', 'word', 'middle'] = 'char', center_text: bool = False, frame_size: Literal['full', 'dynamic'] = 'full', frame_align: Literal['left', 'center', 'right'] = 'left', frame_color: str | tuple[int, int, int] | Color | None = None, title_color: str | tuple[int, int, int] | Color | None = None, title_attrs: list[str] | None = None)[source]
Creates a string with a customizable frame around it. Frame is based off of prompt_toolkit’s show_frame option, but with more customization and designed for print statements.
Cutoff Modes:
char: Cutoff char at end of text (The quick brown fox jumped ove…)word: Cutoff word at end of text (The quick brown fox jumped…)middle: Cutoff chars at middle of text (The quick brown…the lazy dog)
Frame Sizes: -
full: Frame will be the size of the terminal -dynamic: Frame will be the size of the text based on longest line.Attributes:
All
termcolorattributes are supported:"bold","dark","italic","underline","reverse","concealed","strike"NOTE:
allow_ansionly applies to strings- Parameters:
text – Text to be framed. Can be a regular string or a LabeledData object
title – Title of the frame
mode – Mode for cutoff. “char” for character cutoff, “word” for word cutoff, “middle” for middle cutoff
frame_color – Color of the frame. Valid colors based off of termcolor’s color options: string color code or RGB tuple
title_color – Color of the title. Valid colors based off of termcolor’s color options: string color code or RGB tuple
cutoff – If true, cut off text if it exceeds terminal width. Default is True (Recommended)
center_text – If True, centers the text inside frame. Ignored if
frame_sizeis “dynamic”frame_size – Size of the frame. “full” for terminal size, “dynamic” for text size
frame_align – Align of the frame. Only used if
frame_sizeis “dynamic”title_attrs – Attributes to apply to the title. See list above for valid attributes
- property longest_line: int
- Returns:
Longest line of the text
- property title: str
- Returns:
Title of the frame
- property title_attrs: list[str] | None
- Returns:
Attributes to apply to the title.
- exception framed_text.InvalidColorError(color: Any | None = None, message: str | None = None)[source]
Bases:
Exception
- class framed_text.LabeledData[source]
Bases:
objectClass for creating a string with a label and different types of data. Each item can be configured to include colored text.
- class Boolean(label: str, value: bool, suffix: str = '', t_text: str = 'True', f_text: str = 'False', quotes: bool = False, colon_match: bool = True, no_colon: bool = False, label_color: str | tuple[int, int, int] | Color | None = None, t_color: str | tuple[int, int, int] | Color | None = 'green', f_color: str | tuple[int, int, int] | Color | None = 'red', suffix_color: str | tuple[int, int, int] | Color | None = None, label_attrs: list[str] | None = None, val_attrs: list[str] | None = None, suffix_attrs: list[str] | None = None)[source]
Bases:
_Base- __init__(label: str, value: bool, suffix: str = '', t_text: str = 'True', f_text: str = 'False', quotes: bool = False, colon_match: bool = True, no_colon: bool = False, label_color: str | tuple[int, int, int] | Color | None = None, t_color: str | tuple[int, int, int] | Color | None = 'green', f_color: str | tuple[int, int, int] | Color | None = 'red', suffix_color: str | tuple[int, int, int] | Color | None = None, label_attrs: list[str] | None = None, val_attrs: list[str] | None = None, suffix_attrs: list[str] | None = None)[source]
Creates a string with a label and boolean value
- Parameters:
label – Label for boolean value.
value – Boolean value.
suffix – Optional text to appear after the value.
t_text – Text to display for true value.
f_text – Text to display for false value.
quotes – If true, wrap text in single quotes (‘)
colon_match – If true, the colon will match the style of the label.
no_colon – If true, the colon will be removed. Overrides
colon_matchlabel_color – Color of label.
t_color – Color of true value.
f_color – Color of false value.
suffix_color – Color of suffix.
label_attrs – Attributes to apply to the label.
val_attrs – Attributes to apply to the value.
suffix_attrs – Attributes to apply to the suffix.
- cutoff_text(limit: int) str[source]
Cuts off text if it exceeds limit. Will first try to shorten bool value. If there isn’t enough space for just an ellipsis, it will try to shorten the label, so that the output will be 50/50 (label: value).
- Parameters:
limit – Maximum length of text
- Returns:
Shortened text
- class Bytes(label: str, value: int, suffix: str = '', quotes: bool = False, colon_match: bool = True, no_colon: bool = False, unit_match: bool = True, show_unit: bool = True, unit_type: Literal['iec', 'si'] = 'iec', label_color: str | tuple[int, int, int] | Color | None = None, val_color: str | tuple[int, int, int] | Color | None = 'yellow', unit_color: str | tuple[int, int, int] | Color | None = None, suffix_color: str | tuple[int, int, int] | Color | None = None, label_attrs: list[str] | None = None, val_attrs: list[str] | None = None, unit_attrs: list[str] | None = None, suffix_attrs: list[str] | None = None)[source]
Bases:
_Base- __init__(label: str, value: int, suffix: str = '', quotes: bool = False, colon_match: bool = True, no_colon: bool = False, unit_match: bool = True, show_unit: bool = True, unit_type: Literal['iec', 'si'] = 'iec', label_color: str | tuple[int, int, int] | Color | None = None, val_color: str | tuple[int, int, int] | Color | None = 'yellow', unit_color: str | tuple[int, int, int] | Color | None = None, suffix_color: str | tuple[int, int, int] | Color | None = None, label_attrs: list[str] | None = None, val_attrs: list[str] | None = None, unit_attrs: list[str] | None = None, suffix_attrs: list[str] | None = None)[source]
Creates a string with a label and bytes value
- Parameters:
label – Label for string value
value – Integer value. Value MUST be in bytes
suffix – Optional text to appear after the value
quotes – If true, wrap text in single quotes (‘)
colon_match – If true, the colon will match the style of the label.
no_colon – If true, the colon will be removed. Overrides
colon_matchshow_unit – If true, the unit will be shown.
unit_match – If true, the unit will match the style of the value.
unit_type – Unit type: IEC is base 2, SI is base 10
label_color – Color of label.
val_color – Color of string value.
unit_color – Color of unit. Overrides
unit_match.suffix_color – Color of suffix.
label_attrs – Attributes to apply to the label.
val_attrs – Attributes to apply to the value.
unit_attrs – Attributes to apply to the unit. Overrides
unit_match.suffix_attrs – Attributes to apply to the suffix.
- cutoff_text(limit: int) str[source]
Cuts off text if it exceeds limit. Will NOT shorten the value, only suffix (if there is one). If there isn’t enough space for just an ellipsis, it will try to shorten the label, so that the output will be 50/50 (label: value).
- Parameters:
limit – Maximum length of text
- Returns:
Shortened text
- class Date(label: str, value: str | datetime = '', suffix: str = '', quotes: bool = True, colon_match: bool = True, no_colon: bool = False, strftime: str = '%Y-%m-%d %H:%M:%S', label_color: str | tuple[int, int, int] | Color | None = None, val_color: str | tuple[int, int, int] | Color | None = 'blue', suffix_color: str | tuple[int, int, int] | Color | None = None, label_attrs: list[str] | None = None, val_attrs: list[str] | None = None, suffix_attrs: list[str] | None = None)[source]
Bases:
_Base- __init__(label: str, value: str | datetime = '', suffix: str = '', quotes: bool = True, colon_match: bool = True, no_colon: bool = False, strftime: str = '%Y-%m-%d %H:%M:%S', label_color: str | tuple[int, int, int] | Color | None = None, val_color: str | tuple[int, int, int] | Color | None = 'blue', suffix_color: str | tuple[int, int, int] | Color | None = None, label_attrs: list[str] | None = None, val_attrs: list[str] | None = None, suffix_attrs: list[str] | None = None)[source]
Creates a string with a label and a date value
If no value is passed, will print current time using
strftimeparameter :param label: Label for string value :param value: Value, either as a datetime object or string :param suffix: Optional text to appear after the value :param quotes: If true, wrap text in single quotes (‘) :param colon_match: If true, the colon will match the style of the label. :param no_colon: If true, the colon will be removed. Overridescolon_match:param strftime: Formatter for datetime value :param label_color: Color of label. :param val_color: Color of string value. :param suffix_color: Color of suffix. :param label_attrs: Attributes to apply to the label. :param val_attrs: Attributes to apply to the value. :param suffix_attrs: Attributes to apply to the suffix.
- cutoff_text(limit: int) str[source]
Cuts off text if it exceeds limit. Will first try to shorten string. If there isn’t enough space for just an ellipsis, it will try to shorten the label, so that the output will be 50/50 (label: value).
- Parameters:
limit – Maximum length of text
- Returns:
Shortened text
- class Number(label: str, value: int | float, suffix: str = '', quotes: bool = False, colon_match: bool = True, no_colon: bool = False, round_to: int | None = None, leading_zeros: int | None = None, int_no_round: bool = False, label_color: str | tuple[int, int, int] | Color | None = None, val_color: str | tuple[int, int, int] | Color | None = 'yellow', suffix_color: str | tuple[int, int, int] | Color | None = None, label_attrs: list[str] | None = None, val_attrs: list[str] | None = None, suffix_attrs: list[str] | None = None)[source]
Bases:
_Base- __init__(label: str, value: int | float, suffix: str = '', quotes: bool = False, colon_match: bool = True, no_colon: bool = False, round_to: int | None = None, leading_zeros: int | None = None, int_no_round: bool = False, label_color: str | tuple[int, int, int] | Color | None = None, val_color: str | tuple[int, int, int] | Color | None = 'yellow', suffix_color: str | tuple[int, int, int] | Color | None = None, label_attrs: list[str] | None = None, val_attrs: list[str] | None = None, suffix_attrs: list[str] | None = None)[source]
Creates a string with a label and number value
- Parameters:
label – Label for number value
value – Number value
suffix – Optional text to appear after the value
quotes – If true, wrap text in single quotes (‘)
colon_match – If true, the colon will match the style of the label.
no_colon – If true, the colon will be removed. Overrides
colon_matchround_to – Number of decimal places to round to. Leave blank to not round.
leading_zeros – Number of leading zeros to add to the number. Leave blank to not add leading zeros.
int_no_round – If true, displays number as integer without rounding. Overrides
round_tolabel_color – Color of label.
val_color – Color of number value.
suffix_color – Color of suffix.
label_attrs – Attributes to apply to the label.
val_attrs – Attributes to apply to the value.
suffix_attrs – Attributes to apply to the suffix.
- cutoff_text(limit: int) str[source]
Cuts off text if it exceeds limit. Will NOT shorten the number, only the suffix (if there is one). If there isn’t enough space for just an ellipsis, it will try to shorten the label, so that the output will be 50/50 (label: value).
- Parameters:
limit – Maximum length of text
- Returns:
Shortened text
- class Path(label: str, value: Path | str, suffix: str = '', quotes: bool = True, colon_match: bool = True, no_colon: bool = False, label_color: str | tuple[int, int, int] | Color | None = None, val_color: str | tuple[int, int, int] | Color | None = 'cyan', suffix_color: str | tuple[int, int, int] | Color | None = None, label_attrs: list[str] | None = None, val_attrs: list[str] | None = None, suffix_attrs: list[str] | None = None)[source]
Bases:
_Base- __init__(label: str, value: Path | str, suffix: str = '', quotes: bool = True, colon_match: bool = True, no_colon: bool = False, label_color: str | tuple[int, int, int] | Color | None = None, val_color: str | tuple[int, int, int] | Color | None = 'cyan', suffix_color: str | tuple[int, int, int] | Color | None = None, label_attrs: list[str] | None = None, val_attrs: list[str] | None = None, suffix_attrs: list[str] | None = None)[source]
Creates a string with a label and path to a file or directory
- Parameters:
label – Label for path
value – Path to file or directory
suffix – Optional text to appear after the value
quotes – If true, wrap path in single quotes (‘)
colon_match – If true, the colon will match the style of the label.
no_colon – If true, the colon will be removed. Overrides
colon_matchlabel_color – Color of label.
val_color – Color of path value.
suffix_color – Color of suffix.
label_attrs – Attributes to apply to the label.
val_attrs – Attributes to apply to the value.
suffix_attrs – Attributes to apply to the suffix.
- cutoff_text(limit: int, mode: Literal['char', 'word', 'middle'] = 'char') str[source]
Shortens path to limit.
Modes: - char: Cutoff char at end of string (/path/to/a/f…) - word: Cutoff path at end, preserve the deepest directory/file (/path/to/…/file.txt) - middle: Cutoff chars at middle of string (/long/path/t…/an/file.txt)
- Parameters:
limit – Character limit for full labeled path string
mode – How to cut off path.
- Returns:
LabeledData.Path string with shortened path if it exceeds limit, else returns original string
- class String(label: str, value: str, suffix: str = '', quotes: bool = True, colon_match: bool = True, no_colon: bool = False, label_color: str | tuple[int, int, int] | Color | None = None, val_color: str | tuple[int, int, int] | Color | None = 'cyan', suffix_color: str | tuple[int, int, int] | Color | None = None, label_attrs: list[str] | None = None, val_attrs: list[str] | None = None, suffix_attrs: list[str] | None = None)[source]
Bases:
_Base- __init__(label: str, value: str, suffix: str = '', quotes: bool = True, colon_match: bool = True, no_colon: bool = False, label_color: str | tuple[int, int, int] | Color | None = None, val_color: str | tuple[int, int, int] | Color | None = 'cyan', suffix_color: str | tuple[int, int, int] | Color | None = None, label_attrs: list[str] | None = None, val_attrs: list[str] | None = None, suffix_attrs: list[str] | None = None)[source]
Creates a string with a label and string value
- Parameters:
label – Label for string value
value – String value
suffix – Optional text to appear after the value
suffix_color – Color of suffix
val_color – Color of string value.
label_color – Color of label.
quotes – If true, wrap text in single quotes (‘)
colon_match – If true, the colon will match the style of the label.
no_colon – If true, the colon will be removed. Overrides
colon_matchval_attrs – Attributes to apply to the value.
label_attrs – Attributes to apply to the label.
- cutoff_text(limit: int, mode: Literal['char', 'word', 'middle'] = 'char') str[source]
Cuts off text if it exceeds limit. Will first try to shorten string. If there isn’t enough space for just an ellipsis, it will try to shorten the label, so that the output will be 50/50 (label: value).
Modes: - char: Cutoff char at end of string (The quick brown fox jumped ove…) - word: Cutoff word at end of string (The quick brown fox jumped…) - middle: Cutoff words at middle of string (The quick brown…the lazy dog)
- Parameters:
limit – Maximum length of text
mode – How to cut off value text
- Returns:
Shortened text
- class framed_text.ProgressBar(value: int, total: int, label: str = '', show_frame: bool = False, show_percent: bool = True, show_values: bool = False, safe_mode: bool = False, skip_init: bool = False, progress_icon: str = '#', empty_icon: str = '.', brackets: tuple[str, str] = ('[', ']'), value_color: str | tuple[int, int, int] | Color | None = None, label_color: str | tuple[int, int, int] | Color | None = None, percent_color: str | tuple[int, int, int] | Color | None = None, progress_color: str | tuple[int, int, int] | Color | None = None, empty_color: str | tuple[int, int, int] | Color | None = None, brackets_color: str | tuple[int, int, int] | Color | None = None, frame_color: str | tuple[int, int, int] | Color | None = None)[source]
Bases:
object- __init__(value: int, total: int, label: str = '', show_frame: bool = False, show_percent: bool = True, show_values: bool = False, safe_mode: bool = False, skip_init: bool = False, progress_icon: str = '#', empty_icon: str = '.', brackets: tuple[str, str] = ('[', ']'), value_color: str | tuple[int, int, int] | Color | None = None, label_color: str | tuple[int, int, int] | Color | None = None, percent_color: str | tuple[int, int, int] | Color | None = None, progress_color: str | tuple[int, int, int] | Color | None = None, empty_color: str | tuple[int, int, int] | Color | None = None, brackets_color: str | tuple[int, int, int] | Color | None = None, frame_color: str | tuple[int, int, int] | Color | None = None)[source]
Display a progress bar that shows the progress from a value to a total.
The progress bar will snap to the bottom of the terminal.
- Parameters:
value – Current value.
total – Total value.
label – Optional label for the Progress Bar.
show_frame – If true, will show a frame around the progress bar, similar to
FramedText.show_percent – If true, will show percentage of progress. Will replace values display unless
show_valuesis true.show_values – If true, will show current value and total value. If false and
show_percentis false, will not display any values.safe_mode – If true, will clear the terminal and move cursor to top to ensure room for progress bar and any other data.
skip_init – If true, will only initialize when
displayorupdate_progressis called.progress_icon – Icon used for the progress display.
empty_icon – Icon used for the empty space in the progress display.
brackets – Brackets to surround the progress display. First value is the left bracket, second value is the right bracket.
value_color – Color of the label.
label_color – Color of the label.
percent_color – Color of the percentage.
progress_color – Color of the progress display.
empty_color – Color of the empty space in the progress display.
brackets_color – Color of the brackets.
frame_color – Color of the frame.
- static force_reset(show_frame: bool = False, label: bool = False)[source]
Force resets the terminal. This should only be used in the
exceptblock of a try-except block.Make sure to pass the same values to this function that were passed to the
ProgressBarconstructor, otherwise the reset may not work as expected.NOTE: This method does not change
ProgressBar._term_is_init. If you plan to re-use the progress bar after a force reset, you will need to callProgressBar._init_termmanually.This function behaves like
ProgressBar.reset- Parameters:
show_frame – Whether
show_framewas enabled for the progress bar.label – Whether
labelwas enabled for the progress bar.
- class framed_text.ShortenText(text: str | Info | Action | Success | Fail | Warn | Hidden | String | Number | Boolean | Path | Date | Bytes, limit: int | None = None, mode: Literal['char', 'word', 'middle'] = 'char')[source]
Bases:
object- __init__(text: str | Info | Action | Success | Fail | Warn | Hidden | String | Number | Boolean | Path | Date | Bytes, limit: int | None = None, mode: Literal['char', 'word', 'middle'] = 'char')[source]
Shorten text to a specified limit. Supports
LabeledData,Statusand regular strings.Modes
char: Cutoff char at end of text (The quick brown fox jumped ove…)word: Cutoff word at end of text (The quick brown fox jumped…)middle: Cutoff chars at middle of text (The quick brown…the lazy dog)
- Parameters:
text – Text to shorten
limit – Limit. Text will be shortened to this length. If no limit is passed, will default to the width of the terminal.
mode – Mode to use to shorten text. See above for more info.
- class framed_text.Spinner(text: str | Info | Action | Success | Fail | Warn | Hidden | String | Number | Boolean | Path | Date | Bytes = '', icons_id: str = 'default', done_icon: str = '', custom_icons: list[str] | None = None, interval: float = 0.2, position: Literal['start', 'end'] = 'start', indent: int = 1, spinner_color: str | tuple[int, int, int] | Color | None = 'yellow', done_color: str | tuple[int, int, int] | Color | None = 'green')[source]
Bases:
object- BUILTIN_ICONS: dict[str, list[str]] = {'cube': ['⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧', '⠇', '⠏'], 'default': ['/', '-', '\\', '|'], 'dots': [' ', '. ', '.. ', '...'], 'dots2': [' ', '. ', '.. ', '...', ' ..', ' .']}
- __init__(text: str | Info | Action | Success | Fail | Warn | Hidden | String | Number | Boolean | Path | Date | Bytes = '', icons_id: str = 'default', done_icon: str = '', custom_icons: list[str] | None = None, interval: float = 0.2, position: Literal['start', 'end'] = 'start', indent: int = 1, spinner_color: str | tuple[int, int, int] | Color | None = 'yellow', done_color: str | tuple[int, int, int] | Color | None = 'green')[source]
Draws a spinner on a screen
Position
"start": The spinner will be placed at the start of the line."end": The spinner will be placed at the end of the line.
- Parameters:
text – Text to display next to the spinner. Omit for no text.
icons_id – ID string of one of the built-in icon sets from
Spinner.BUILTIN_ICONSdone_icon – Icon to use for when the spinner is complete
custom_icons – A list of strings to use as the spinner icon. Overrides
icons_idinterval – The delay between spinner icon updates.
position – Where the spinner should be placed on a line.
indent – How many spaces the line should be indented.
spinner_color – Color of the spinner icon while active.
done_color – Color for the spinner icon when stopped.
- start(text: str = '')[source]
Start the spinner
- Parameters:
text – Text to display next to the spinner. Omit for no text.
- stop(done_icon: str | None = None, done_color: str | tuple[int, int, int] | Color | None = None)[source]
Stop the spinner
Optionally, allow custom done icon and color for the current spinner.
- Parameters:
done_icon – Icon to use for when the spinner is complete
done_color – Color for the done icon
- update(text: str | Info | Action | Success | Fail | Warn | Hidden | String | Number | Boolean | Path | Date | Bytes | None = None, icons_id: str | None = None, done_icon: str | None = None, custom_icons: list[str] | None = None, interval: float | None = None, position: Literal['start', 'end'] | None = None, indent: int | None = None, spinner_color: str | tuple[int, int, int] | Color | None = None, done_color: str | tuple[int, int, int] | Color | None = None)[source]
Update values for the spinner.
Some values can only be updated when the spinner is not running. See documentation for more details.
Position
"start": The spinner will be placed at the start of the line."end": The spinner will be placed at the end of the line.
- Parameters:
text – Text to display next to the spinner. Omit for no text.
icons_id – ID string of one of the built-in icon sets from
Spinner.BUILTIN_ICONSdone_icon – Icon to use for when the spinner is complete
custom_icons – A list of strings to use as the spinner icon. Overrides
icons_idinterval – The delay between spinner icon updates.
position – Where the spinner should be placed on a line.
indent – How many spaces the line should be indented.
spinner_color – Color of the spinner icon while active.
done_color – Color for the spinner icon when stopped.
- class framed_text.Status[source]
Bases:
objectPredefined Status classes. Can be used with LabeledData and regular strings. Each Status optionally takes a message and text color which creates a string in the format: <icon> <message>
Custom Status classes can be created from the BaseStatus class.
- class Action(msg: str | String | Number | Boolean | Path | Date | Bytes | None = None, icon: str = '➤', sep: str = ' ', overwrite: bool = False, icon_color: str | tuple[int, int, int] | Color | None = 'blue', msg_color: str | tuple[int, int, int] | Color | None = None, icon_attrs: list[str] | None = None, msg_attrs: list[str] | None = None)[source]
Bases:
BaseStatus- Parameters:
msg – Message to display after the icon
icon – Character(s) to use as the icon. Icon can be any size.
sep – Separator between icon and message. Will only be used when message is provided.
overwrite – If true, will overwrite the previous line with a new status.
icon_color – Color of the icon.
msg_color – Color of the message.
icon_attrs – Attributes to apply to the icon. Can be a list of termcolor attributes
msg_attrs – Attributes to apply to the message. Can be a list of termcolor attributes
- __init__(msg: str | String | Number | Boolean | Path | Date | Bytes | None = None, icon: str = '➤', sep: str = ' ', overwrite: bool = False, icon_color: str | tuple[int, int, int] | Color | None = 'blue', msg_color: str | tuple[int, int, int] | Color | None = None, icon_attrs: list[str] | None = None, msg_attrs: list[str] | None = None)[source]
Status base class. Can be used to create custom status classes.
Predefined Status classes are available in the Status class.
- Parameters:
msg – Message to display after the icon
icon – Character(s) to use as the icon. Icon can be any size. If no icon, seperator is not used.
sep – Separator between icon and message. Will only be used when message is provided.
overwrite – If true, will overwrite the previous line with a new status.
icon_color – Color of the icon.
msg_color – Color of the message.
icon_attrs – Attributes of the icon. Can be a list of termcolor attributes
msg_attrs – Attributes of the message. Can be a list of termcolor attributes
- class Fail(msg: str | String | Number | Boolean | Path | Date | Bytes | None = None, icon: str = '✗', sep: str = ' ', overwrite: bool = False, icon_color: str | tuple[int, int, int] | Color | None = 'red', msg_color: str | tuple[int, int, int] | Color | None = 'red', icon_attrs: list[str] | None = None, msg_attrs: list[str] | None = None)[source]
Bases:
BaseStatus- Parameters:
msg – Message to display after the icon
icon – Character(s) to use as the icon. Icon can be any size.
sep – Separator between icon and message. Will only be used when message is provided.
overwrite – If true, will overwrite the previous line with a new status.
icon_color – Color of the icon.
msg_color – Color of the message.
icon_attrs – Attributes to apply to the icon. Can be a list of termcolor attributes
msg_attrs – Attributes to apply to the message. Can be a list of termcolor attributes
- __init__(msg: str | String | Number | Boolean | Path | Date | Bytes | None = None, icon: str = '✗', sep: str = ' ', overwrite: bool = False, icon_color: str | tuple[int, int, int] | Color | None = 'red', msg_color: str | tuple[int, int, int] | Color | None = 'red', icon_attrs: list[str] | None = None, msg_attrs: list[str] | None = None)[source]
Status base class. Can be used to create custom status classes.
Predefined Status classes are available in the Status class.
- Parameters:
msg – Message to display after the icon
icon – Character(s) to use as the icon. Icon can be any size. If no icon, seperator is not used.
sep – Separator between icon and message. Will only be used when message is provided.
overwrite – If true, will overwrite the previous line with a new status.
icon_color – Color of the icon.
msg_color – Color of the message.
icon_attrs – Attributes of the icon. Can be a list of termcolor attributes
msg_attrs – Attributes of the message. Can be a list of termcolor attributes
- class Hidden(msg: str | String | Number | Boolean | Path | Date | Bytes | None = None, icon: str = '➤', sep: str = ' ', overwrite: bool = False, icon_color: str | tuple[int, int, int] | Color | None = (125, 125, 125), msg_color: str | tuple[int, int, int] | Color | None = (125, 125, 125), icon_attrs: list[str] | None = None, msg_attrs: list[str] | None = None)[source]
Bases:
BaseStatus- Parameters:
msg – Message to display after the icon
icon – Character(s) to use as the icon. Icon can be any size.
sep – Separator between icon and message. Will only be used when message is provided.
overwrite – If true, will overwrite the previous line with a new status.
icon_color – Color of the icon.
msg_color – Color of the message.
icon_attrs – Attributes to apply to the icon. Can be a list of termcolor attributes
msg_attrs – Attributes to apply to the message. Can be a list of termcolor attributes
- __init__(msg: str | String | Number | Boolean | Path | Date | Bytes | None = None, icon: str = '➤', sep: str = ' ', overwrite: bool = False, icon_color: str | tuple[int, int, int] | Color | None = (125, 125, 125), msg_color: str | tuple[int, int, int] | Color | None = (125, 125, 125), icon_attrs: list[str] | None = None, msg_attrs: list[str] | None = None)[source]
Status base class. Can be used to create custom status classes.
Predefined Status classes are available in the Status class.
- Parameters:
msg – Message to display after the icon
icon – Character(s) to use as the icon. Icon can be any size. If no icon, seperator is not used.
sep – Separator between icon and message. Will only be used when message is provided.
overwrite – If true, will overwrite the previous line with a new status.
icon_color – Color of the icon.
msg_color – Color of the message.
icon_attrs – Attributes of the icon. Can be a list of termcolor attributes
msg_attrs – Attributes of the message. Can be a list of termcolor attributes
- class Info(msg: str | String | Number | Boolean | Path | Date | Bytes | None = None, icon: str = '?', sep: str = ' ', overwrite: bool = False, icon_color: str | tuple[int, int, int] | Color | None = 'yellow', msg_color: str | tuple[int, int, int] | Color | None = None, icon_attrs: list[str] | None = None, msg_attrs: list[str] | None = None)[source]
Bases:
BaseStatus- Parameters:
msg – Message to display after the icon
icon – Character(s) to use as the icon. Icon can be any size.
sep – Separator between icon and message. Will only be used when message is provided.
overwrite – If true, will overwrite the previous line with a new status.
icon_color – Color of the icon.
msg_color – Color of the message.
icon_attrs – Attributes to apply to the icon. Can be a list of termcolor attributes
msg_attrs – Attributes to apply to the message. Can be a list of termcolor attributes
- __init__(msg: str | String | Number | Boolean | Path | Date | Bytes | None = None, icon: str = '?', sep: str = ' ', overwrite: bool = False, icon_color: str | tuple[int, int, int] | Color | None = 'yellow', msg_color: str | tuple[int, int, int] | Color | None = None, icon_attrs: list[str] | None = None, msg_attrs: list[str] | None = None)[source]
Status base class. Can be used to create custom status classes.
Predefined Status classes are available in the Status class.
- Parameters:
msg – Message to display after the icon
icon – Character(s) to use as the icon. Icon can be any size. If no icon, seperator is not used.
sep – Separator between icon and message. Will only be used when message is provided.
overwrite – If true, will overwrite the previous line with a new status.
icon_color – Color of the icon.
msg_color – Color of the message.
icon_attrs – Attributes of the icon. Can be a list of termcolor attributes
msg_attrs – Attributes of the message. Can be a list of termcolor attributes
- class Success(msg: str | String | Number | Boolean | Path | Date | Bytes | None = None, icon: str = '✔', sep: str = ' ', overwrite: bool = False, icon_color: str | tuple[int, int, int] | Color | None = 'green', msg_color: str | tuple[int, int, int] | Color | None = 'green', icon_attrs: list[str] | None = None, msg_attrs: list[str] | None = None)[source]
Bases:
BaseStatus- Parameters:
msg – Message to display after the icon
icon – Character(s) to use as the icon. Icon can be any size.
sep – Separator between icon and message. Will only be used when message is provided.
overwrite – If true, will overwrite the previous line with a new status.
icon_color – Color of the icon.
msg_color – Color of the message.
icon_attrs – Attributes to apply to the icon. Can be a list of termcolor attributes
msg_attrs – Attributes to apply to the message. Can be a list of termcolor attributes
- __init__(msg: str | String | Number | Boolean | Path | Date | Bytes | None = None, icon: str = '✔', sep: str = ' ', overwrite: bool = False, icon_color: str | tuple[int, int, int] | Color | None = 'green', msg_color: str | tuple[int, int, int] | Color | None = 'green', icon_attrs: list[str] | None = None, msg_attrs: list[str] | None = None)[source]
Status base class. Can be used to create custom status classes.
Predefined Status classes are available in the Status class.
- Parameters:
msg – Message to display after the icon
icon – Character(s) to use as the icon. Icon can be any size. If no icon, seperator is not used.
sep – Separator between icon and message. Will only be used when message is provided.
overwrite – If true, will overwrite the previous line with a new status.
icon_color – Color of the icon.
msg_color – Color of the message.
icon_attrs – Attributes of the icon. Can be a list of termcolor attributes
msg_attrs – Attributes of the message. Can be a list of termcolor attributes
- class Warn(msg: str | String | Number | Boolean | Path | Date | Bytes | None = None, icon: str = '⚠️', sep: str = '', overwrite: bool = False, icon_color: str | tuple[int, int, int] | Color | None = (239, 202, 19), msg_color: str | tuple[int, int, int] | Color | None = 'yellow', icon_attrs: list[str] | None = None, msg_attrs: list[str] | None = None)[source]
Bases:
BaseStatus- Parameters:
msg – Message to display after the icon
icon – Character(s) to use as the icon. Icon can be any size.
sep – Separator between icon and message. Will only be used when message is provided.
overwrite – If true, will overwrite the previous line with a new status.
icon_color – Color of the icon.
msg_color – Color of the message.
icon_attrs – Attributes to apply to the icon. Can be a list of termcolor attributes
msg_attrs – Attributes to apply to the message. Can be a list of termcolor attributes
- __init__(msg: str | String | Number | Boolean | Path | Date | Bytes | None = None, icon: str = '⚠️', sep: str = '', overwrite: bool = False, icon_color: str | tuple[int, int, int] | Color | None = (239, 202, 19), msg_color: str | tuple[int, int, int] | Color | None = 'yellow', icon_attrs: list[str] | None = None, msg_attrs: list[str] | None = None)[source]
Status base class. Can be used to create custom status classes.
Predefined Status classes are available in the Status class.
- Parameters:
msg – Message to display after the icon
icon – Character(s) to use as the icon. Icon can be any size. If no icon, seperator is not used.
sep – Separator between icon and message. Will only be used when message is provided.
overwrite – If true, will overwrite the previous line with a new status.
icon_color – Color of the icon.
msg_color – Color of the message.
icon_attrs – Attributes of the icon. Can be a list of termcolor attributes
msg_attrs – Attributes of the message. Can be a list of termcolor attributes
- class framed_text.StatusColors[source]
Bases:
objectA collection of the default colors used by the Status classes. Pre-formatted
Available Colors
INFO:
"yellow"ACTION:
"blue"SUCCESS:
"green"FAIL:
"red"WARN:
(239, 202, 19)HIDDEN:
(125, 125, 125)
- ACTION: str = 'blue'
- FAIL: str = 'red'
- HIDDEN: tuple[int, int, int] = (125, 125, 125)
- INFO: str = 'yellow'
- SUCCESS: str = 'green'
- WARN: tuple[int, int, int] = (239, 202, 19)
- class framed_text.StatusIcons[source]
Bases:
objectA collection of the default icons used by the Status classes. Pre-formatted
Available Icons
INFO:
'?'ACTION:
'➤'SUCCESS:
'✔'FAIL:
'✗'WARN:
'⚠️'HIDDEN:
'➤'
- ACTION: str = '➤'
- FAIL: str = '✗'
- HIDDEN: str = '➤'
- INFO: str = '?'
- SUCCESS: str = '✔'
- WARN: str = '⚠️'