-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDetailLogWindow.py
66 lines (55 loc) · 2.77 KB
/
DetailLogWindow.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
import os
from PyQt5 import QtWidgets
from PyQt5.QtWidgets import QMainWindow
from PyQt5.uic import loadUi
from Database import KEYS, Database
class DetailLogWindow(QMainWindow):
def __init__(self, data, parent=None):
super(DetailLogWindow, self).__init__(parent)
loadUi("UI/DetailLog.ui", self)
self.data = data
self.car_image.setScaledContents(True)
self.license_image.setScaledContents(True)
self.ticket_button.clicked.connect(self.ticket)
self.initData()
def ticket(self):
file_name = 'tickets/' + str(self.data[KEYS.CARID]) + '.txt'
with open(file_name, 'w+') as file:
lic_num = str(self.license_number_lineedit.text() or "ঢাকা মেট্রো -ঢ ১১")
rule = self.data[KEYS.RULENAME]
fine = str(self.data[KEYS.RULEFINE])
file.write(' \n')
file.write(' ########################################\n')
file.write(' # Driver Information: #\n')
file.write(' # License Number #\n')
file.write(' #' + ''.join([' ' for i in range(35 - len(lic_num))]) + lic_num + ' #\n')
file.write(' # Rule Broken : #\n')
file.write(' #'+''.join([' ' for i in range(35 - len(rule))]) + rule + ' #\n')
file.write(' # Fine : #\n')
file.write(' #'+''.join([' ' for i in range(34 - len(fine))]) + fine + ' tk #\n')
file.write(' ########################################\n')
self.destroy()
os.popen("notepad " + file_name)
def initData(self):
self.cam_id.setText(str(self.data[KEYS.CARID]))
self.car_color.setText(self.data[KEYS.CARCOLOR])
if self.data[KEYS.CARIMAGE] is not None:
self.car_image.setPixmap(self.data[KEYS.CARIMAGE])
if self.data[KEYS.LICENSEIMAGE] is not None:
self.license_image.setPixmap(self.data[KEYS.LICENSEIMAGE])
self.license_number_lineedit.setText(self.data[KEYS.LICENSENUMBER])
self.location.setText(self.data[KEYS.LOCATION])
self.rule.setText(self.data[KEYS.RULENAME])
self.close_button.clicked.connect(self.close)
self.delete_button.clicked.connect(self.deleteRecord)
def close(self):
self.destroy()
def deleteRecord(self):
qm = QtWidgets.QMessageBox
prompt = qm.question(self, '', "Are you sure to reset all the values?", qm.Yes | qm.No)
if prompt == qm.Yes:
db = Database.get_instance()
db.delete_violation(carid=self.data[KEYS.CARID], ruleid=self.data[KEYS.RULEID], time=self.data[KEYS.TIME])
self.destroy()
else:
pass