-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPrettyText.py
More file actions
85 lines (81 loc) · 2.74 KB
/
PrettyText.py
File metadata and controls
85 lines (81 loc) · 2.74 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
# turned the following into a simple method:
# https://stackoverflow.com/a/39452138
# default setting is red text to make printing error messages quick
def pretty_text(text:str,
color:str="red",
bg:str="None",
bold:bool=False,
italic:bool=False,
underline:bool=False,
blink:bool=False,
bright:bool=True):
# all possible options
_options = {
"end" : '\33[0m',
"bold" : '\33[1m',
"italic" : '\33[3m',
"underline" : '\33[4m',
"blink" : '\33[5m',
"blink2" : '\33[6m',
"not_blink" : '\33[25m',
"selected" : '\33[7m',
"black" : '\33[30m',
"red" : '\33[31m',
"green" : '\33[32m',
"yellow" : '\33[33m',
"blue" : '\33[34m',
"violet" : '\33[35m',
"beige" : '\33[36m',
"white" : '\33[37m',
"bg_black" : '\33[40m',
"bg_red" : '\33[41m',
"bg_green" : '\33[42m',
"bg_yellow" : '\33[43m',
"bg_blue" : '\33[44m',
"bg_violet" : '\33[45m',
"bg_beige" : '\33[46m',
"bg_white" : '\33[47m',
"bg_grey" : '\33[90m',
"red_bright" : '\33[91m',
"green_bright" : '\33[92m',
"yellow_bright" : '\33[93m',
"blue_bright" : '\33[94m',
"violet_bright" : '\33[95m',
"beige_bright" : '\33[96m',
"white_bright" : '\33[97m',
"bg_black_bright" : '\33[40m',
"bg_grey_bright" : '\33[100m',
"bg_red_bright" : '\33[101m',
"bg_green_bright" : '\33[102m',
"bg_yellow_bright" : '\33[103m',
"bg_blue_bright" : '\33[104m',
"bg_violet_bright" : '\33[105m',
"bg_beige_bright" : '\33[106m',
"bg_white_bright" : '\33[107m'
}
#it all goes in an array that'll be joined together
settings = []
if bright is True:
concat = "_bright"
else: concat = ""
#add styles
if italic:
settings.append(_options.get("italic"))
if bold:
settings.append(_options.get("bold"))
if underline:
settings.append(_options.get("underline"))
if blink:
settings.append(_options.get("blink"))
if not blink:
settings.append(_options.get("not_blink"))
#add bg, if invalid it'll just do nothing
settings.append(_options.get(''.join(["bg_",bg.lower(),concat]), ""))
#add color, if invalid it'll just do nothing
settings.append(_options.get(''.join([color.lower(),concat]),""))
#add text to actually be printed
settings.append(text)
#close it out
settings.append(_options.get("end"))
#return the fancy text string
return ''.join(settings)