def __init__(self): self.getTrainingData() self.imageWidth = 480 self.imageHeight = 360 self.numRetrieval = 9 QMainWindow.__init__(self) self.setMinimumSize(QSize(self.imageWidth + 60, int(self.imageHeight * 1.9))) self.setWindowTitle("ShapeRetrievalEngine") centralWidget = QWidget(self) self.queryImageFileName = None imageWidget=QWidget(centralWidget) imageWidget.setGeometry(30,30,self.imageWidth ,self.imageHeight) #imageWidget.setAutoFillBackground(True) imageWidget.setStyleSheet("background-color:rgb(0,0,0)") self.queryImageLabel = QLabel() imageWidgetLayout = QVBoxLayout(imageWidget) self.queryImageLabel.setAlignment(Qt.AlignCenter) self.queryImageLabel.setText("<font color='white'>Query Image</font>") imageWidgetLayout.addWidget(self.queryImageLabel) browseButton=QPushButton(centralWidget) browseButton.setGeometry(30, self.imageHeight + 40, 60, 30) browseButton.setText("Browse") browseButton.clicked.connect(self.getfile) searchButton=QPushButton(centralWidget) searchButton.setGeometry(90, self.imageHeight + 40, 60, 30) searchButton.setText("Search") searchButton.clicked.connect(self.getResultSet) scrollAreaImageWidgetContents = QWidget(centralWidget) scrollAreaImageWidgetContents.setGeometry(20, self.imageHeight + 90, self.imageWidth + 10, int(self.imageHeight * 0.25) + 90) scrollAreaImageWidget = QtWidgets.QGroupBox('Retrieval Results') reslayout = QtWidgets.QHBoxLayout() self.resultImageLabelList = [] x = 10 y = 10 for i in range(self.numRetrieval): resSingleLayout = QtWidgets.QVBoxLayout() resultWidget = QWidget() resultWidget.setGeometry(x, y, int(self.imageWidth * 0.25), int(self.imageHeight * 0.25)) resultWidget.setFixedSize(QSize(int(self.imageWidth * 0.25), int(self.imageHeight * 0.25))) resultWidget.setStyleSheet("background-color:rgb(0,0,0)") imageLabel = QLabel() imageLabelLayout = QVBoxLayout(resultWidget) imageLabel.setAlignment(Qt.AlignCenter) imageLabel.setText("<font color='white'>None</font>") imageLabelLayout.addWidget(imageLabel) x = x + int(self.imageWidth * 0.25) + 10 resSingleLayout.addWidget(resultWidget) resLabel = QLabel() resLabel.setAlignment(Qt.AlignCenter) resLabel.setText("Image_"+str(i+1)) resSingleLayout.addWidget(resLabel) reslayout.addItem(resSingleLayout) self.resultImageLabelList.append(imageLabel) scrollAreaImageWidget.setLayout(reslayout) scrollAreaImage=QScrollArea() scrollAreaImage.setWidget(scrollAreaImageWidget) scrollAreaImage.setWidgetResizable(False) scrollAreaImage.setFixedHeight(int(self.imageHeight * 0.25) + 80) scrollAreaImage.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOn) layout = QVBoxLayout(scrollAreaImageWidgetContents) layout.addWidget(scrollAreaImage) self.setCentralWidget(centralWidget)