-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathconfig.py
163 lines (119 loc) · 4.8 KB
/
config.py
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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
from PyQt5 import QtCore, QtWidgets, QtGui
from config_start import path_programm
import yaml
import os
import re
config_file = os.path.join(path_programm, "_database", "_config", "config.yml")
# config_file = os.path.join(os.path.dirname(sys.argv[0]), "config.yml")
path_database = os.path.join(path_programm, "_database")
preamble = os.path.join(path_database, "preamble.tex")
# database_lama_1 = TinyDB(path_database, "db.json")
# _file_ = Query()
colors_ui = {
"black": QtGui.QColor(0, 0, 0),
"white": QtGui.QColor(255, 255, 255),
"dark_gray": QtGui.QColor(53, 53, 53),
"gray": QtGui.QColor(214, 214, 214),
"blue_1": QtGui.QColor(245, 245, 255),
"blue_2": QtGui.QColor(224, 233, 232),
"blue_3": QtGui.QColor(194, 208, 212), # 211, 224, 223
"blue_4": QtGui.QColor(168, 189, 194),
"blue_5": QtGui.QColor(88, 111, 124),
"blue_6": QtGui.QColor(83, 122, 141),
"blue_7": QtGui.QColor(47, 69, 80),
"red": QtGui.QColor(195, 58, 63),
}
# "blue_6": QtGui.QColor(68, 92, 136),
def test_coloring(widget, color="blue"):
widget.setStyleSheet(f"background-color: {color}")
def get_color(color):
color = "rgb({0}, {1}, {2})".format(color.red(), color.green(), color.blue())
return color
def config_loader(pathToFile, parameter):
config_file = yaml.safe_load(open(pathToFile, encoding="utf8"))
return config_file[parameter]
logo_path = os.path.join(
path_programm, "_database", "_config", "icon", "LaMA_icon_logo.png"
)
logo_cria_path = os.path.join(
path_programm, "_database", "_config", "icon", "LaMA_cria_icon_logo.png"
)
logo_cria_button_path = os.path.join(
path_programm, "_database", "_config", "icon", "LaMA_cria_icon_logo_button.png"
)
path_assets_charcoal = os.path.join(path_programm, "_database", "_config", "assets", "icons_charcoal").replace('\\', "/")
path_assets_ghostwhite = os.path.join(path_programm, "_database", "_config", "assets", "icons_ghostwhite").replace('\\', "/")
def get_icon_path(icon, color='charcoal'):
if color == 'charcoal':
icon_path = path_assets_charcoal
else:
icon_path = path_assets_ghostwhite
return os.path.join(icon_path, icon).replace('\\', "/")
class SpinBox_noWheel(QtWidgets.QSpinBox):
def wheelEvent(self, event):
event.ignore()
class DoubleSpinBox_noWheel(QtWidgets.QDoubleSpinBox):
def wheelEvent(self, event):
event.ignore()
class ClickLabel(QtWidgets.QLabel):
clicked = QtCore.pyqtSignal()
def mousePressEvent(self, event):
self.clicked.emit()
QtWidgets.QLabel.mousePressEvent(self, event)
def bring_to_front(window):
window.setWindowFlags(window.windowFlags() | QtCore.Qt.WindowStaysOnTopHint)
window.show()
window.setWindowFlags(window.windowFlags() & ~QtCore.Qt.WindowStaysOnTopHint)
window.show()
def is_empty(structure):
if structure:
return False
else:
return True
def extract_topic_abbr(topic):
x = re.search("\(([a-zA-Z0-9]+)\)", topic)
if x != None:
return x.group(1)
else:
return
def shorten_gk(gk):
gk = gk.lower().replace(" ", "").replace(".", "").replace("-l", "")
return gk
def split_section(section, chosen_program):
section = re.split(" - |{|}", section)
info = [item.strip() for item in section]
info.pop(0)
info.pop(-1)
if chosen_program == "lama":
if re.match("K[0-9]", info[1]) or info[1] == "MAT":
pass
else:
info.insert(1, None)
return info
def still_to_define():
print('still to define')
def check_if_widget_is_visible(widget):
return widget.isVisible()
ag_beschreibung = config_loader(config_file, "ag_beschreibung")
an_beschreibung = config_loader(config_file, "an_beschreibung")
fa_beschreibung = config_loader(config_file, "fa_beschreibung")
ws_beschreibung = config_loader(config_file, "ws_beschreibung")
list_topics = [
list(ag_beschreibung.keys()),
list(an_beschreibung.keys()),
list(fa_beschreibung.keys()),
list(ws_beschreibung.keys()),
]
zusatzthemen_beschreibung = config_loader(config_file, "zusatzthemen_beschreibung")
k5_beschreibung = config_loader(config_file, "k5_beschreibung")
k6_beschreibung = config_loader(config_file, "k6_beschreibung")
k7_beschreibung = config_loader(config_file, "k7_beschreibung")
k8_beschreibung = config_loader(config_file, "k8_beschreibung")
dict_gk = config_loader(config_file, "dict_gk")
Klassen = config_loader(config_file, "Klassen")
list_klassen = config_loader(config_file, "list_klassen")
dict_aufgabenformate = config_loader(config_file, "dict_aufgabenformate")
for klasse in list_klassen:
exec('dict_{0} = config_loader(config_file,"dict_{0}")'.format(klasse))
exec('dict_{0}_name = config_loader(config_file,"dict_{0}_name")'.format(klasse))
dict_unterkapitel = config_loader(config_file, "dict_unterkapitel")