This Python module contains a collection of functions for displaying text in various formats, such as bold, italic, and error messages. It also includes functions for getting user input and displaying data in a table format. It heavily relies on ANSI escape sequences.
Here is a list of functions included in this module:
- Description: Clears the screen.
- Usage:
clear()
- Description: Displays *args in italic. **kwargs will be passed to python's print function.
- Usage:
pitalic("Your Text Here")
orpitalic(*list_to_unpack)
etc. - Output : Your Text Here
- Description: Displays *args in bold. **kwargs will be passed to python's print function.
- Usage:
pbold("Your Text Here")
orpbold(*list_to_unpack)
etc. - Output : Your Text Here
- Description: Displays *args in yellow and bold. **kwargs will be passed to python's print function.
- Usage:
pwarn("Your Text Here")
orpwarn(*list_to_unpack)
etc. - Output : Your Text Here (but actually yellow and bold)
- Description: Displays *args in red and bold. **kwargs will be passed to python's print function.
- Usage:
perror("Your Text Here")
orperror(*list_to_unpack)
etc. - Output : Your Text Here (but actually red and bold)
- Description: Displays *args in blinking. **kwargs will be passed to python's print function.
- Usage:
pblink("Your Text Here")
orpblink(*list_to_unpack)
etc. - Output : Your Text Here (but actually blinking)
- Description: Asks the user to enter a boolean value. Can parse regular bool inputs like
y
,n
,true
,false
, etc. - Usage:
user_input = bool_input("Enter True or False: ")
- Description: Displays the data in a table format.
- Usage:
data = [['John', 28], ['Jane', 25]] headers = ['Name', 'Age'] print_table(data, headers)
- Output:
| Name | Age | ************** | John | 28 | | Jane | 25 |
- Description: Displays a form and returns the user's responses.
- Usage:
form_questions = ['Name', 'Age', 'City'] user_responses = print_as_form(form_questions)
- Output:
Name: Age: City:
from fmt import form_input, print_table
headers = ['Name', 'Age', 'Location']
data = []
while True:
user = fmt.form_input(headers)
if user is None:
break
else:
data += [user]
fmt.print_table(data, headers)
If user inputs A, B, C, ... L, the output will be:
| Name | Age | Location |
*************************
| A | B | C |
| D | E | F |
| G | H | I |
| J | K | L |
(with headers in bold)