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 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