This module offers functions for aligning text in the terminal, making it easier to create visually appealing command-line interfaces. It includes options for centering text horizontally and vertically, as well as right-aligning text.
Centers text horizontally within the terminal.
-
Parameters:
str(str): The text to center.adjust(int, optional): Additional spaces for centering adjustment (default is0).addLineBreak(boolean, optional): To add a line break or not (default istrue).
-
Returns:
- Centered text as a string.
Centers text vertically in the terminal.
-
Parameters:
str(str): The text to center.uadjust(int, optional): Spaces above the text (default is0).dadjust(int, optional): Spaces below the text (default is0).
-
Returns:
- Vertically centered text as a string.
Aligns text to the right side of the terminal.
-
Parameters:
str(str): The text to align.ladjust(int, optional): Additional spaces to the left of the text (default is0).
-
Returns:
- Right-aligned text as a string.
- Python version: 3 and above.
- Misplacement: Ensure your string has no extra spaces. For example, use "text" instead of "text ".
To use the functions, import the module in your script:
import termiline
# Example usage
print(termiline.centerX("Horizontally Centered Text"))
print(termiline.centerY("Vertically Centered Text"))
print(termiline.alignRight("Right Aligned Text"))