forked from nuwainfo/tibetaneditor
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFormat.py
More file actions
61 lines (48 loc) · 1.59 KB
/
Copy pathFormat.py
File metadata and controls
61 lines (48 loc) · 1.59 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
from PyQt5.QtGui import QTextCharFormat
class TextFormat(QTextCharFormat):
def __init__(self, name, type):
super().__init__()
self.name = name
self.wordList = []
self.regexList = []
self.type = type # level or pos
self.nameLabel = None
self.colorButton = None
self.listButton = None
self.ruleButton = None
self.counterLabel = None
def setupWordList(self, listPath, lines=None):
self.wordList = []
if lines:
lines = lines
else:
with open(listPath, 'r', encoding='utf-8') as f:
lines = f.readlines()
for line in lines:
word = line.rstrip()
if not word:
continue
# add a tsek where missing
if not word.endswith('་'):
word += '་'
self.wordList.append(word)
def setupRegexList(self, regexPath, lines=None):
self.regexList = []
if lines:
lines = lines
else:
with open(regexPath, 'r', encoding='utf-8') as f:
lines = f.readlines()
for line in lines:
regex = line.rstrip()
if regex:
self.regexList.append(regex)
def getColorRgbaCss(self):
return 'rgba({}, {}, {})'.format(
*(self.foreground().color().getRgb()))
def getColorRgba(self):
return self.foreground().color().getRgb()
def setColor(self, qtColor):
self.setForeground(qtColor)
def getColor(self):
return self.foreground().color()