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)
Esempio n. 3
0
class ImageViewer(QDialog):
    """
    ImageViewer displays the POV-Ray image <image_filename> after it has been rendered.
    """

    def __init__(self, image_filename, parent=None, name=None, modal=0, fl=0):
        # QDialog.__init__(self,parent,name,modal,fl)
        QDialog.__init__(self, parent)

        self.image = QPixmap(image_filename)
        width = self.image.width()
        height = self.image.height()
        caption = image_filename + " (" + str(width) + " x " + str(height) + ")"
        self.setWindowTitle(caption)

        if name is None:
            name = "ImageViewer"
        self.setObjectName(name)

        self.pixmapLabel = QLabel(self)
        self.pixmapLabel.setGeometry(QRect(0, 0, width, height))
        self.pixmapLabel.setPixmap(self.image)
        self.pixmapLabel.setScaledContents(1)

        self.resize(QSize(width, height).expandedTo(self.minimumSizeHint()))

    def display(self):
        """
        Display the image in the ImageViewer, making sure it isn't larger than the desktop size.
        """
        if (
            QApplication.desktop().width() > self.image.width() + 10
            and QApplication.desktop().height() > self.image.height() + 30
        ):
            self.show()
        else:
            self.showMaximized()
            # No scrollbars provided with showMaximized. The image is clipped if it is larger than the screen.
            # Probably need to use a QScrollView for large images. Mark 060701.
        return

    pass
Esempio n. 4
0
class ImageViewer(QDialog):
    """
    ImageViewer displays the POV-Ray image <image_filename> after it has been rendered.
    """
    def __init__(self, image_filename, parent=None, name=None, modal=0, fl=0):
        #QDialog.__init__(self,parent,name,modal,fl)
        QDialog.__init__(self, parent)

        self.image = QPixmap(image_filename)
        width = self.image.width()
        height = self.image.height()
        caption = image_filename + " (" + str(width) + " x " + str(
            height) + ")"
        self.setWindowTitle(caption)

        if name is None:
            name = "ImageViewer"
        self.setObjectName(name)

        self.pixmapLabel = QLabel(self)
        self.pixmapLabel.setGeometry(QRect(0, 0, width, height))
        self.pixmapLabel.setPixmap(self.image)
        self.pixmapLabel.setScaledContents(1)

        self.resize(QSize(width, height).expandedTo(self.minimumSizeHint()))

    def display(self):
        """
        Display the image in the ImageViewer, making sure it isn't larger than the desktop size.
        """
        if QApplication.desktop().width() > self.image.width() + 10 and \
           QApplication.desktop().height() > self.image.height() + 30:
            self.show()
        else:
            self.showMaximized()
            # No scrollbars provided with showMaximized. The image is clipped if it is larger than the screen.
            # Probably need to use a QScrollView for large images. Mark 060701.
        return

    pass
Esempio n. 5
0
 def fset(self, cdata):
     self._cdata = None
     pm = QPixmap()
     if cdata:
         pm.loadFromData(cdata)
     if pm.isNull():
         pm = QPixmap(I('default_cover.png'))
     else:
         self._cdata = cdata
     self.setPixmap(pm)
     tt = _('This book has no cover')
     if self._cdata:
         tt = _('Cover size: %(width)d x %(height)d pixels') % \
         dict(width=pm.width(), height=pm.height())
     self.setToolTip(tt)
Esempio n. 6
0
 def fset(self, cdata):
     self._cdata = None
     pm = QPixmap()
     if cdata:
         pm.loadFromData(cdata)
     if pm.isNull():
         pm = QPixmap(I('default_cover.png'))
     else:
         self._cdata = cdata
     self.setPixmap(pm)
     tt = _('This book has no cover')
     if self._cdata:
         tt = _('Cover size: %(width)d x %(height)d pixels') % \
         dict(width=pm.width(), height=pm.height())
     self.setToolTip(tt)