-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPopupCookFinish.py
59 lines (46 loc) · 1.55 KB
/
PopupCookFinish.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
import sys
import mongoDBServer
import math
from bson import ObjectId
from time import sleep
from PyQt5 import QtCore, QtGui, QtWidgets
from PyQt5.QtWidgets import QWidget, QApplication, QMainWindow, QDialog
from PyQt5.QtCore import QObject, QThread, pyqtSignal
import PopupCookFinishUI
class PopUp5Sec(QThread):
time_popup = pyqtSignal(int)
def __init__(self, _id, parent=None):
super(PopUp5Sec, self).__init__(parent)
self.time = 5
self._id = _id
self.currentFood = mongoDBServer.get_food(_id)['stock']
def run(self):
mongoDBServer.food_finish(self._id, self.currentFood)
mongoDBServer.export_log()
while True:
sleep(1)
self.time_popup.emit(self.time)
self.time -= 1
def stop(self):
self.terminate()
class PopupCookFinish(QDialog, PopupCookFinishUI.Ui_Dialog_PopupCookFinish):
def __init__(self, change, _id, parent=None):
super(PopupCookFinish, self).__init__(parent)
self.setupUi(self)
self.change = change
self._id = _id
# var
self.can_close = False
print('เงินทอน : {}'.format(change))
self.PopUp5SecThread = PopUp5Sec(self._id)
self.PopUp5SecThread.start()
self.PopUp5SecThread.time_popup.connect(self.time_popup)
def time_popup(self, time):
if time == 0:
self.PopUp5SecThread.stop()
self.close()
if __name__ == '__main__':
app = QApplication(sys.argv)
form = PopupCookFinish()
form.show()
app.exec_()