示例#1
0
 def _createWidgets(self, layout):
     """
     """
     widgetStart = self._dataTypeHandler.getInputWidget(self)
     widgetEnd = self._dataTypeHandler.getInputWidget(self)
     toLabel = QtGui.QLabel("to", self)
     toLabel.setSizePolicy(QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed)
     layout.addWidget(widgetStart)
     layout.addWidget(toLabel)
     layout.addWidget(widgetEnd)
     return [widgetStart, widgetEnd]
示例#2
0
文件: delegate.py 项目: mhamid3d/jinx
    def startImageCycling(self, index):
        """
        Start frame cycling on a cell at <index>

        :parameters:
            index : QtCore.QModelIndex
                the model index to start frame cycling on
        """
        if self.__imageCyclingEnabled and index.isValid(
        ) and index != self.__cycleIndex:
            # stop cycling on old index
            self.stopImageCycling()
            newRect = self._thumbnailRect(index)
            if newRect.isValid():
                filename = str(index.data())
                if not common.imageFormatIsAnimatable(
                        filename) or not os.path.isfile(filename):
                    return
                scaledImage = index.data(role=self.ROLE_SCALED_IMAGE)
                # On OSX 10.9 PyQt 4.10 replaces null QImages with QPyNullVariants when retreiving them from a model
                if scaledImage is None or not isinstance(
                        scaledImage, QtGui.QImage) or scaledImage.isNull():
                    return
                # make the index widget ( QLabel displaying a QMovie )
                movieLabel = QtGui.QLabel()
                movie = QtGui.QMovie(filename, parent=movieLabel)
                movie.setCacheMode(QtGui.QMovie.CacheAll)
                # QMovie bug?, jumpToNextFrame() will only return False for static images after it has been called more than once
                movie.jumpToNextFrame()
                # if there is no frame 1, then it is a static image, so abort.
                # this must be done after it has been set and started playing
                # or the QMovie has no frame attributes
                if movie.jumpToNextFrame() is False:
                    self.stopImageCycling()
                    return
                # movieLabel.setFrameStyle( QtGui.QFrame.Box )
                movieLabel.setSizePolicy(QtGui.QSizePolicy.Fixed,
                                         QtGui.QSizePolicy.Fixed)
                newSize = scaledImage.size()
                movie.setScaledSize(newSize)
                movieLabel.setFixedSize(newSize)
                movieLabel.setMovie(movie)
                # start playing
                movie.start()
                self.__cycleIndex = QtCore.QPersistentModelIndex(index)
                # set the new index widget
                self._view.setIndexWidget(index, movieLabel)
                # move to center of cell
                movieLabel.move(
                    movieLabel.pos().x() + ((newRect.width() / 2) -
                                            (newSize.width() / 2)),
                    movieLabel.pos().y())
示例#3
0
        def __init__(self, parent=None):
            super(ResolutionHandler.ResolutionInputWidget,
                  self).__init__(parent)

            intValidator = QtGui.QIntValidator(self)
            intValidator.setBottom(0)

            self.width = QtGui.QLineEdit(self)
            self.width.setFrame(False)
            self.width.setValidator(intValidator)
            self.height = QtGui.QLineEdit(self)
            self.height.setValidator(intValidator)
            self.height.setFrame(False)

            layout = QtGui.QHBoxLayout()
            layout.setContentsMargins(0, 0, 0, 0)
            layout.setSpacing(0)
            layout.addWidget(self.width)
            layout.addWidget(QtGui.QLabel("x", self))
            layout.addWidget(self.height)
            self.setLayout(layout)
示例#4
0
 def getInputWidget(cls, parentWidget):
     widget = QtGui.QLabel(parentWidget)
     return widget