-
Notifications
You must be signed in to change notification settings - Fork 21
/
merchantgui.py
79 lines (61 loc) · 2.46 KB
/
merchantgui.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
from PyQt4 import QtGui
from PyQt4 import QtCore
class MerchantGUI(QtGui.QWidget):
def __init__(self, controller, currency, parent=None):
QtGui.QWidget.__init__(self, parent)
self.controller = controller
self.currency = currency
self.init_ui()
def init_ui(self):
self.status = QtGui.QLabel()
self.status.setWordWrap(True)
self.status.setMinimumHeight(100)
self.status.setText("System ready.")
amount = QtGui.QLabel()
amount.setText("Amount:")
self.edit = QtGui.QLineEdit()
validator = QtGui.QDoubleValidator(self.edit)
self.edit.setValidator(validator)
self.combo = QtGui.QComboBox()
self.combo.addItem("BTC")
self.combo.addItem(self.currency)
self.rate = QtGui.QLabel()
self.rate.setText("Current exchange rate: ... ")
show = QtGui.QPushButton("Update display")
self.connect(show, QtCore.SIGNAL('clicked()'), self.show_on_clicked)
fullscreen = QtGui.QPushButton("Toggle fullscreen")
self.connect(fullscreen, QtCore.SIGNAL('clicked()'), self.fullscreen_on_clicked)
clear = QtGui.QPushButton("Clear display")
self.connect(clear, QtCore.SIGNAL('clicked()'), self.clear_on_clicked)
hbox1 = QtGui.QHBoxLayout()
hbox1.addWidget(amount)
hbox1.addWidget(self.edit)
hbox1.addWidget(self.combo)
hbox1.addWidget(self.rate)
hbox2 = QtGui.QHBoxLayout()
hbox2.addWidget(show)
hbox2.addWidget(fullscreen)
hbox2.addWidget(clear)
vbox = QtGui.QVBoxLayout()
vbox.addLayout(hbox1)
vbox.addLayout(hbox2)
vbox.addWidget(self.status)
self.setLayout(vbox)
self.setWindowTitle('Point of Sale System - Backend')
def show_on_clicked(self):
if self.edit.text() == "":
amount = 0
else:
amount = float(self.edit.text())
self.controller.init_new_transaction(amount, self.combo.currentText())
def fullscreen_on_clicked(self):
self.controller.toggle_fullscreen_mode()
def clear_on_clicked(self):
self.controller.clear_customer_display()
def update_status(self, message):
self.status.setText(message)
def update_exchange_rate(self, rate):
self.rate.setText("Current exchange rate: %f %s" % (rate, self.currency))
def closeEvent(self, event):
event.accept()
QtGui.QApplication.exit()