-
Notifications
You must be signed in to change notification settings - Fork 0
/
addEditDialog.py
74 lines (58 loc) · 2.15 KB
/
addEditDialog.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
import sqlite3
from PyQt5 import QtCore, QtGui, QtWidgets
# from PyQt5.uic import loadUi
import sys
from addEditCoffeeForm import Ui_Dialog
from PyQt5.QtWidgets import QApplication, QDialog, QMainWindow, QPushButton
class FilmAddDialog(QDialog, Ui_Dialog):
def __init__(self):
super().__init__()
self.setupUi(self)
self.accepted = 0
self.pushButton.clicked.connect(self.get_data)
self.make_combo_box()
def make_combo_box(self):
for genre in ["В зернах", "Молотый"]:
self.beans.addItem(genre)
def get_data(self):
self.s = self.sort.text()
self.r = str(self.roast.value())
self.b = "True" if self.beans.currentText() == "В зернах" else "False"
self.t = self.taste.text()
self.p = int(self.price.value())
self.v = int(self.volume.value())
self.accepted = 1
self.accept()
def exec_(self):
super(FilmAddDialog, self).exec_()
if self.accepted:
return 1, self.s, self.r, self.b, self.t, self.p, self.v
else:
return 0,
class FilmEditDialog(FilmAddDialog):
def __init__(self, sort, roast, beans, taste, price, volume):
super().__init__()
self.setWindowTitle("Редактирование фильма")
self.sort.setText(sort)
self.roast.setValue(int(roast))
self.beans.setCurrentText("Да" if beans else "Нет")
self.taste.setText(taste)
self.price.setValue(int(price))
self.volume.setValue(int(volume))
def except_hook(cls, exception, traceback):
sys.__excepthook__(cls, exception, traceback)
if __name__ == "__main__":
class Window(QMainWindow):
def __init__(self):
super().__init__()
self.centralWidget = QPushButton("test")
self.centralWidget.clicked.connect(self.film_testing)
self.setCentralWidget(self.centralWidget)
def film_testing(self):
dlg = FilmAddDialog()
print(dlg.exec_())
app = QApplication(sys.argv)
win = Window()
win.show()
sys.excepthook = except_hook
sys.exit(app.exec())