def setup_category_view(self): self.current_view = StepViews.CATEGORY_VIEW i, j = 0, 0 for category in self.categories: data = urllib.request.urlopen(category["icons"][0]["url"]).read() label = ClickableLabel(self) label.setScaledContents(True) label.setFixedSize(190, 190) label.dataId = category["id"] label.clicked.connect(self.category_click) image = QImage(32, 32, QImage.Format_RGB32) image.loadFromData(data) painter = QPainter(image) painter.setPen(QPen(QColor("white"))) painter.setFont(QFont("Roboto", 22, QFont.Bold)) painter.drawText(QRect(0, 0, image.width(), image.height() - 25), Qt.AlignCenter | Qt.AlignBottom, category["name"]) painter.end() pixmap = QPixmap(image) label.setPixmap(pixmap) self.layout.addWidget(label, i, j) j += 1 if j % 4 == 0: i += 1 j = 0
def addDocumentLayout(self, doc): docLayout = self.ui.layout_documents layout = QtGui.QVBoxLayout() label = ClickableLabel() #ba = query.value(0).toByteArray() ba = doc['byteArray'] pic = QtGui.QPixmap() pic.loadFromData(ba) #Show the image into a QLabel object label.setPixmap(self.scalePixmap(pic)) self.connect(label, QtCore.SIGNAL('clicked()'), lambda ba=ba: self.showImage(ba)) delBtn = QtGui.QPushButton(u'löschen') self.connect(delBtn, QtCore.SIGNAL('clicked()'), lambda doc=doc, l=layout: self.removeDocument(doc, layout)) layout.addWidget(label) layout.addWidget(delBtn) docLayout.addLayout(layout)
def setup_category_playlists_view(self): self.current_view = StepViews.CATEGORY_PLAYLISTS_VIEW i, j = 0, 0 for playlist in self.categoryPlaylists: data = urllib.request.urlopen(playlist["images"][0]["url"]).read() label = ClickableLabel(self) label.setScaledContents(True) label.setFixedSize(190, 190) image = QImage(32, 32, QImage.Format_RGB32) image.loadFromData(data) pixmap = QPixmap(image) label.setPixmap(pixmap) self.layout.addWidget(label, i, j) j += 1 if j % 4 == 0: i += 1 j = 0