本文整理汇总了Python中PyQt5.QtGui.QMovie.setCacheMode方法的典型用法代码示例。如果您正苦于以下问题:Python QMovie.setCacheMode方法的具体用法?Python QMovie.setCacheMode怎么用?Python QMovie.setCacheMode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt5.QtGui.QMovie
的用法示例。
在下文中一共展示了QMovie.setCacheMode方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: SystemTrayIcon
# 需要导入模块: from PyQt5.QtGui import QMovie [as 别名]
# 或者: from PyQt5.QtGui.QMovie import setCacheMode [as 别名]
class SystemTrayIcon(QSystemTrayIcon):
def __init__(self, parent):
super(SystemTrayIcon, self).__init__()
self.parent = parent
self.new_folder_window = NewFolderWindow(parent)
self.preferences_window = PreferencesWindow()
self.setIcon(QIcon(":gridsync.png"))
self.right_menu = RightClickMenu(self)
self.setContextMenu(self.right_menu)
self.activated.connect(self.on_click)
self.animation = QMovie()
self.animation.setFileName(":sync.gif")
self.animation.updated.connect(self.update_animation_frame)
self.animation.setCacheMode(True)
def update_animation_frame(self):
self.setIcon(QIcon(self.animation.currentPixmap()))
def set_icon(self, resource):
self.setIcon(QIcon(resource))
def on_click(self, value):
#self.right_menu.populate()
if value == QSystemTrayIcon.Trigger:
open_gridsync_folder()
def on_quit(self):
reactor.stop()
示例2: open
# 需要导入模块: from PyQt5.QtGui import QMovie [as 别名]
# 或者: from PyQt5.QtGui.QMovie import setCacheMode [as 别名]
def open(self):
self.file = QFileDialog.getOpenFileName(self, "Open File", self.pwd)[0]
if self.file == "":
return
self.information = info.Information(self, self.file)
movie = QMovie(self.file, QByteArray(), self)
movie.setCacheMode(QMovie.CacheAll)
movie.setSpeed(100)
self.label.setMovie(movie)
movie.start()
示例3: MoviePlayer
# 需要导入模块: from PyQt5.QtGui import QMovie [as 别名]
# 或者: from PyQt5.QtGui.QMovie import setCacheMode [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("%")
#.........这里部分代码省略.........
示例4: alarmChecker
# 需要导入模块: from PyQt5.QtGui import QMovie [as 别名]
# 或者: from PyQt5.QtGui.QMovie import setCacheMode [as 别名]
class alarmChecker(QWidget):
def __init__(self, parent):
super(alarmChecker, self).__init__()
self.parent = parent
self.networkError = False
self.loadAlarm()
self.getAlarm()
self.getTimeout()
self.getTimer()
self.setLayout(self.alarm_layout)
def loadAlarm(self):
self.list_alarm = []
config = ConfigParser.ConfigParser()
config.readfp(open(self.parent.config_path + 'alarm.cfg'))
for a in config.sections():
dict = {"tableName": a}
for b in config.options(a):
dict[b] = config.get(a, b)
self.list_alarm.append(dict)
def getAlarm(self):
self.alarm_layout = QGridLayout()
self.movie = QMovie(self.parent.os_path + "/img/giphy2.gif", QByteArray(), self)
self.movie_screen = QLabel()
# Make label fit the gif
self.movie_screen.setFixedSize(80, 50)
# Add the QMovie object to the label
self.movie.setCacheMode(QMovie.CacheAll)
self.movie.setSpeed(100)
self.movie_screen.setMovie(self.movie)
self.movie.start()
self.timeout_ack = []
self.dialog = self.dialogTimeout()
self.dialog.hide()
self.label_acq = QPushButton("ACQUISITION")
self.label_acq.clicked.connect(self.dialog.show)
self.label_acq.setFixedHeight(50)
self.setColor("QPushButton", self.label_acq, "green")
self.alarm_layout.addWidget(self.movie_screen, 0, 0, 1, 1)
self.alarm_layout.addWidget(self.label_acq, 0, 1, 1, 2)
for i, device in enumerate(self.list_alarm):
name = device["tableName"] + device["key"]
button = QPushButton(device["label"].upper())
button.setFixedHeight(50)
self.setColor("QPushButton", button, "green")
button.clicked.connect(partial(self.showWarning, "msg_%s" % name))
self.alarm_layout.addWidget(button, 0, i + 3, 1, 1)
setattr(self, "alarm_%s" % name, button)
self.watcher_alarm = QTimer(self)
self.watcher_alarm.setInterval(5000)
self.watcher_alarm.timeout.connect(self.checkCriticalValue)
self.watcher_alarm.start()
def getTimeout(self):
self.device_dict = copy.deepcopy(self.parent.device_dict)
self.timeout_limit = 90
self.list_timeout = [key for key, value in self.parent.device_dict.iteritems()]
self.last_date = {}
self.last_time = {}
for key, value in self.device_dict.iteritems():
self.last_date[key] = 0
self.last_time[key] = datetime.datetime.now()
def getTimer(self):
watcher_timeout = QTimer(self)
watcher_timeout.singleShot(2000, partial(self.showTimeout, 0))
self.checker_timeout = QTimer(self)
self.checker_timeout.setInterval(15000)
self.checker_timeout.timeout.connect(self.checkTimeout)
self.checker_timeout.start()
def showTimeout(self, i):
for timeout in self.timeout_ack:
try:
self.list_timeout.remove(timeout)
except ValueError:
pass
if not self.networkError:
if self.list_timeout:
if i < len(self.list_timeout):
self.label_acq.setText("TIME OUT ON %s" % self.list_timeout[i])
self.setColor("QPushButton", self.label_acq, "red")
i += 1
else:
i = 0
else:
self.label_acq.setText("ACQUISITION")
self.setColor("QPushButton", self.label_acq, "green")
else:
self.label_acq.setText("SERVER LOST")
#.........这里部分代码省略.........