-
Notifications
You must be signed in to change notification settings - Fork 0
/
dialogEinstellungenBenutzer.py
71 lines (59 loc) · 2.69 KB
/
dialogEinstellungenBenutzer.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
import configparser, os
from PySide6.QtWidgets import (
QDialogButtonBox,
QDialog,
QVBoxLayout,
QGridLayout,
QLabel,
QLineEdit,
QMessageBox,
)
class EinstellungenBenutzer(QDialog):
def __init__(self, configPath):
super().__init__()
#config.ini lesen
configIni = configparser.ConfigParser()
configIni.read(os.path.join(configPath, "config.ini"))
self.benutzernamen = (configIni["Benutzer"]["namen"]).split("::")
self.benutzerkuerzel = (configIni["Benutzer"]["kuerzel"]).split("::")
self.setWindowTitle("BenutzerInnen verwalten")
self.setMinimumWidth(300)
self.buttonBox = QDialogButtonBox(QDialogButtonBox.StandardButton.Ok | QDialogButtonBox.StandardButton.Cancel)
self.buttonBox.button(QDialogButtonBox.StandardButton.Cancel).setText("Abbrechen")
self.buttonBox.accepted.connect(self.accept) # type: ignore
self.buttonBox.rejected.connect(self.reject) # type: ignore
dialogLayoutV = QVBoxLayout()
dialogLayoutG = QGridLayout()
self.labelNamen = QLabel("Name")
self.labelKuerzel = QLabel("Kürzel")
dialogLayoutG.addWidget(self.labelNamen, 0, 0)
dialogLayoutG.addWidget(self.labelKuerzel, 0, 1)
self.lineEditNamen = []
self.lineEditKuerzel = []
for i in range(10):
self.lineEditNamen.append(QLineEdit())
dialogLayoutG.addWidget(self.lineEditNamen[i], i + 1, 0)
for i in range(10):
self.lineEditKuerzel.append(QLineEdit())
self.lineEditKuerzel[i].setFixedWidth(40)
dialogLayoutG.addWidget(self.lineEditKuerzel[i], i + 1, 1)
for i in range(len(self.benutzernamen)):
self.lineEditNamen[i].setText(self.benutzernamen[i])
self.lineEditKuerzel[i].setText(self.benutzerkuerzel[i])
dialogLayoutV.addLayout(dialogLayoutG)
dialogLayoutV.addWidget(self.buttonBox)
self.setLayout(dialogLayoutV)
self.lineEditNamen[0].setFocus()
self.lineEditNamen[0].setFocus()
def accept(self):
fehlendesKuerzel = -1
for i in range(5):
if self.lineEditNamen[i].text() != "" and self.lineEditKuerzel[i].text() == "":
fehlendesKuerzel = i
break
if fehlendesKuerzel != -1:
mb = QMessageBox(QMessageBox.Icon.Information, "Hinweis von InrGDT", "Für den " + str(fehlendesKuerzel + 1) + ". Benutzer wurde kein Kürzel angegeben.", QMessageBox.StandardButton.Ok)
mb.exec()
self.lineEditKuerzel[fehlendesKuerzel].setFocus()
else:
self.done(1)