-
Notifications
You must be signed in to change notification settings - Fork 1
/
review_rc.py
196 lines (153 loc) · 8.11 KB
/
review_rc.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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
# -*- coding: utf-8 -*-
# Form implementation generated from reading ui file 'review.ui'
#
# Created by: PyQt5 UI code generator 5.15.4
#
# WARNING: Any manual changes made to this file will be lost when pyuic5 is
# run again. Do not edit this file unless you know what you are doing.
from PyQt5 import QtCore, QtGui, QtWidgets
import resource_rc
from PyQt5.QtWidgets import QApplication, QMainWindow,QMessageBox
import client
class Ui_Form(QtWidgets.QWidget):
def __init__(self,main_UI=None,mainwindow=None,id=None):
super(Ui_Form, self).__init__()
self.setupUi(main_UI,mainwindow,id)
def setupUi(self,main_UI=None,mainwindow=None,id=None):
self.main_UI=main_UI
self.MainWindow= mainwindow
self.ID= id
self.setObjectName("Form")
self.resize(1120, 872)
self.horizontalLayout_4 = QtWidgets.QHBoxLayout(self)
self.horizontalLayout_4.setContentsMargins(0, 0, 0, 0)
self.horizontalLayout_4.setObjectName("horizontalLayout_4")
self.widget_2 = QtWidgets.QWidget(self)
self.widget_2.setMaximumSize(QtCore.QSize(100, 100))
self.widget_2.setObjectName("widget_2")
self.verticalLayout_8 = QtWidgets.QVBoxLayout(self.widget_2)
self.verticalLayout_8.setObjectName("verticalLayout_8")
self.label_16 = QtWidgets.QLabel(self.widget_2)
self.label_16.setMinimumSize(QtCore.QSize(50, 50))
self.label_16.setMaximumSize(QtCore.QSize(50, 50))
self.label_16.setAutoFillBackground(False)
self.label_16.setText("")
self.label_16.setTextFormat(QtCore.Qt.PlainText)
self.label_16.setPixmap(QtGui.QPixmap(":/icons/icons/icon.png"))
self.label_16.setScaledContents(True)
self.label_16.setAlignment(QtCore.Qt.AlignBottom|QtCore.Qt.AlignHCenter)
self.label_16.setObjectName("label_16")
self.verticalLayout_8.addWidget(self.label_16)
self.username_label = QtWidgets.QLabel(self.widget_2)
self.username_label.setMaximumSize(QtCore.QSize(50, 50))
self.username_label.setAlignment(QtCore.Qt.AlignCenter)
self.username_label.setObjectName("username_label")
self.verticalLayout_8.addWidget(self.username_label)
self.horizontalLayout_4.addWidget(self.widget_2)
self.widget_3 = QtWidgets.QWidget(self)
self.widget_3.setObjectName("widget_3")
self.verticalLayout = QtWidgets.QVBoxLayout(self.widget_3)
self.verticalLayout.setContentsMargins(0, 0, 0, 0)
self.verticalLayout.setSpacing(0)
self.verticalLayout.setObjectName("verticalLayout")
self.widget_4 = QtWidgets.QWidget(self.widget_3)
self.widget_4.setObjectName("widget_4")
self.verticalLayout_2 = QtWidgets.QVBoxLayout(self.widget_4)
self.verticalLayout_2.setObjectName("verticalLayout_2")
self.horizontalLayout = QtWidgets.QHBoxLayout()
self.horizontalLayout.setObjectName("horizontalLayout")
self.label = QtWidgets.QLabel(self.widget_4)
self.label.setMinimumSize(QtCore.QSize(60, 20))
self.label.setMaximumSize(QtCore.QSize(60, 20))
self.label.setObjectName("label")
self.horizontalLayout.addWidget(self.label)
self.doubleSpinBox = QtWidgets.QDoubleSpinBox(self.widget_4)
self.doubleSpinBox.setDecimals(1)
self.doubleSpinBox.setMaximum(10.0)
self.doubleSpinBox.setObjectName("doubleSpinBox")
self.horizontalLayout.addWidget(self.doubleSpinBox)
spacerItem = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
self.horizontalLayout.addItem(spacerItem)
self.verticalLayout_2.addLayout(self.horizontalLayout)
self.label_2 = QtWidgets.QLabel(self.widget_4)
self.label_2.setObjectName("label_2")
self.verticalLayout_2.addWidget(self.label_2)
self.verticalLayout.addWidget(self.widget_4)
self.widget_5 = QtWidgets.QWidget(self.widget_3)
self.widget_5.setObjectName("widget_5")
self.horizontalLayout_2 = QtWidgets.QHBoxLayout(self.widget_5)
self.horizontalLayout_2.setSizeConstraint(QtWidgets.QLayout.SetDefaultConstraint)
self.horizontalLayout_2.setContentsMargins(0, 0, 0, 0)
self.horizontalLayout_2.setSpacing(0)
self.horizontalLayout_2.setObjectName("horizontalLayout_2")
self.lineEdit = QtWidgets.QLineEdit(self.widget_5)
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.MinimumExpanding, QtWidgets.QSizePolicy.Preferred)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(self.lineEdit.sizePolicy().hasHeightForWidth())
self.lineEdit.setSizePolicy(sizePolicy)
self.lineEdit.setAlignment(QtCore.Qt.AlignLeading|QtCore.Qt.AlignLeft|QtCore.Qt.AlignTop)
self.lineEdit.setObjectName("lineEdit")
self.horizontalLayout_2.addWidget(self.lineEdit)
self.verticalLayout.addWidget(self.widget_5)
self.widget_6 = QtWidgets.QWidget(self.widget_3)
self.widget_6.setObjectName("widget_6")
self.horizontalLayout_3 = QtWidgets.QHBoxLayout(self.widget_6)
self.horizontalLayout_3.setObjectName("horizontalLayout_3")
self.select_file_button_2 = QtWidgets.QPushButton(self.widget_6)
self.select_file_button_2.setAutoDefault(False)
self.select_file_button_2.setDefault(False)
self.select_file_button_2.setObjectName("select_file_button_2")
#zyt
self.select_file_button_2.clicked.connect(self.openFileDialog)
###
self.horizontalLayout_3.addWidget(self.select_file_button_2)
self.file_dir_label_2 = QtWidgets.QLabel(self.widget_6)
self.file_dir_label_2.setText("")
self.file_dir_label_2.setObjectName("file_dir_label_2")
self.horizontalLayout_3.addWidget(self.file_dir_label_2)
spacerItem1 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
self.horizontalLayout_3.addItem(spacerItem1)
self.submit_button_2 = QtWidgets.QPushButton(self.widget_6)
self.submit_button_2.setObjectName("submit_button_2")
self.submit_button_2.clicked.connect(self.submit_review)
self.horizontalLayout_3.addWidget(self.submit_button_2)
self.verticalLayout.addWidget(self.widget_6)
self.horizontalLayout_4.addWidget(self.widget_3)
self.retranslateUi()
QtCore.QMetaObject.connectSlotsByName(self)
def retranslateUi(self):
_translate = QtCore.QCoreApplication.translate
self.setWindowTitle(_translate("Form", "Form"))
self.username_label.setText(_translate("Form", "name"))
self.label.setText(_translate("Form", "Rating:"))
self.label_2.setText(_translate("Form", "Review:"))
self.lineEdit.setPlaceholderText(_translate("Form", "write your review:"))
self.select_file_button_2.setText(_translate("Form", "upload"))
self.submit_button_2.setText(_translate("Form", "submit"))
#zyt
def openFileDialog(self):
options = QtWidgets.QFileDialog.Options()
fileName, _ = QtWidgets.QFileDialog.getOpenFileName(self,
"Select a PNG file", "",
"PNG Files (*.png);;All Files (*)", options=options)
if fileName:
self.file_dir_label_2.setText(fileName)
#####
def submit_review(self):
userid = self.main_UI.id
rating = self.doubleSpinBox.value()
review_text = self.lineEdit.text()
file_dir = self.file_dir_label_2.text()
review_dict = {
"userid": userid,
"movieid": self.ID,
"rate": rating,
"reviewContent": review_text,
"filename": file_dir
}
try_upload = client.add_review(review_dict)
if (not try_upload[0]):
self.MainWindow.show_notification("add_review failed", try_upload[1]['message'])
else:
self.MainWindow.show_notification("add_review successfully", try_upload[1]['message'])