本文整理汇总了Python中PyQt5.QtGui.QMovie.state方法的典型用法代码示例。如果您正苦于以下问题:Python QMovie.state方法的具体用法?Python QMovie.state怎么用?Python QMovie.state使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt5.QtGui.QMovie
的用法示例。
在下文中一共展示了QMovie.state方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: IconManagement
# 需要导入模块: from PyQt5.QtGui import QMovie [as 别名]
# 或者: from PyQt5.QtGui.QMovie import state [as 别名]
class IconManagement(object):
def __init__(self, tray, interval = 100):
self.tray = tray
self.movie = QMovie(":/images/tray_animations/tray.gif")
self.movie.setSpeed(interval)
self.movie.frameChanged.connect(self.next_icon)
self.icons = Enum(
ok = QIcon(":/images/demerio.png"),
problem = QIcon(":/images/demerio-problem.png"),
conductor_problem = QIcon(":/images/demerio-conductor-problem.png")
)
self.icon = self.icons.ok
self.update_icon()
def internet_is_ok(self, internet_is_ok):
self.icon = self.icons.ok if internet_is_ok else self.icons.problem
self.update_icon()
@pyqtSlot(int)
def next_icon(self, i):
self.tray.setIcon(QIcon(self.movie.currentPixmap()))
def start(self):
self.movie.start()
def stop(self):
self.update_icon()
self.movie.stop()
def update_icon(self):
self.tray.setIcon(self.icon)
def conductor_problem(self):
if self.movie.state() == QMovie.Running:
self.movie.stop()
self.icon = self.icons.conductor_problem
self.update_icon()
示例2: MoviePlayer
# 需要导入模块: from PyQt5.QtGui import QMovie [as 别名]
# 或者: from PyQt5.QtGui.QMovie import state [as 别名]
class MoviePlayer(QWidget):
def __init__(self, parent=None):
super(MoviePlayer, self).__init__(parent)
self.movie = QMovie(self)
self.movie.setCacheMode(QMovie.CacheAll)
self.movieLabel = QLabel("No movie loaded")
self.movieLabel.setAlignment(Qt.AlignCenter)
self.movieLabel.setSizePolicy(QSizePolicy.Ignored, QSizePolicy.Ignored)
self.movieLabel.setBackgroundRole(QPalette.Dark)
self.movieLabel.setAutoFillBackground(True)
self.currentMovieDirectory = ''
self.createControls()
self.createButtons()
self.movie.frameChanged.connect(self.updateFrameSlider)
self.movie.stateChanged.connect(self.updateButtons)
self.fitCheckBox.clicked.connect(self.fitToWindow)
self.frameSlider.valueChanged.connect(self.goToFrame)
self.speedSpinBox.valueChanged.connect(self.movie.setSpeed)
mainLayout = QVBoxLayout()
mainLayout.addWidget(self.movieLabel)
mainLayout.addLayout(self.controlsLayout)
mainLayout.addLayout(self.buttonsLayout)
self.setLayout(mainLayout)
self.updateFrameSlider()
self.updateButtons()
self.setWindowTitle("Movie Player")
self.resize(400, 400)
def open(self):
fileName, _ = QFileDialog.getOpenFileName(self, "Open a Movie",
self.currentMovieDirectory)
if fileName:
self.openFile(fileName)
def openFile(self, fileName):
self.currentMovieDirectory = QFileInfo(fileName).path()
self.movie.stop()
self.movieLabel.setMovie(self.movie)
self.movie.setFileName(fileName)
self.movie.start()
self.updateFrameSlider();
self.updateButtons();
def goToFrame(self, frame):
self.movie.jumpToFrame(frame)
def fitToWindow(self):
self.movieLabel.setScaledContents(self.fitCheckBox.isChecked())
def updateFrameSlider(self):
hasFrames = (self.movie.currentFrameNumber() >= 0)
if hasFrames:
if self.movie.frameCount() > 0:
self.frameSlider.setMaximum(self.movie.frameCount() - 1)
elif self.movie.currentFrameNumber() > self.frameSlider.maximum():
self.frameSlider.setMaximum(self.movie.currentFrameNumber())
self.frameSlider.setValue(self.movie.currentFrameNumber())
else:
self.frameSlider.setMaximum(0)
self.frameLabel.setEnabled(hasFrames)
self.frameSlider.setEnabled(hasFrames)
def updateButtons(self):
state = self.movie.state()
self.playButton.setEnabled(self.movie.isValid() and
self.movie.frameCount() != 1 and state == QMovie.NotRunning)
self.pauseButton.setEnabled(state != QMovie.NotRunning)
self.pauseButton.setChecked(state == QMovie.Paused)
self.stopButton.setEnabled(state != QMovie.NotRunning)
def createControls(self):
self.fitCheckBox = QCheckBox("Fit to Window")
self.frameLabel = QLabel("Current frame:")
self.frameSlider = QSlider(Qt.Horizontal)
self.frameSlider.setTickPosition(QSlider.TicksBelow)
self.frameSlider.setTickInterval(10)
speedLabel = QLabel("Speed:")
self.speedSpinBox = QSpinBox()
self.speedSpinBox.setRange(1, 9999)
self.speedSpinBox.setValue(100)
self.speedSpinBox.setSuffix("%")
#.........这里部分代码省略.........