def _addToTab(self, submission, submissionURL, lst): """ Add a submission and its representative image to the lst under its tab. :type submission: praw.objects.Submission :type submissionURL: str :type lst: QListWidget """ imagePath = submission.representativeImage if imagePath is not None and imagePath.exists(): item = QListWidgetItem(submissionURL, lst) item.setTextColor(Qt.transparent) labelWidget = QLabel() labelWidget.setOpenExternalLinks(True) labelWidget.setTextFormat(Qt.RichText) size = QSize(128, 158) item.setSizeHint(size) size = QSize(128, 128) if imagePath.suffix == ".webm": imagePath = pathlib.Path("RedditDataExtractor", "images", "videoImage.png").resolve() pixmap = QPixmap(str(imagePath)) pixmap = pixmap.scaled(size, Qt.KeepAspectRatio) height = pixmap.height() width = pixmap.width() submissionTitle = submissionURL[submissionURL[0:-1].rfind("/") + 1:-1] labelWidget.setText( '<a href="' + submissionURL + '"><img src="' + str(imagePath) + '" height="' + str( height) + '" width="' + str(width) + '"><p>' + submissionTitle) lst.setItemWidget(item, labelWidget)
def _addToTab(self, submission, submissionURL, lst): """ Add a submission and its representative image to the lst under its tab. :type submission: praw.objects.Submission :type submissionURL: str :type lst: QListWidget """ imagePath = submission.representativeImage if imagePath is not None and imagePath.exists(): item = QListWidgetItem(submissionURL, lst) item.setTextColor(Qt.transparent) labelWidget = QLabel() labelWidget.setOpenExternalLinks(True) labelWidget.setTextFormat(Qt.RichText) size = QSize(128, 158) item.setSizeHint(size) size = QSize(128, 128) if imagePath.suffix == ".webm": imagePath = pathlib.Path("RedditDataExtractor", "images", "videoImage.png").resolve() pixmap = QPixmap(str(imagePath)) pixmap = pixmap.scaled(size, Qt.KeepAspectRatio) height = pixmap.height() width = pixmap.width() submissionTitle = submissionURL[submissionURL[0:-1].rfind("/") + 1:-1] labelWidget.setText('<a href="' + submissionURL + '"><img src="' + str(imagePath) + '" height="' + str(height) + '" width="' + str(width) + '"><p>' + submissionTitle) lst.setItemWidget(item, labelWidget)
def addItem(self, collection): item = QListWidgetItem(self.collectionList) item.setSizeHint(QSize(36, CLOSED_SIZE)) self.collectionList.addItem(item) self.collectionList.setItemWidget(item, CollectionItem(self, collection, item))
def addItem(self, collection): item = QListWidgetItem(self.collectionList) item.setSizeHint(QSize(36, CLOSED_SIZE)) self.collectionList.addItem(item) self.collectionList.setItemWidget( item, CollectionItem(self, collection, item))