-
Notifications
You must be signed in to change notification settings - Fork 0
/
W_zoneTime.py
63 lines (53 loc) · 2.36 KB
/
W_zoneTime.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
from PyQt5.QtCore import *
from PyQt5.QtWidgets import QApplication, QWidget, QMessageBox, QLineEdit
from GUI_zoneTime import Ui_FormZoneTime
from DatabaseAPI import CompanyDB, ZoneTime
import sys
class main(QWidget, Ui_FormZoneTime):
def __init__(self):
QWidget.__init__(self)
self.setupUi(self)
self.onCancel() #set intial times from database
##-------------------------- connect signals --------------------------
self.BT_validate.clicked.connect(self.onValidate)
self.BT_cancel.clicked.connect(self.onCancel)
self.BT_home.clicked.connect(self.home)
##-------------------------- validate button clicked --------------------------
def onValidate(self):
zoneTime = ZoneTime() #instanciation from ZoneTime class
zoneTime.zone1From = self.TE_zone1From.time().toString()
zoneTime.zone1To = self.TE_zone1To.time().toString()
zoneTime.zone2From = self.TE_zone2From.time().toString()
zoneTime.zone2To = self.TE_zone2To.time().toString()
zoneTime.zone3From = self.TE_zone3From.time().toString()
zoneTime.zone3To = self.TE_zone3To.time().toString()
db = CompanyDB()
db.connectdDB()
db.setTimeZoneAccess(zoneTime)
db.closeDB()
msgBox = QMessageBox()
msgBox.setWindowTitle("Commit")
msgBox.setText("Changes successfully added")
msgBox.setIcon(QMessageBox.Information)
ret = msgBox.exec_()
##-------------------------- cancel button clicked --------------------------
def onCancel(self):
zoneTime = ZoneTime()
db = CompanyDB()
db.connectdDB()
zoneTime = db.getTimeZoneAccess()
db.closeDB()
self.TE_zone1From.setTime(QTime.fromString(zoneTime.zone1From))
self.TE_zone1To.setTime(QTime.fromString(zoneTime.zone1To))
self.TE_zone2From.setTime(QTime.fromString(zoneTime.zone2From))
self.TE_zone2To.setTime(QTime.fromString(zoneTime.zone2To))
self.TE_zone3From.setTime(QTime.fromString(zoneTime.zone3From))
self.TE_zone3To.setTime(QTime.fromString(zoneTime.zone3To))
##-------------------------- home button clicked --------------------------
def home(self):
self.close() #close current form
##----------------- Loop --------------------
app = QApplication(sys.argv)
window = main()
window.show()
app.exec()