-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathOS Screen Colour Codes.py
More file actions
53 lines (40 loc) · 1.63 KB
/
OS Screen Colour Codes.py
File metadata and controls
53 lines (40 loc) · 1.63 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
'''Save the Python file as 'OS screen colours'''
# There are also OS screen colours, which also colours text. However, the OS screen
# These os screen colour codes colour individual text characters. See program examples
# below.
import os
os.system('')
text_colours=(
'\x1b[31m', # index 0 = red
'\x1b[32m', # index 1 = green
'\x1b[33m', # index 2 = yellow
'\x1b[34m', # index 3 = blue
'\x1b[35m', # index 4 = purple
'\x1b[36m', # index 5 = cyan
'\x1b[37m' # index 6 = white
)
print(f'{text_colours[0]}The text is red')
print(f'{text_colours[1]}The text is green')
print(f'{text_colours[2]}The text is Yellow')
input(f'\n{text_colours[3]}End of Progream example 1. Press Enter.')
'''----------------------------------------------------------------'''
# There are also OS screen colours, which also colours text. However, the OS screen
# colours are not as flexible as text colours are. For example, If you try to make one
# line of text blue and try to make the next line of text green. When you execute/run the
# program, the next line of text you coloured green will override the blue text, making
# it green text too. Note: you must execute/run the program from the OS output
# screen, via double-clicking the Python program file itself.
import os
os.system('')
white=('color f')
blue=('color 9')
red=('color 4')
green=('color a')
cyan=('color b')
pink=('color c')
os.system(blue)
print('The text is blue')
input('\nEnd of Progream example 2. Press Enter')
os.system(green)
print('The text is green')
input('\nEnd of Progream examples. Press Enter to end the program.')