forked from PriyankaKhire/ProgrammingPracticePython
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathColorText.py
More file actions
34 lines (32 loc) · 1.12 KB
/
ColorText.py
File metadata and controls
34 lines (32 loc) · 1.12 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
#Color text
import sys
class ColorText(object):
def __init__(self):
self.colors = {"orange":"KEYWORD",
"green":"STRING",
"dark-red":"COMMENT",
"black":"SYNC",
"purple":"BUILTIN",
"brown":"console",
"blue":"stdout",
"light-red":"stderr",
"black-highlight":"hit",
"red-highlight":"ERROR",
"grey-highlight":"sel"}
def help(self):
print "The supported colors are: "
print "orange"
print "green"
print "dark-red"
print "black"
print "purple"
print "brown"
print "blue"
print "black-highlight"
print "light-red"
print "red-highlight"
print "grey-highlight"
def display(self, text, colour):
try: color = sys.stdout.shell
except AttributeError: raise RuntimeError("Use IDLE")
color.write(str(text)+"\n",self.colors[colour.lower()])