class Startabout(QtGui.QDialog): def __init__(self, parent=None): QtGui.QWidget.__init__(self, parent) self.ui = Ui_Dialog() self.ui.setupUi(self) palette2 = QtGui.QPalette() palette2.setBrush(self.backgroundRole(), QBrush(QImage("./pics/genback.png"))) icon = QtGui.QIcon() b = QtGui.QPixmap("./pics/logo.png") icon.addPixmap(b) self.setWindowIcon(icon) self.setPalette(palette2) self.setStyleSheet('color: rgb(85, 0, 0);') self.ui.close.setStyleSheet('background-color: rgb(0, 147, 203); color: rgb(255, 255, 255);') b = QtGui.QPixmap("./pics/acadmin.png") self.ui.acadmin.setPixmap(QtGui.QPixmap(b)) b = QtGui.QPixmap("./pics/shaastra.png") self.ui.shaastra.setPixmap(QtGui.QPixmap(b)) QtCore.QObject.connect(self.ui.close, QtCore.SIGNAL("clicked()"), self.close)
def __init__(self, parent=None): QtGui.QWidget.__init__(self, parent) self.ui = Ui_Dialog() self.ui.setupUi(self) palette2 = QtGui.QPalette() palette2.setBrush(self.backgroundRole(), QBrush(QImage("./pics/genback.png"))) icon = QtGui.QIcon() b = QtGui.QPixmap("./pics/logo.png") icon.addPixmap(b) self.setWindowIcon(icon) self.setPalette(palette2) self.setStyleSheet('color: rgb(85, 0, 0);') self.ui.close.setStyleSheet('background-color: rgb(0, 147, 203); color: rgb(255, 255, 255);') b = QtGui.QPixmap("./pics/acadmin.png") self.ui.acadmin.setPixmap(QtGui.QPixmap(b)) b = QtGui.QPixmap("./pics/shaastra.png") self.ui.shaastra.setPixmap(QtGui.QPixmap(b)) QtCore.QObject.connect(self.ui.close, QtCore.SIGNAL("clicked()"), self.close)
def about(self): widget = QDialog() ui = Ui_Dialog() ui.setupUi(widget) widget.setFixedSize(400, 78) widget.setWindowTitle('О программе') widget.setWindowIcon(QIcon('icon.jpg')) widget.exec_()
def __init__(self): super(SecondWindow, self).__init__() self.ui = Ui_Dialog() self.ui.setupUi(self)
def __init__(self, dialog): About_Ui_Dialog.__init__(self) self.setupUi(dialog)
class Ui_Test(object): def createclustercsv(self): for i in range(len(cntlistfull)): data = str(cntlistfull[i]) fisbn = (nameisbn.get(data)) print data frate1 = float(isbnrating.get(fisbn)) frate2 = float(sentimented_rating.get(data)) print i print "-----------------------" print frate1 print frate2 print "-----------------------" fratef = (frate1 + frate2) / 2 dd = "" dd = str(fisbn) + "," + str(fratef) + "\n" fcluster1.write(dd) dd = str(data) + "," + str(fratef) + "\n" fcluster2.write(dd) fcluster1.close() fcluster2.close() def findrating(self, rate): if (rate == 0): return 2.5 if (rate < 0): if (rate < -5): return 0.0 elif (rate < -3): return 0.5 elif (rate < -2): return 1.0 elif (rate < -1): return 1.5 else: return 2.0 if (rate > 0): if (rate > 5): return 5.0 elif (rate > 4): return 4.5 elif (rate > 3): return 4.0 elif (rate > 2): return 3.5 elif (rate > 1): return 3.0 else: return 2.3 def updateSystem(self): print "In update" self.adminWindow = QtGui.QWidget() self.ui = Ui_AdminLogin() self.ui.setupUi(self.adminWindow) self.adminWindow.show() def thisProject(self): print "In thisProject" self.adminWindow1 = QtGui.QDialog() self.ui = Ui_Dialog() self.ui.setupUi(self.adminWindow1) self.adminWindow1.show() def Clicked2(self, item): self.listWidgetCategory.clear() self.textEditbookname.clear() self.textEditisbn.clear() print("hello" + item.text()) self.bookname = str(item.text()) #self.listWidgetCategory.clear() self.googleBookName() #QtGui.QMessageBox.information(self, "ListWidget", "You clicked: "+self.item.text()) def Clicked1(self, item): print("hello" + item.text()) self.bookname = str(item.text()) self.listWidgetCategory.clear() self.textEditbookname.clear() self.textEditisbn.clear() self.googleBookName1() #QtGui.QMessageBox.information(self, "ListWidget", "You clicked: "+self.item.text()) def Clicked(self, item): #self.listWidgetCategory.clear() self.textEditbookname.clear() self.textEditisbn.clear() print("hello" + item.text()) self.bookname = str(item.text()) #self.listWidgetCategory.clear() self.googleBookName() #QtGui.QMessageBox.information(self, "ListWidget", "You clicked: "+self.item.text()) def createDict(self): while (1): str1 = f1.readline() if str1 != "": str1 = str1.rstrip("\n") toprated.append(str1) #print str else: break while (1): str1 = f2.readline() if str1 != "": str1 = str1.rstrip("\n") medrated.append(str1) #print str else: break while (1): str1 = f3.readline() if str1 != "": str1 = str1.rstrip("\n") lowrated.append(str1) #print str else: break print "--------------------------------------------------------------------------" print "toprated:" print toprated print "--------------------------------------------------------------------------" print "medrated:" print medrated print "--------------------------------------------------------------------------" print "lowrated:" print lowrated print "--------------------------------------------------------------------------" #Datasets #-------------------------------------------------------------------------------------------------------- self.csvFile1 = "./NewDataSet/full/nameandisbn.csv" self.csvFile2 = "./NewDataSet/full/isbnandname.csv" self.csvFile3 = "./NewDataSet/full/isbnandrating.csv" self.csvFile4 = "./NewDataSet/fiction/bookname.csv" self.csvFile5 = "./NewDataSet/indiannovel/bookname.csv" self.csvFile6 = "./NewDataSet/journal/bookname.csv" self.csvFile7 = "./NewDataSet/literature/bookname.csv" self.csvFile8 = "./NewDataSet/full/isbnanddesc.csv" self.csvFile9 = "./NewDataSet/namereview.csv" #-------------------------------------------------------------------------------------------------------- flag1 = os.path.exists(self.csvFile9) if (not flag1): #to check existing path or not? print("Give proper path") else: reader = csv.reader(open(self.csvFile9)) for row in reader: '''if reader.line_num == 1: headers = row[1:] else:''' ddd = row[1] sentimented_rating[row[0]] = ddd print "--------------------------------------------------------------------------------------------------------" for keys, values in sentimented_rating.items(): print(keys) print(values) print "--------------------------------------------------------------------------------------------------------" '''#For sentiment analysis self.csvFile9="./NewDataSet/book1.csv" flag0=os.path.exists(self.csvFile9) if(not flag0):#to check existing path or not? print("Give proper path") else: reader=csv.reader(open(self.csvFile9)) cnt=0 for i in reader: cnt=cnt+1 print ("Count") print (cnt) for row in reader: if reader.line_num == 1: headers = row[1:] else: ddd=row[1] a=str(ddd) x=len(a) print x s=[] j=0 strs="" gog="" rating=0 for i in range(x): if(a[i]!="$" and i!=(x-1)): #print a[i] strs=strs+a[i] else: print strs s.append(strs) strs="" l=len(s) obj=Bs() for i in range(l): #print s[i] tyu=float(obj.name(str(s[i]))) rating=rating+tyu print "Rating :" print rating print "Average Rating :" kkukk=rating/l print kkukk gog=str(row[0])+","+str(kkukk)+"\n" f4.write(gog) namereview[row[0]] = kkukk print "-----------------------------------------------------------------------------------" print "namereview" print namereview print "-----------------------------------------------------------------------------------" print namereview t=len(namereview) print t for x in namereview: print x''' #-------------------------------------------------------------------------------------------------------- flag1 = os.path.exists(self.csvFile1) if (not flag1): #to check existing path or not? print("Give proper path") else: reader = csv.reader(open(self.csvFile1)) for row in reader: if reader.line_num == 1: headers = row[1:] else: ddd = row[1] nameisbn[row[0]] = ddd flag2 = os.path.exists(self.csvFile2) if (not flag2): #to check existing path or not? print("Give proper path") else: reader = csv.reader(open(self.csvFile2)) for row in reader: if reader.line_num == 1: headers = row[1:] else: ddd = row[1] isbnname[row[0]] = ddd flag3 = os.path.exists(self.csvFile3) if (not flag3): #to check existing path or not? print("Give proper path") else: reader = csv.reader(open(self.csvFile3)) for row in reader: if reader.line_num == 1: headers = row[1:] else: ddd = row[1] isbnrating[row[0]] = ddd '''reader= csv.reader(open(csvFile4)) for row in reader1: #print row[0] if reader1.line_num > 1: cntlist.append(row[0])''' flag4 = os.path.exists(self.csvFile4) if (not flag4): #to check existing path or not? print("Give proper path") else: reader = csv.reader(open(self.csvFile4)) for row in reader: if reader.line_num > 1: cntlistFiction.append(row[0]) flag5 = os.path.exists(self.csvFile5) if (not flag5): #to check existing path or not? print("Give proper path") else: reader = csv.reader(open(self.csvFile5)) for row in reader: if reader.line_num > 1: cntlistIndianNovel.append(row[0]) flag6 = os.path.exists(self.csvFile6) if (not flag6): #to check existing path or not? print("Give proper path") else: reader = csv.reader(open(self.csvFile6)) for row in reader: if reader.line_num > 1: cntlistJournal.append(row[0]) #-------------------------------------------------------------- flag6 = os.path.exists(csvFile0) if (not flag6): #to check existing path or not? print("Give proper path") else: reader = csv.reader(open(csvFile0)) for row in reader: if reader.line_num > 1: cntlistfull.append(row[0]) #-------------------------------------------------------------- flag7 = os.path.exists(self.csvFile7) if (not flag7): #to check existing path or not? print("Give proper path") else: reader = csv.reader(open(self.csvFile7)) for row in reader: if reader.line_num > 1: cntlistLiterature.append(row[0]) flag8 = os.path.exists(self.csvFile8) if (not flag1): #to check existing path or not? print("Give proper path") else: reader = csv.reader(open(self.csvFile8)) for row in reader: if reader.line_num == 1: headers = row[1:] else: ddd = row[1] isbndesc[row[0]] = ddd def selectionchange(self, j): self.listWidgetSimilarBooks.clear() self.textEditrating.clear() print "Items in the list are :" '''for count in range(self.comboBox.count()): print self.comboBox.itemText(count)''' print "Current index", j, "selection changed ", self.comboBoxCategory.currentText( ) if (j == 0): #-- self.listWidgetCategory.clear() for i in cntlistFiction: self.item1 = QtGui.QListWidgetItem(i) self.listWidgetCategory.addItem(self.item1) elif (j == 1): #-- self.listWidgetCategory.clear() for i in cntlistIndianNovel: self.item2 = QtGui.QListWidgetItem(i) self.listWidgetCategory.addItem(self.item2) elif (j == 2): #-- self.listWidgetCategory.clear() for i in cntlistJournal: self.item3 = QtGui.QListWidgetItem(i) self.listWidgetCategory.addItem(self.item3) elif (j == 3): #-- self.listWidgetCategory.clear() for i in cntlistLiterature: self.item3 = QtGui.QListWidgetItem(i) self.listWidgetCategory.addItem(self.item3) def selectionchange1(self, j): self.textEditrating.clear() self.listWidgetSimilarBooks.clear() if (j == 0): #-- self.listWidgetCategory.clear() self.listWidgetRating.clear() for i in toprated: self.item1 = QtGui.QListWidgetItem(i) item2 = str(isbnname.get(str(i))) print item2 self.listWidgetRating.addItem(item2) if (j == 1): #-- self.listWidgetCategory.clear() self.listWidgetRating.clear() for i in medrated: self.item1 = QtGui.QListWidgetItem(i) item2 = str(isbnname.get(str(i))) print item2 self.listWidgetRating.addItem(item2) if (j == 2): #-- self.listWidgetCategory.clear() self.listWidgetRating.clear() for i in lowrated: self.item1 = QtGui.QListWidgetItem(i) item2 = str(isbnname.get(str(i))) print item2 self.listWidgetRating.addItem(item2) def googleBookName1(self): '''print(self.bookname) self.csvFile="./NewDataSet/full/nameandisbn.csv" flag=os.path.exists(self.csvFile) if(not flag):#to check existing path or not? print("Give proper path") else: reader=csv.reader(open(self.csvFile)) for row in reader: if reader.line_num == 1: headers = row[1:] else: ddd=row[1] nameisbn[row[0]] = ddd''' print self.bookname self.x = nameisbn.has_key(self.bookname) print(self.x) if (self.x): print("Found") self.result = "" self.isbn1 = nameisbn.get(self.bookname) xxxx1 = float(isbnrating.get(self.isbn1)) yyyy = float(sentimented_rating.get(self.bookname)) print "--------------------------------------------------------------" print "yyyyy" print yyyy print "--------------------------------------------------------------" yyyy1 = self.findrating(yyyy) xxxx = (yyyy1 + xxxx1) / 2 xyz = str(nameisbn.get(self.bookname)) print(xxxx) if (xxxx >= 4): self.result = "Best Book" elif (xxxx >= 3): self.result = "Good Book" elif (xxxx >= 2): self.result = "Average Book" else: self.result = "Minimum Average Book" self.output = "Rating of the book:\nBook Name : " + self.bookname + " is : " + str( xxxx ) + " out of 5 \nOur Recommendation : " + self.result + "\nBook ISBN : " + str( self.isbn1) #self.textEdit2.setText() else: self.output = "OOPs !!!\nThe Searched Book is not In our Database.\n" print(self.output) self.textEditrating.setText(self.output) def part1(self): xyz = str(isbndesc.get(self.isbn1)) print xyz if xyz == 'indian novels': random.shuffle(cntlistIndianNovel) self.listWidgetSimilarBooks.clear() for i in cntlistIndianNovel: self.item5 = QtGui.QListWidgetItem(i) self.listWidgetSimilarBooks.addItem(self.item5) elif xyz == 'journals': random.shuffle(cntlistJournal) self.listWidgetSimilarBooks.clear() for i in cntlistJournal: self.item6 = QtGui.QListWidgetItem(i) self.listWidgetSimilarBooks.addItem(self.item6) elif xyz == 'fiction': random.shuffle(cntlistFiction) self.listWidgetSimilarBooks.clear() for i in cntlistFiction: self.item7 = QtGui.QListWidgetItem(i) self.listWidgetSimilarBooks.addItem(self.item7) elif xyz == 'literature': random.shuffle(cntlistLiterature) self.listWidgetSimilarBooks.clear() for i in cntlistLiterature: self.item8 = QtGui.QListWidgetItem(i) self.listWidgetSimilarBooks.addItem(self.item8) def googleBookName(self): '''print(self.bookname) self.csvFile="./NewDataSet/full/nameandisbn.csv" flag=os.path.exists(self.csvFile) if(not flag):#to check existing path or not? print("Give proper path") else: reader=csv.reader(open(self.csvFile)) for row in reader: if reader.line_num == 1: headers = row[1:] else: ddd=row[1] nameisbn[row[0]] = ddd''' print self.bookname self.x = nameisbn.has_key(self.bookname) print(self.x) if (self.x): print("Found") self.result = "" self.isbn1 = nameisbn.get(self.bookname) xxxx1 = float(isbnrating.get(self.isbn1)) yyyy = float(sentimented_rating.get(self.bookname)) print "--------------------------------------------------------------" print "yyyyy" print yyyy print "--------------------------------------------------------------" yyyy1 = self.findrating(yyyy) xxxx = (yyyy1 + xxxx1) / 2 xyz = str(nameisbn.get(self.bookname)) print(xxxx) if (xxxx >= 4): self.result = "Best Book" elif (xxxx >= 3): self.result = "Good Book" elif (xxxx >= 2): self.result = "Average Book" else: self.result = "Minimum Average Book" xyz = str(isbndesc.get(self.isbn1)) self.output = "Rating of the book:\nBook Name : " + self.bookname + " is : " + str( xxxx ) + " out of 5 \nOur Recommendation : " + self.result + "\nBook ISBN : " + str( self.isbn1) + "\nBook Category : " + xyz print(self.output) self.textEditrating.setText(self.output) #self.textEdit2.setText() self.part1() else: self.output = "OOPs !!!\nThe Searched Book is not In our Database.\n" print(self.output) self.textEditrating.setText(self.output) def part2(self): xyz = str(isbndesc.get(self.isbn)) print xyz if xyz == 'indian novels': random.shuffle(cntlistIndianNovel) self.listWidgetSimilarBooks.clear() for i in cntlistIndianNovel: self.item5 = QtGui.QListWidgetItem(i) self.listWidgetSimilarBooks.addItem(self.item5) elif xyz == 'journals': random.shuffle(cntlistJournal) self.listWidgetSimilarBooks.clear() for i in cntlistJournal: self.item6 = QtGui.QListWidgetItem(i) self.listWidgetSimilarBooks.addItem(self.item6) elif xyz == 'fiction': random.shuffle(cntlistFiction) self.listWidgetSimilarBooks.clear() for i in cntlistFiction: self.item7 = QtGui.QListWidgetItem(i) self.listWidgetSimilarBooks.addItem(self.item7) elif xyz == 'literature': random.shuffle(cntlistLiterature) self.listWidgetSimilarBooks.clear() for i in cntlistLiterature: self.item8 = QtGui.QListWidgetItem(i) self.listWidgetSimilarBooks.addItem(self.item8) def googleIsbn(self): '''print(self.bookname) self.csvFile="./NewDataSet/full/nameandisbn.csv" flag=os.path.exists(self.csvFile) if(not flag):#to check existing path or not? print("Give proper path") else: reader=csv.reader(open(self.csvFile)) for row in reader: if reader.line_num == 1: headers = row[1:] else: ddd=row[1] nameisbn[row[0]] = ddd''' self.x = isbnrating.has_key(self.isbn) self.y = str(isbnname.get(self.isbn)) print self.y print(self.x) if (self.x): print("Found") self.result = "" isbn = self.isbn xxxx = float(isbnrating.get(isbn)) print(xxxx) if (xxxx >= 4): self.result = "Best Book" elif (xxxx >= 3): self.result = "Good Book" elif (xxxx >= 2): self.result = "Average Book" else: self.result = "Minimum Average Book" xyz = str(isbndesc.get(self.isbn)) self.output = "Rating of the book:\nBook ISBN : " + self.isbn + " is : " + str( xxxx ) + " out of 5 \nOur Recommendation : " + self.result + "\nBook Name : " + self.y + "\nBook Category : " + xyz print(self.output) self.textEditrating.setText(self.output) #self.textEdit2.setText() self.part2() else: self.output = "OOPs !!!\nThe Searched Book is not In our Database.\nOr\nGive a correct ISBN." print(self.output) self.textEditrating.setText(self.output) def btnClick1(self): self.listWidgetSimilarBooks.clear() self.listWidgetCategory.clear() self.listWidgetRating.clear() self.textEditrating.clear() self.bookname = str(self.textEditbookname.text()) self.bookname = self.bookname.lower() self.textEditisbn.clear() print self.bookname if (self.bookname == ""): self.textEditrating.setText("OOPs ! \n Please Give a Book Name") else: self.googleBookName() def btnClick2(self): self.listWidgetSimilarBooks.clear() self.listWidgetCategory.clear() self.listWidgetRating.clear() self.textEditrating.clear() self.isbn = str(self.textEditisbn.text()) self.textEditbookname.clear() print(self.isbn) if (self.isbn == ""): self.textEditrating.setText( "OOPs ! \n Please Give a Book ISBN Number") else: self.googleIsbn() def setupUi(self, Test): self.createDict() self.createclustercsv() Test.setObjectName(_fromUtf8("Test")) Test.resize(1133, 638) icon = QtGui.QIcon() icon.addPixmap(QtGui.QPixmap(_fromUtf8(":/StartPage/network.ico")), QtGui.QIcon.Normal, QtGui.QIcon.Off) Test.setWindowIcon(icon) sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(Test.sizePolicy().hasHeightForWidth()) Test.setSizePolicy(sizePolicy) Test.setMinimumSize(QtCore.QSize(1133, 638)) Test.setMaximumSize(QtCore.QSize(1133, 638)) font = QtGui.QFont() font.setKerning(True) Test.setFont(font) Test.setLayoutDirection(QtCore.Qt.LeftToRight) Test.setAutoFillBackground(False) self.centralwidget = QtGui.QWidget(Test) self.centralwidget.setObjectName(_fromUtf8("centralwidget")) self.label_2 = QtGui.QLabel(self.centralwidget) self.label_2.setGeometry(QtCore.QRect(10, 80, 211, 23)) font = QtGui.QFont() font.setPointSize(12) font.setBold(True) font.setWeight(75) self.label_2.setFont(font) self.label_2.setObjectName(_fromUtf8("label_2")) self.btnBookname = QtGui.QPushButton(self.centralwidget) self.btnBookname.setGeometry(QtCore.QRect(10, 150, 85, 27)) self.btnBookname.setObjectName(_fromUtf8("btnBookname")) ######################################################## #self.createDict() self.btnBookname.clicked.connect(self.btnClick1) ######################################################## self.label_3 = QtGui.QLabel(self.centralwidget) self.label_3.setGeometry(QtCore.QRect(10, 330, 74, 23)) font = QtGui.QFont() font.setPointSize(15) font.setBold(True) font.setWeight(75) self.label_3.setFont(font) self.label_3.setObjectName(_fromUtf8("label_3")) self.btnisbn = QtGui.QPushButton(self.centralwidget) self.btnisbn.setGeometry(QtCore.QRect(10, 280, 85, 27)) self.btnisbn.setObjectName(_fromUtf8("btnisbn")) ######################################################## self.btnisbn.clicked.connect(self.btnClick2) ######################################################## self.label_4 = QtGui.QLabel(self.centralwidget) self.label_4.setGeometry(QtCore.QRect(10, 200, 201, 41)) font = QtGui.QFont() font.setPointSize(12) font.setBold(True) font.setWeight(75) self.label_4.setFont(font) self.label_4.setObjectName(_fromUtf8("label_4")) self.textEditrating = QtGui.QTextEdit(self.centralwidget) self.textEditrating.setGeometry(QtCore.QRect(10, 360, 381, 221)) ######################################################## ######################################################## font = QtGui.QFont() font.setPointSize(12) font.setBold(True) font.setWeight(75) self.textEditrating.setFont(font) self.textEditrating.setTextInteractionFlags( QtCore.Qt.TextSelectableByKeyboard | QtCore.Qt.TextSelectableByMouse) self.textEditrating.setObjectName(_fromUtf8("textEditrating")) self.textEditbookname = QtGui.QLineEdit(self.centralwidget) self.textEditbookname.setGeometry(QtCore.QRect(10, 110, 311, 31)) self.textEditbookname.setObjectName(_fromUtf8("textEditbookname")) self.textEditisbn = QtGui.QLineEdit(self.centralwidget) self.textEditisbn.setGeometry(QtCore.QRect(10, 240, 311, 31)) self.textEditisbn.setObjectName(_fromUtf8("textEditisbn")) self.verticalLayoutWidget = QtGui.QWidget(self.centralwidget) self.verticalLayoutWidget.setGeometry(QtCore.QRect(10, 0, 1111, 61)) self.verticalLayoutWidget.setObjectName( _fromUtf8("verticalLayoutWidget")) self.verticalLayout = QtGui.QVBoxLayout(self.verticalLayoutWidget) self.verticalLayout.setObjectName(_fromUtf8("verticalLayout")) self.label = QtGui.QLabel(self.verticalLayoutWidget) font = QtGui.QFont() font.setPointSize(20) font.setBold(True) font.setWeight(75) self.label.setFont(font) self.label.setLayoutDirection(QtCore.Qt.LeftToRight) self.label.setTextFormat(QtCore.Qt.RichText) self.label.setScaledContents(True) self.label.setAlignment(QtCore.Qt.AlignCenter) self.label.setIndent(1) self.label.setObjectName(_fromUtf8("label")) self.verticalLayout.addWidget(self.label) self.label_5 = QtGui.QLabel(self.centralwidget) self.label_5.setGeometry(QtCore.QRect(350, 70, 211, 21)) font = QtGui.QFont() font.setPointSize(12) font.setBold(True) font.setWeight(75) self.label_5.setFont(font) self.label_5.setObjectName(_fromUtf8("label_5")) self.comboBoxCategory = QtGui.QComboBox(self.centralwidget) self.comboBoxCategory.setGeometry(QtCore.QRect(350, 100, 221, 24)) self.comboBoxCategory.setObjectName(_fromUtf8("comboBoxCategory")) self.comboBoxCategory.addItem(_fromUtf8("")) self.comboBoxCategory.addItem(_fromUtf8("")) self.comboBoxCategory.addItem(_fromUtf8("")) self.comboBoxCategory.addItem(_fromUtf8("")) ######################################################## self.comboBoxCategory.currentIndexChanged.connect(self.selectionchange) ######################################################## self.listWidgetCategory = QtGui.QListWidget(self.centralwidget) self.listWidgetCategory.setGeometry(QtCore.QRect(350, 130, 371, 181)) self.listWidgetCategory.setObjectName(_fromUtf8("listWidgetCategory")) '''item = QtGui.QListWidgetItem() self.listWidgetCategory.addItem(item)''' ######################################################## self.listWidgetCategory.itemClicked.connect(self.Clicked) ######################################################## self.listWidgetSimilarBooks = QtGui.QListWidget(self.centralwidget) self.listWidgetSimilarBooks.setGeometry( QtCore.QRect(450, 360, 671, 221)) self.listWidgetSimilarBooks.setObjectName( _fromUtf8("listWidgetSimilarBooks")) '''item = QtGui.QListWidgetItem() self.listWidgetSimilarBooks.addItem(item)''' ######################################################## self.listWidgetSimilarBooks.itemClicked.connect(self.Clicked1) ######################################################## self.label_6 = QtGui.QLabel(self.centralwidget) self.label_6.setGeometry(QtCore.QRect(450, 330, 191, 23)) font = QtGui.QFont() font.setPointSize(15) font.setBold(True) font.setWeight(75) self.label_6.setFont(font) self.label_6.setObjectName(_fromUtf8("label_6")) self.line = QtGui.QFrame(self.centralwidget) self.line.setGeometry(QtCore.QRect(10, 310, 1111, 16)) self.line.setFrameShape(QtGui.QFrame.HLine) self.line.setFrameShadow(QtGui.QFrame.Sunken) self.line.setObjectName(_fromUtf8("line")) self.line_2 = QtGui.QFrame(self.centralwidget) self.line_2.setGeometry(QtCore.QRect(330, 70, 16, 241)) self.line_2.setFrameShape(QtGui.QFrame.VLine) self.line_2.setFrameShadow(QtGui.QFrame.Sunken) self.line_2.setObjectName(_fromUtf8("line_2")) self.line_3 = QtGui.QFrame(self.centralwidget) self.line_3.setGeometry(QtCore.QRect(10, 60, 1111, 20)) self.line_3.setFrameShape(QtGui.QFrame.HLine) self.line_3.setFrameShadow(QtGui.QFrame.Sunken) self.line_3.setObjectName(_fromUtf8("line_3")) self.label_7 = QtGui.QLabel(self.centralwidget) self.label_7.setGeometry(QtCore.QRect(740, 70, 211, 21)) font = QtGui.QFont() font.setPointSize(12) font.setBold(True) font.setWeight(75) self.label_7.setFont(font) self.label_7.setObjectName(_fromUtf8("label_7")) self.listWidgetRating = QtGui.QListWidget(self.centralwidget) self.listWidgetRating.setGeometry(QtCore.QRect(740, 130, 381, 181)) self.listWidgetRating.setObjectName(_fromUtf8("listWidgetRating")) '''item = QtGui.QListWidgetItem() self.listWidgetRating.addItem(item)''' ######################################################## self.listWidgetRating.itemClicked.connect(self.Clicked2) ######################################################## self.comboBoxRating = QtGui.QComboBox(self.centralwidget) self.comboBoxRating.setGeometry(QtCore.QRect(740, 100, 221, 24)) self.comboBoxRating.setObjectName(_fromUtf8("comboBoxRating")) self.comboBoxRating.addItem(_fromUtf8("")) self.comboBoxRating.addItem(_fromUtf8("")) self.comboBoxRating.addItem(_fromUtf8("")) ######################################################## self.comboBoxRating.currentIndexChanged.connect(self.selectionchange1) ######################################################## self.line_4 = QtGui.QFrame(self.centralwidget) self.line_4.setGeometry(QtCore.QRect(720, 70, 16, 241)) self.line_4.setFrameShape(QtGui.QFrame.VLine) self.line_4.setFrameShadow(QtGui.QFrame.Sunken) self.line_4.setObjectName(_fromUtf8("line_4")) self.line_5 = QtGui.QFrame(self.centralwidget) self.line_5.setGeometry(QtCore.QRect(410, 320, 20, 261)) self.line_5.setFrameShape(QtGui.QFrame.VLine) self.line_5.setFrameShadow(QtGui.QFrame.Sunken) self.line_5.setObjectName(_fromUtf8("line_5")) self.line_6 = QtGui.QFrame(self.centralwidget) self.line_6.setGeometry(QtCore.QRect(10, 180, 321, 20)) self.line_6.setFrameShape(QtGui.QFrame.HLine) self.line_6.setFrameShadow(QtGui.QFrame.Sunken) self.line_6.setObjectName(_fromUtf8("line_6")) Test.setCentralWidget(self.centralwidget) self.menubar = QtGui.QMenuBar(Test) self.menubar.setGeometry(QtCore.QRect(0, 0, 1133, 20)) self.menubar.setObjectName(_fromUtf8("menubar")) self.menuFile = QtGui.QMenu(self.menubar) self.menuFile.setObjectName(_fromUtf8("menuFile")) self.menuAbout_Us = QtGui.QMenu(self.menubar) self.menuAbout_Us.setObjectName(_fromUtf8("menuAbout_Us")) self.menuAdmin = QtGui.QMenu(self.menubar) self.menuAdmin.setObjectName(_fromUtf8("menuAdmin")) Test.setMenuBar(self.menubar) self.statusbar = QtGui.QStatusBar(Test) self.statusbar.setObjectName(_fromUtf8("statusbar")) Test.setStatusBar(self.statusbar) self.toolBar = QtGui.QToolBar(Test) self.toolBar.setObjectName(_fromUtf8("toolBar")) Test.addToolBar(QtCore.Qt.TopToolBarArea, self.toolBar) self.actionClose = QtGui.QAction(Test) self.actionClose.setObjectName(_fromUtf8("actionClose")) self.actionUndo = QtGui.QAction(Test) self.actionUndo.setObjectName(_fromUtf8("actionUndo")) self.actionUpdate_System = QtGui.QAction(Test) self.actionUpdate_System.setObjectName( _fromUtf8("actionUpdate_System")) #self.actionUpdate_System.addAction(self.update) self.actionThis_Project = QtGui.QAction(Test) self.actionThis_Project.setObjectName(_fromUtf8("actionThis_Project")) self.menuFile.addAction(self.actionClose) self.menuAbout_Us.addAction(self.actionThis_Project) self.menuAdmin.addAction(self.actionUpdate_System) self.menubar.addAction(self.menuFile.menuAction()) self.menubar.addAction(self.menuAdmin.menuAction()) self.menubar.addAction(self.menuAbout_Us.menuAction()) self.retranslateUi(Test) QtCore.QObject.connect(self.actionClose, QtCore.SIGNAL(_fromUtf8("activated()")), Test.close) QtCore.QObject.connect(self.actionUpdate_System, QtCore.SIGNAL(_fromUtf8("activated()")), self.updateSystem) QtCore.QObject.connect(self.actionThis_Project, QtCore.SIGNAL(_fromUtf8("activated()")), self.thisProject) QtCore.QMetaObject.connectSlotsByName(Test) def retranslateUi(self, Test): Test.setWindowTitle(_translate("Test", "Test", None)) self.label_2.setText(_translate("Test", "Search By Book Name", None)) self.btnBookname.setText(_translate("Test", "Search..", None)) self.label_3.setText(_translate("Test", "Rating :", None)) self.btnisbn.setText(_translate("Test", "Search..", None)) self.label_4.setText(_translate("Test", "Search By ISBN ", None)) self.textEditrating.setHtml( _translate( "Test", "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0//EN\" \"http://www.w3.org/TR/REC-html40/strict.dtd\">\n" "<html><head><meta name=\"qrichtext\" content=\"1\" /><style type=\"text/css\">\n" "p, li { white-space: pre-wrap; }\n" "</style></head><body style=\" font-family:\'Sans\'; font-size:12pt; font-weight:600; font-style:normal;\">\n" "<p align=\"justify\" style=\" margin-top:12px; margin-bottom:12px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><br /></p></body></html>", None)) self.label.setText( _translate("Test", " BOOK RECOMMENDATION SYSTEM", None)) self.label_5.setText(_translate("Test", "Search By Category ", None)) self.comboBoxCategory.setItemText(0, _translate("Test", "Fiction", None)) self.comboBoxCategory.setItemText( 1, _translate("Test", "Indian Novels", None)) self.comboBoxCategory.setItemText(2, _translate("Test", "Journals", None)) self.comboBoxCategory.setItemText( 3, _translate("Test", "Literature", None)) __sortingEnabled = self.listWidgetCategory.isSortingEnabled() self.listWidgetCategory.setSortingEnabled(False) ############################################################ '''item = self.listWidgetCategory.item(0) item.setText(_translate("Test", "New Item", None))''' ############################################################ self.listWidgetCategory.setSortingEnabled(__sortingEnabled) __sortingEnabled = self.listWidgetSimilarBooks.isSortingEnabled() self.listWidgetSimilarBooks.setSortingEnabled(False) ############################################################ '''item = self.listWidgetSimilarBooks.item(0) item.setText(_translate("Test", "New Item", None))''' ############################################################ self.listWidgetSimilarBooks.setSortingEnabled(__sortingEnabled) self.label_6.setText(_translate("Test", "Similar Books", None)) self.label_7.setText(_translate("Test", "Search By Rating ", None)) __sortingEnabled = self.listWidgetRating.isSortingEnabled() self.listWidgetRating.setSortingEnabled(False) ############################################################ '''item = self.listWidgetRating.item(0) item.setText(_translate("Test", "New Item", None))''' ############################################################ self.listWidgetRating.setSortingEnabled(__sortingEnabled) self.comboBoxRating.setItemText(0, _translate("Test", "Top Rated", None)) self.comboBoxRating.setItemText( 1, _translate("Test", "Medium Rated", None)) self.comboBoxRating.setItemText(2, _translate("Test", "Low Rated", None)) self.menuFile.setTitle(_translate("Test", "File", None)) self.menuAbout_Us.setTitle(_translate("Test", "About Us", None)) self.menuAdmin.setTitle(_translate("Test", "Admin", None)) self.toolBar.setWindowTitle(_translate("Test", "toolBar", None)) self.actionClose.setText(_translate("Test", "Close", None)) self.actionUndo.setText(_translate("Test", "Undo", None)) self.actionUpdate_System.setText( _translate("Test", "Update System", None)) self.actionThis_Project.setText( _translate("Test", "This Project", None))
class SecondWindow(QtWidgets.QWidget): def __init__(self): super(SecondWindow, self).__init__() self.ui = Ui_Dialog() self.ui.setupUi(self)
def updateSystem(self): print "In update" self.adminWindow = QtGui.QWidget() self.ui = Ui_AdminLogin() self.ui.setupUi(self.adminWindow) self.adminWindow.show()
def thisProject(self): print "In thisProject" self.adminWindow1 = QtGui.QDialog() self.ui = Ui_Dialog() self.ui.setupUi(self.adminWindow1) self.adminWindow1.show()
def on_action_triggered(self): a = Ui_Dialog() d = QDialog() a.setupUi(d) d.exec()
def __init__(self): QtGui.QDialog.__init__(self) self.ui = Ui_Dialog() self.ui.setupUi(self)
class AboutDialog(QDialog): def __init__(self): super().__init__() self.ui = AboutUI() self.ui.setupUi(self)
class AboutD(QtGui.QDialog): def __init_(self): super(AboutD, self).__init__() self.dialog = Ui_Dialog() self.dialog.setupUi(self)
class MyWindow(QMainWindow, Ui_MainWindow): def __init__(self): super().__init__() # 窗口位置 self.move(600, 200) # 窗口大小 self.resize(400, 400) # 窗口透明度 # self.setWindowOpacity(0.9) # 导入qt designer设计的布局样式 self.setupUi(self) # 自定义布局样式 self.setup_ui() def paintEvent(self, event): """ 设置主窗口背景图片 :param event: :return: """ painter = QPainter(self) # todo 1 设置背景颜色 painter.setBrush(Qt.green) painter.drawRect(self.rect()) # #todo 2 设置背景图片,平铺到整个窗口,随着窗口改变而改变 pixmap = QPixmap("./main_bg.jpg") painter.drawPixmap(self.rect(), pixmap) def setup_ui(self): # 设置关于我们弹窗的信号与槽 self.actionabout_us.triggered.connect(self.show_about_widget) # 设置表格 单元格宽度自动适应 self.tableWidget.horizontalHeader().setSectionResizeMode( QHeaderView.Stretch) @pyqtSlot() def on_pushButton_clicked(self): keyword = self.lineEdit.text() # 开始查询歌曲 利用查询结果 填充表格 if not keyword: return self.search_song = SearchSong(keyword) self.search_song.searched[list].connect(self.fill_table) self.search_song.searched[str].connect(self.show_searched_exception) self.search_song.start() def show_searched_exception(self, searched_exception): self.textBrowser.append(searched_exception) def download_the_song(self, i): # print(f'下载第{i+1}首歌曲,歌曲信息为{self.songs[i]}') self.textBrowser.append(f'正在下载第{i+1}首歌曲...') song = self.songs[i] self.download_song = DownloadSong(song) self.download_song.downloaded.connect(self.show_download_info) self.download_song.start() def show_download_info(self, info): # print(info) self.textBrowser.append(info) def download_btn(self, i): wg = QWidget() btn = QPushButton('下载') btn.setObjectName('btn') btn.setStyleSheet("#btn{\n" "color:white;\n" "border-color:white;\n" "background:transparent;\n" "}") btn.setMinimumHeight(20) btn.clicked.connect(lambda: self.download_the_song(i)) hbl = QHBoxLayout() hbl.addWidget(btn) hbl.setContentsMargins(0, 0, 0, 0) wg.setLayout(hbl) return wg def fill_table(self, songs): """ 填充表格 :param songs: 与该槽函数对应的信号发射的数据,也就是歌曲列表 :return: """ # print(songs) # print('填充表格') # 保存一份songs数据到主窗体对象中 以便后面方便使用 self.songs = songs self.tableWidget.setColumnCount(4) self.tableWidget.setRowCount(len(songs)) for index, song in enumerate(songs): self.tableWidget.setItem(index, 0, QTableWidgetItem(song['song_name'])) self.tableWidget.setItem(index, 1, QTableWidgetItem(song['artist'])) self.tableWidget.setItem(index, 2, QTableWidgetItem(song['album'])) self.tableWidget.setCellWidget(index, 3, self.download_btn(index)) def show_about_widget(self): self.ui_about = Ui_Dialog() self.about_win = QDialog() self.ui_about.setupUi(self.about_win) self.about_win.setWindowTitle('关于我们') self.about_win.show()
def show_about_widget(self): self.ui_about = Ui_Dialog() self.about_win = QDialog() self.ui_about.setupUi(self.about_win) self.about_win.setWindowTitle('关于我们') self.about_win.show()
def openAbout(self): self.aboutWindow = QtWidgets.QDialog() self.ui = Ui_Dialog() self.ui.setupUi(self.aboutWindow) self.aboutWindow.show()
class Ui_DBConnectionGen(object): def openAbout(self): self.aboutWindow = QtWidgets.QDialog() self.ui = Ui_Dialog() self.ui.setupUi(self.aboutWindow) self.aboutWindow.show() def setupUi(self, DBConnectionGen): palette = QtGui.QPalette() brush = QtGui.QBrush(QtGui.QColor(85, 255, 255)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.WindowText, brush) brush = QtGui.QBrush(QtGui.QColor(0, 239, 239)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.Button, brush) brush = QtGui.QBrush(QtGui.QColor(63, 63, 63)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.Light, brush) brush = QtGui.QBrush(QtGui.QColor(47, 47, 47)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.Midlight, brush) brush = QtGui.QBrush(QtGui.QColor(54, 54, 54)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.Base, brush) brush = QtGui.QBrush(QtGui.QColor(45, 45, 45)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.Window, brush) brush = QtGui.QBrush(QtGui.QColor(57, 57, 57)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.AlternateBase, brush) brush = QtGui.QBrush(QtGui.QColor(85, 255, 255)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.WindowText, brush) brush = QtGui.QBrush(QtGui.QColor(0, 239, 239)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.Button, brush) brush = QtGui.QBrush(QtGui.QColor(63, 63, 63)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.Light, brush) brush = QtGui.QBrush(QtGui.QColor(47, 47, 47)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.Midlight, brush) brush = QtGui.QBrush(QtGui.QColor(54, 54, 54)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.Base, brush) brush = QtGui.QBrush(QtGui.QColor(45, 45, 45)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.Window, brush) brush = QtGui.QBrush(QtGui.QColor(57, 57, 57)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.AlternateBase, brush) brush = QtGui.QBrush(QtGui.QColor(120, 120, 120)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.WindowText, brush) brush = QtGui.QBrush(QtGui.QColor(0, 239, 239)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.Button, brush) brush = QtGui.QBrush(QtGui.QColor(63, 63, 63)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.Light, brush) brush = QtGui.QBrush(QtGui.QColor(47, 47, 47)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.Midlight, brush) brush = QtGui.QBrush(QtGui.QColor(45, 45, 45)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.Base, brush) brush = QtGui.QBrush(QtGui.QColor(45, 45, 45)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.Window, brush) brush = QtGui.QBrush(QtGui.QColor(57, 57, 57)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.AlternateBase, brush) DBConnectionGen.setObjectName("DBConnectionGen") DBConnectionGen.resize(497, 600) self.centralwidget = QtWidgets.QWidget(DBConnectionGen) self.centralwidget.setObjectName("centralwidget") self.label = QtWidgets.QLabel(self.centralwidget) self.label.setEnabled(True) self.label.setGeometry(QtCore.QRect(10, 10, 471, 31)) font = QtGui.QFont() font.setFamily("Aero") font.setPointSize(22) font.setItalic(True) self.label.setFont(font) self.label.setObjectName("label") self.preview_text = QtWidgets.QTextBrowser(self.centralwidget) self.preview_text.setGeometry(QtCore.QRect(15, 350, 471, 221)) font = QtGui.QFont() font.setPointSize(8) self.preview_text.setFont(font) self.preview_text.setObjectName("preview_text") self.layoutWidget = QtWidgets.QWidget(self.centralwidget) self.layoutWidget.setGeometry(QtCore.QRect(90, 69, 321, 251)) self.layoutWidget.setObjectName("layoutWidget") self.gridLayout = QtWidgets.QGridLayout(self.layoutWidget) self.gridLayout.setContentsMargins(0, 0, 0, 0) self.gridLayout.setHorizontalSpacing(32) self.gridLayout.setVerticalSpacing(10) self.gridLayout.setObjectName("gridLayout") self.extention = QtWidgets.QComboBox(self.layoutWidget) font = QtGui.QFont() font.setPointSize(16) self.extention.setFont(font) self.extention.setObjectName("extention") self.extention.addItem("") self.extention.addItem("") self.gridLayout.addWidget(self.extention, 0, 1, 1, 1) self.server = QtWidgets.QLineEdit(self.layoutWidget) font = QtGui.QFont() font.setPointSize(16) self.server.setFont(font) self.server.setObjectName("server") self.gridLayout.addWidget(self.server, 1, 1, 1, 1) self.label_3 = QtWidgets.QLabel(self.layoutWidget) font = QtGui.QFont() font.setFamily("Bebas") font.setPointSize(16) self.label_3.setFont(font) self.label_3.setObjectName("label_3") self.gridLayout.addWidget(self.label_3, 2, 0, 1, 1) self.password = QtWidgets.QLineEdit(self.layoutWidget) font = QtGui.QFont() font.setPointSize(16) self.password.setFont(font) self.password.setObjectName("password") self.gridLayout.addWidget(self.password, 3, 1, 1, 1) self.database = QtWidgets.QLineEdit(self.layoutWidget) font = QtGui.QFont() font.setPointSize(16) self.database.setFont(font) self.database.setObjectName("database") self.gridLayout.addWidget(self.database, 4, 1, 1, 1) self.label_6 = QtWidgets.QLabel(self.layoutWidget) font = QtGui.QFont() font.setFamily("Bebas") font.setPointSize(16) self.label_6.setFont(font) self.label_6.setObjectName("label_6") self.gridLayout.addWidget(self.label_6, 4, 0, 1, 1) self.label_2 = QtWidgets.QLabel(self.layoutWidget) font = QtGui.QFont() font.setFamily("Bebas") font.setPointSize(16) self.label_2.setFont(font) self.label_2.setObjectName("label_2") self.gridLayout.addWidget(self.label_2, 1, 0, 1, 1) self.generate = QtWidgets.QPushButton(self.layoutWidget) self.generate.setFlat(False) self.generate.setObjectName("generate") self.gridLayout.addWidget(self.generate, 5, 0, 1, 1) self.generate.clicked.connect(self.dbGenUi) self.label_5 = QtWidgets.QLabel(self.layoutWidget) font = QtGui.QFont() font.setFamily("Bebas") font.setPointSize(16) self.label_5.setFont(font) self.label_5.setObjectName("label_5") self.gridLayout.addWidget(self.label_5, 0, 0, 1, 1) self.username = QtWidgets.QLineEdit(self.layoutWidget) font = QtGui.QFont() font.setPointSize(16) self.username.setFont(font) self.username.setObjectName("username") self.gridLayout.addWidget(self.username, 2, 1, 1, 1) self.preview = QtWidgets.QPushButton(self.layoutWidget) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Preferred) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth( self.preview.sizePolicy().hasHeightForWidth()) self.preview.setSizePolicy(sizePolicy) self.preview.setObjectName("preview") self.gridLayout.addWidget(self.preview, 5, 1, 1, 1) self.preview.clicked.connect(self.dbConPreview) self.label_4 = QtWidgets.QLabel(self.layoutWidget) font = QtGui.QFont() font.setFamily("Bebas") font.setPointSize(16) self.label_4.setFont(font) self.label_4.setObjectName("label_4") self.gridLayout.addWidget(self.label_4, 3, 0, 1, 1) DBConnectionGen.setCentralWidget(self.centralwidget) self.statusbar = QtWidgets.QStatusBar(DBConnectionGen) self.statusbar.setAutoFillBackground(False) self.statusbar.setSizeGripEnabled(False) self.statusbar.setObjectName("statusbar") DBConnectionGen.setStatusBar(self.statusbar) DBConnectionGen.setPalette(palette) self.retranslateUi(DBConnectionGen) QtCore.QMetaObject.connectSlotsByName(DBConnectionGen) def retranslateUi(self, DBConnectionGen): _translate = QtCore.QCoreApplication.translate DBConnectionGen.setWindowTitle( _translate("DBConnectionGen", "MainWindow")) self.label.setText( _translate("DBConnectionGen", "Database Connection Generator")) self.preview_text.setHtml( _translate( "DBConnectionGen", "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0//EN\" \"http://www.w3.org/TR/REC-html40/strict.dtd\">\n" "<html><head><meta name=\"qrichtext\" content=\"1\" /><style type=\"text/css\">\n" "p, li { white-space: pre-wrap; }\n" "</style></head><body style=\" font-family:\'MS Shell Dlg 2\'; font-size:8pt; font-weight:400; font-style:normal;\">\n" "<p style=\"-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><br /></p></body></html>" )) self.extention.setItemText(0, _translate("DBConnectionGen", "js")) self.extention.setItemText(1, _translate("DBConnectionGen", "php")) self.label_3.setText(_translate("DBConnectionGen", "Username")) self.label_6.setText(_translate("DBConnectionGen", "Database")) self.label_2.setText(_translate("DBConnectionGen", "Server")) self.generate.setText(_translate("DBConnectionGen", "Generate")) self.label_5.setText(_translate("DBConnectionGen", "Extention")) self.preview.setText(_translate("DBConnectionGen", "Preview")) self.label_4.setText(_translate("DBConnectionGen", "Password")) def dbConPreview(self): self.openAbout() format = self.extention.currentText() self.preview_text.setText(d.uiPrev(format)) def dbGenUi(self): format = self.extention.currentText() dbServer = self.server.text() dbName = self.database.text() dbUser = self.username.text() dbPswd = self.password.text() if d.validate(format, dbServer, dbName, dbPswd, dbName) == True: self.preview_text.setText( d.gen(format, dbServer, dbName, dbPswd, dbName)) else: msg = QtWidgets.QMessageBox() msg.setWindowTitle("Error!") msg.setText("Fields cannot be empty") x = msg.exec_() # this will show our messagebox
def __init__(self): super().__init__() self.ui = AboutUI() self.ui.setupUi(self)
def __init_(self): super(AboutD, self).__init__() self.dialog = Ui_Dialog() self.dialog.setupUi(self)
class AboutDialog(QtWidgets.QDialog): def __init__(self): super(AboutDialog, self).__init__() self.ui = Ui_Dialog() self.ui.setupUi(self) self.setWindowTitle("关于")
def __init__(self): super(AboutDialog, self).__init__() self.ui = Ui_Dialog() self.ui.setupUi(self) self.setWindowTitle("关于")
class aboutDialog(QtGui.QDialog): def __init__(self): QtGui.QDialog.__init__(self) self.ui = Ui_Dialog() self.ui.setupUi(self)