xTerm
Change Font and Text Color in Terminal or Console With xTerm. ENJOY
Install on Windows With pip
Install On Linux With pip3
Usage
use for change font Unicode Mode (Alpha mode)
from xTerm import Maths
# class shortcut
maths = Maths(font_type="Sans_Serif")
converted_text = maths.Convert("Hello World")
print(converted_text)
maths = Maths(font_type="Sans_Serif_bold")
converted_text = maths.Convert("Hello World")
print(converted_text)
maths = Maths(font_type="Sans_Serif_italic")
converted_text = maths.Convert("Hello World")
print(converted_text)
maths = Maths(font_type="Sans_Serif_bold_italic")
converted_text = maths.Convert("Hello World")
print(converted_text)
maths = Maths(font_type="Mathematical_bold")
converted_text = maths.Convert("Hello World")
print(converted_text)
maths = Maths(font_type="Mathematical_italic")
converted_text = maths.Convert("Hello World")
print(converted_text)
maths = Maths(font_type="Mathematical_Fraktur")
converted_text = maths.Convert("hello World")
print(converted_text)
maths = Maths(font_type="Mathematical_bold_Fraktur")
converted_text = maths.Convert("Hello World")
print(converted_text)
maths = Maths(font_type="Mathematical_double_struck")
converted_text = maths.Convert("hello World")
print(converted_text)
maths = Maths(font_type="Mathematical_monospace")
# converet string model to any unicode font ,
converted_text = maths.Convert("Hello World")
print(converted_text)
Alpha Mode (Convert Font String)
Convert String Text To Unicode Font Display
from xTerm import Alpha
# shortcut class
alpha = Alpha.Maths(font_type="Sans_Serif_bold_italic")
# text string for convert
converted_text = alpha.Convert("Hello World")
# Print Output
print(converted_text)
Table Function
In the following, I will introduce all the parameters that can be used in the table function to introduce them and their types of use along with several different examples.
Example Usage Table
!pip install xterm
from xTerm import Table
Price Table
products = [
["Laptop", 1299.99],
["Smartphone", 799.99],
["Tablet", 499.49],
["Headphones", 199.95],
["Smartwatch", 249.90],
]
print(Table(
[[item[0], f"${item[1]:,.2f}"] for item in products],
headers=["Product", "Price (USD)"],
tablefmt="fancy_grid"
))
Employees Report Table
employees = [
["John Doe", 56000, 4],
["Jane Smith", 78000, 5],
["Emily Davis", 62000, 3],
["Michael Johnson", 85000, 4],
["Sarah Lee", 50000, 2],
]
print(Table(
[[emp[0], f"${emp[1]:,}", "★" * emp[2]] for emp in employees],
headers=["Employee", "Salary", "Rating"],
tablefmt="rounded_outline"
))
Report Sensors Table
sensors = [
["Sensor A", 23.5, "Normal"],
["Sensor B", 28.1, "Alert"],
["Sensor C", 21.3, "Normal"],
["Sensor D", 30.7, "Critical"],
["Sensor E", 25.0, "Normal"],
]
print(Table(
[[sensor[0], f"{sensor[1]}°C", sensor[2]] for sensor in sensors],
headers=["Sensor", "Temperature", "Status"],
tablefmt="grid"
))
Server Task Table
tasks = [
["Database Migration", "In Progress", 45],
["API Development", "Completed", 100],
["Frontend Design", "In Progress", 60],
["Backend Optimization", "Not Started", 0],
["Testing & QA", "Pending", 20],
]
print(Table(
[[task[0], task[1], f"{task[2]}%"] for task in tasks],
headers=["Task", "Status", "Progress"],
tablefmt="pipe"
))
Student Report Table
students = [
["Ali", [85, 90, 78], 84.33],
["Sara", [92, 88, 95], 91.67],
["Reza", [70, 65, 75], 70.00],
["Mina", [88, 80, 82], 83.33],
["Hassan", [60, 55, 65], 60.00],
]
print(Table(
[[
student[0],
", ".join(map(str, student[1])),
f"{student[2]:.2f}",
f"{student[2] * 100 / 100:.1f}%"
] for student in students],
headers=["Student", "Scores", "Average", "Percentage"],
tablefmt="psql"
))
Devices Report Table
devices = [
["Router", "Online", "2024-10-31 14:30"],
["Switch", "Offline", "2024-10-31 08:15"],
["Firewall", "Online", "2024-10-30 23:45"],
["Access Point", "Maintenance", "2024-10-31 12:20"],
["Server", "Online", "2024-10-31 13:55"],
]
print(Table(
devices,
headers=["Device", "Status", "Last Update"],
tablefmt="github"
))
Financial Report Table
financial_report = [
["2020", "$1,200,000", "$800,000", "$400,000", "12.5%"],
["2021", "$1,350,000", "$900,000", "$450,000", "13.2%"],
["2022", "$1,500,000", "$950,000", "$550,000", "15.3%"],
["2023", "$1,800,000", "$1,000,000", "$800,000", "18.2%"],
]
print(Table(
financial_report,
headers=["Year", "Revenue", "Expenses", "Net Profit", "Growth Rate"],
tablefmt="fancy_grid",
stralign="center",
numalign="right"
))
Projects Report Table
projects = [
["Website Redesign", "2024-09-01", "12 days", "In Progress"],
["Mobile App", "2024-08-15", "5 days", "Completed"],
["Backend API", "2024-10-10", "3 days", "Testing"],
["Cloud Migration", "2024-07-30", "18 days", "Pending"],
["Security Update", "2024-08-25", "15 days", "In Progress"],
]
print(Table(
projects,
headers=["Project", "Start Date", "Time Remaining", "Status"],
tablefmt="rounded_outline",
stralign="center"
))
Students Report Table
students = [
["Ali", [85, 90, 78, 88], 85.25, "Passed"],
["Sara", [92, 88, 95, 96], 92.75, "Passed"],
["Reza", [70, 65, 75, 68], 69.5, "Failed"],
["Mina", [88, 80, 82, 86], 84.0, "Passed"],
["Hassan", [60, 55, 65, 59], 59.75, "Failed"],
]
print(Table(
[[student[0], ", ".join(map(str, student[1])), f"{student[2]:.2f}", student[3]] for student in students],
headers=["Student", "Scores", "Average", "Status"],
tablefmt="psql",
stralign="center",
numalign="right"
))
Servers Status Report
servers = [
["Server 1", "192.168.1.10", "Online", "75%", "65%"],
["Server 2", "192.168.1.20", "Offline", "-", "-"],
["Server 3", "192.168.1.30", "Maintenance", "40%", "50%"],
["Server 4", "192.168.1.40", "Online", "60%", "70%"],
["Server 5", "192.168.1.50", "Online", "85%", "90%"],
]
print(Table(
servers,
headers=["Server", "IP Address", "Status", "CPU Usage", "Memory Usage"],
tablefmt="github",
stralign="center"
))
Employees Report Table (Markdown)
employees = [
["John Doe", 5, "$70,000", "★★★★☆", "Excellent"],
["Jane Smith", 2, "$50,000", "★★★☆☆", "Good"],
["Emily Davis", 7, "$85,000", "★★★★★", "Outstanding"],
["Michael Brown", 4, "$60,000", "★★★☆☆", "Average"],
["Sarah Lee", 3, "$55,000", "★★★☆☆", "Good"],
]
print(Table(
employees,
headers=["Employee", "Experience (Years)", "Salary", "Rating", "Evaluation"],
tablefmt="pipe",
stralign="center"
))
Crypto Assets Table
crypto_assets = [
["Bitcoin", 2.5, "$60,000", "$150,000"],
["Ethereum", 10, "$4,000", "$40,000"],
["Ripple", 5000, "$0.50", "$2,500"],
["Litecoin", 15, "$150", "$2,250"],
["Cardano", 2000, "$2.10", "$4,200"],
]
print(Table(
crypto_assets,
headers=["Asset", "Quantity", "Price per Unit", "Total Value"],
tablefmt="fancy_grid",
numalign="right"
))
Team Report Table
matches = [
["Team A", "Team B", 3, 2, "Team A"],
["Team C", "Team D", 1, 1, "Draw"],
["Team E", "Team F", 0, 2, "Team F"],
["Team G", "Team H", 4, 1, "Team G"],
["Team I", "Team J", 2, 2, "Draw"],
]
print(Table(
matches,
headers=["Home Team", "Away Team", "Home Score", "Away Score", "Result"],
tablefmt="grid",
stralign="center",
numalign="right"
))