本文整理汇总了Python中PyQt5.QtGui.QMovie.stop方法的典型用法代码示例。如果您正苦于以下问题:Python QMovie.stop方法的具体用法?Python QMovie.stop怎么用?Python QMovie.stop使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt5.QtGui.QMovie
的用法示例。
在下文中一共展示了QMovie.stop方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: GifWidget
# 需要导入模块: from PyQt5.QtGui import QMovie [as 别名]
# 或者: from PyQt5.QtGui.QMovie import stop [as 别名]
class GifWidget(QLabel):
def __init__(self, parent = None, path = None):
super(GifWidget, self).__init__(parent)
self.setPath(path)
def __del__(self):
print("GifWidget __del__")
if hasattr(self, "_movie"):
self._movie.stop()
del self._movie
def setPath(self, path):
if hasattr(self, "_movie"):
self._movie.stop()
del self._movie
if not path:
return
self._movie = QMovie(path)
self.setMovie(self._movie)
self._movie.start()
def start(self):
if hasattr(self, "_movie"):
self._movie.start()
def stop(self):
if hasattr(self, "_movie"):
self._movie.stop()
示例2: IconManagement
# 需要导入模块: from PyQt5.QtGui import QMovie [as 别名]
# 或者: from PyQt5.QtGui.QMovie import stop [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()
示例3: LoginWidget
# 需要导入模块: from PyQt5.QtGui import QMovie [as 别名]
# 或者: from PyQt5.QtGui.QMovie import stop [as 别名]
class LoginWidget(QWidget):
# signals
loginOk = pyqtSignal(str, dict) # (login(email), cookies{})
loginError = pyqtSignal(str)
def __init__(self, parent=None):
super(LoginWidget, self).__init__(parent)
self.uifile = 'ui/login_widget.ui'
self.pickle_filename = 'cache/login.dat'
self.xnova_url = 'uni4.xnova.su'
self.ui = None
self.loading_gif = None
# thread for network operations
self.th = None
def load_ui(self):
self.ui = uic.loadUi(self.uifile, self)
self.ui.lbl_loading.hide()
self.ui.btn_login.clicked.connect(self.on_btn_login)
self.ui.btn_register.clicked.connect(self.on_btn_register)
self.loading_gif = QMovie(':/i/loading.gif')
self.restore_login()
# load xnova url from config/net.ini
cfg = configparser.ConfigParser()
cfg.read('config/net.ini', encoding='utf-8')
if 'net' in cfg:
self.xnova_url = cfg['net']['xnova_url']
def save_login(self):
email = self.ui.le_email.text()
password = self.ui.le_pass.text()
remember = self.ui.chk_remember.isChecked()
auth_data = (email, password, remember)
try:
cache_dir = pathlib.Path('./cache')
if not cache_dir.exists():
cache_dir.mkdir()
with open(self.pickle_filename, 'wb') as f:
pickle.dump(auth_data, f)
except pickle.PickleError as pe:
pass
except IOError as ioe:
pass
# except OSError as ose: # same as IOError in python3 ?
# pass
def restore_login(self):
try:
with open(self.pickle_filename, 'rb') as f:
auth_data = pickle.load(f)
self.ui.le_email.setText(auth_data[0])
self.ui.le_pass.setText(auth_data[1])
if auth_data[2]:
self.ui.chk_remember.setChecked(True)
else:
self.ui.chk_remember.setChecked(False)
except pickle.PickleError as pe:
pass
except IOError as ioe:
pass
@pyqtSlot()
def on_btn_register(self):
logger.debug('register clicked, opening [http://{0}/]'.format(self.xnova_url))
QDesktopServices.openUrl(QUrl('http://{0}/'.format(self.xnova_url)))
@pyqtSlot()
def on_btn_login(self):
# logger.debug('login clicked')
self.ui.btn_login.hide()
self.ui.btn_register.hide()
self.ui.le_email.setEnabled(False)
self.ui.le_pass.setEnabled(False)
self.ui.chk_remember.setEnabled(False)
self.ui.lbl_loading.show()
self.ui.lbl_loading.setMovie(self.loading_gif)
self.loading_gif.start()
if self.ui.chk_remember.isChecked():
self.save_login()
# create thread object
self.th = LoginThread(self)
self.th.finished.connect(self.on_thread_finished)
# get form data and start thread
self.th.email = self.ui.le_email.text()
self.th.password = self.ui.le_pass.text()
self.th.remember = self.ui.chk_remember.isChecked()
self.th.start()
@pyqtSlot()
def on_thread_finished(self):
# logger.debug('thread finished')
self.loading_gif.stop()
self.ui.le_email.setEnabled(True)
self.ui.le_pass.setEnabled(True)
self.ui.chk_remember.setEnabled(True)
self.ui.btn_login.show()
self.ui.btn_register.show()
self.ui.lbl_loading.hide()
if self.th.login_ok:
logger.info('Login ({0}) ok'.format(self.th.email))
#.........这里部分代码省略.........
示例4: MainWindow
# 需要导入模块: from PyQt5.QtGui import QMovie [as 别名]
# 或者: from PyQt5.QtGui.QMovie import stop [as 别名]
#.........这里部分代码省略.........
def show_feedback(self):
feed = Feedback(self.com)
feed.exec_()
def about_semard(self):
about = QMessageBox.about(self, "Sobre Semard",
"""<b>Semard</b> v%s
<p><b>Copyright (C) 2013</b> Ronnie Andrew.</p>
<p>Todos os direitos reservados de acordo com a licença GNU GPL v3 ou posterior.</p>
<p><b>Website Oficial:</b> <a href='https://github.com/ROAND/Series-Manager'>GitHub</a></p>
<p><b>Plataforma: </b>%s</p>
""" % (__version__, platform.system()))
def show_semard(self, message):
self.show()
def closeEvent(self, event):
self.hide()
self.tray.showMessage('Semard', 'Semard ainda está em execução.')
event.ignore()
@Slot(str)
def set_image(self, img_str):
self.ui.image_label.setPixmap(QPixmap(img_str))
@Slot(str)
def message(self, message):
if str(message) in 'ended':
self.ui.loading_label.hide()
# self.repaint()
self.ui.anime_list_widget.setEnabled(True)
self.ui.show_button.setEnabled(True)
self.movie.stop()
if str(message) in 'started':
self.ui.loading_label.show()
# self.repaint()
self.ui.anime_list_widget.setEnabled(False)
self.ui.show_button.setEnabled(False)
self.movie.start()
def anime_entered(self, item):
pass
def load_url_items(self):
self.com.sig.emit('started')
self.main_download_page = AnimeList('http://www.anbient.net/lista')
self.number, self.anime_list = self.main_download_page.get_attrs()
self.ui.avaLabel.setText('%s disponiveis.' % self.number)
self.add_full_items_animelist()
self.com.sig.emit('ended')
def episode_change(self):
self.com.sig.emit('started')
self.ui.options_list_widget.clear()
if self.ui.res_list_widget.currentItem():
name = self.ui.res_list_widget.currentItem().text()
episode = self.episode_list[name]
self.ui.options_list_widget.addItems(episode.links)
self.com.sig.emit('ended')
def download(self):
#name = self.ui.options_list_widget.currentItem().text()
link = self.ui.options_list_widget.currentItem().text()
self.com.sig.emit('started')
示例5: SystemTrayIcon
# 需要导入模块: from PyQt5.QtGui import QMovie [as 别名]
# 或者: from PyQt5.QtGui.QMovie import stop [as 别名]
#.........这里部分代码省略.........
tree[3].get('unit'))
self.weatherDataDico['Humidity'] = (tree[2].get('value'),
tree[2].get('unit'))
self.weatherDataDico['Sunrise'] = tree[0][2].get('rise')
self.weatherDataDico['Sunset'] = tree[0][2].get('set')
rain_value = tree[7].get('value')
if rain_value == None:
rain_value = ''
self.weatherDataDico['Precipitation'] = (tree[7].get('mode'), rain_value)
def tooltip_weather(self):
self.systray.setToolTip(self.city_weather_info)
def tray(self):
temp_decimal = eval(self.settings.value('Decimal') or 'False')
try:
if temp_decimal:
temp_tray = self.temp_decimal
else:
temp_tray = self.temp
except:
# First time launch
return
if self.inerror or not hasattr(self, 'temp'):
logging.critical('Cannot paint icon!')
if hasattr(self, 'overviewcity'):
try:
# delete dialog to prevent memory leak
self.overviewcity.close()
except:
pass
return
try:
self.gif_loading.stop()
except:
# In first time run the gif is not animated
pass
logging.debug('Paint tray icon...')
# Place empty.png here to initialize the icon
# don't paint the T° over the old value
icon = QPixmap(':/empty')
self.traycolor = self.settings.value('TrayColor') or ''
self.fontsize = self.settings.value('FontSize') or '18'
self.tray_type = self.settings.value('TrayType') or 'icon&temp'
pt = QPainter()
pt.begin(icon)
if self.tray_type != 'temp':
pt.drawPixmap(0, -12, 64, 64, self.wIcon)
pt.setFont(QFont('sans-sertif', int(self.fontsize)))
pt.setPen(QColor(self.traycolor))
if self.tray_type == 'icon&temp':
pt.drawText(icon.rect(), Qt.AlignBottom | Qt.AlignCenter,
str(temp_tray))
if self.tray_type == 'temp':
pt.drawText(icon.rect(), Qt.AlignCenter, str(temp_tray))
pt.end()
if self.tray_type == 'icon':
self.systray.setIcon(QIcon(self.wIcon))
else:
self.systray.setIcon(QIcon(icon))
try:
if not self.overviewcity.isVisible():
notifier = self.settings.value('Notifications') or 'True'
notifier = eval(notifier)
if notifier:
temp = int(re.search('\d+', self.temp_decimal).group())
示例6: XNCStatusBar
# 需要导入模块: from PyQt5.QtGui import QMovie [as 别名]
# 或者: from PyQt5.QtGui.QMovie import stop [as 别名]
class XNCStatusBar(QStatusBar):
def __init__(self, parent=None):
super(XNCStatusBar, self).__init__(parent)
# state vars
self.world = XNovaWorld_instance()
# initialization
self.setSizeGripEnabled(True)
# sub-widgets
# progressbar
self._progressbar = QProgressBar(self)
self._progressbar.hide()
self._progressbar.setValue(0)
self._progressbar.setRange(0, 99)
# online players counter
self._lbl_online = QLabel(self.tr('Online') + ': 0', self)
# label with loading.gif
self._loading_gif = QMovie(':/i/loading.gif')
self._lbl_loading = QLabel(self)
self._lbl_loading.setMovie(self._loading_gif)
self._lbl_loading.hide()
# testing only
self._btn_runscript = QPushButton('Run script', self)
self._btn_runscript.clicked.connect(self.on_run_script)
self.addPermanentWidget(self._btn_runscript)
#
self.addPermanentWidget(self._lbl_loading)
self.addPermanentWidget(self._lbl_online) # should be las right widget
self.show()
def set_status(self, msg: str, timeout: int=0):
self.showMessage(msg, timeout)
def set_loading_status(self, loading: bool):
if loading:
self._lbl_loading.show()
self._loading_gif.start()
else:
self._loading_gif.stop()
self._lbl_loading.hide()
def set_world_load_progress(self, comment: str, progress: int):
"""
Display world load progress in status bar
:param comment: string comment of what is currently loading
:param progress: percent progress, or -1 to disable
"""
if progress != -1:
if not self._progressbar.isVisible():
self.insertPermanentWidget(0, self._progressbar)
self._progressbar.show()
msg = self.tr('Loading world') + ' ({0}%) {1}...'.format(progress, comment)
logger.debug(msg)
self._progressbar.setValue(progress)
self.set_status(msg)
else:
self.removeWidget(self._progressbar)
self._progressbar.hide()
self._progressbar.reset()
self.clearMessage()
def update_online_players_count(self):
op = self.world.get_online_players()
self._lbl_online.setText(self.tr('Online') + ': {0}'.format(op))
# some functions may be useful, documentation:
# void QStatusBar::clearMessage()
# void QStatusBar::addPermanentWidget(QWidget * widget, int stretch = 0)
# void QStatusBar::addWidget(QWidget * widget, int stretch = 0)
# void QStatusBar::removeWidget(QWidget * widget)
@pyqtSlot()
def on_run_script(self):
files = os.listdir('scripts')
files.sort()
script_files = [fn for fn in files if fn[0] != '.' and fn.endswith('.py')]
# print(script_files)
menu = QMenu(self)
for script_filename in script_files:
act = QAction(menu)
act.setText('Run "scripts/' + script_filename + '"...')
act.setData('scripts/' + script_filename)
menu.addAction(act)
act_ret = menu.exec(QCursor.pos())
if act_ret is None:
return
script_filename = str(act_ret.data())
s = ''
try:
with open(script_filename, 'rt', encoding='utf-8') as f:
s = f.read()
except IOError:
pass
if s != '':
exec(s)
示例7: MoviePlayer
# 需要导入模块: from PyQt5.QtGui import QMovie [as 别名]
# 或者: from PyQt5.QtGui.QMovie import stop [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("%")
#.........这里部分代码省略.........
示例8: FileViewWindow
# 需要导入模块: from PyQt5.QtGui import QMovie [as 别名]
# 或者: from PyQt5.QtGui.QMovie import stop [as 别名]
#.........这里部分代码省略.........
history_back_btn.setDefaultAction(self.actions.back)
history_back_btn.setContextMenuPolicy(Qt.CustomContextMenu)
history_back_btn.customContextMenuRequested.connect(
lambda pos: self.controller.show_history_context_menu(history_back_btn, False))
self.toolbar.addWidget(history_back_btn)
history_forward_btn = ToolButton()
history_forward_btn.setDefaultAction(self.actions.forward)
history_forward_btn.setContextMenuPolicy(Qt.CustomContextMenu)
history_forward_btn.customContextMenuRequested.connect(
lambda pos: self.controller.show_history_context_menu(history_forward_btn, False))
self.toolbar.addWidget(history_forward_btn)
self.toolbar.addSeparator()
self.toolbar.addAction(self.actions.reload)
self.toolbar.addAction(self.actions.prepare)
# self.toolbar.addSeparator()
# self.toolbar.addAction(self.actions.undo)
# self.toolbar.addAction(self.actions.redo)
self.toolbar.addSeparator()
self.toolbar.addAction(self.actions.show_hidden)
button = QToolButton()
button.setIcon(QIcon.fromTheme("view-restore"))
button.setMenu(self.make_view_menu())
button.setPopupMode(QToolButton.InstantPopup)
self.toolbar.addWidget(button)
button = QToolButton()
button.setIcon(QIcon.fromTheme("view-sort-ascending"))
button.setMenu(self.make_sort_menu())
button.setPopupMode(QToolButton.InstantPopup)
self.toolbar.addWidget(button)
button = QToolButton()
button.setIcon(QIcon.fromTheme("view-sort-ascending"))
button.setMenu(self.make_group_menu())
button.setPopupMode(QToolButton.InstantPopup)
self.toolbar.addWidget(button)
self.toolbar.addSeparator()
self.toolbar.addAction(self.actions.view_icon_view)
self.toolbar.addAction(self.actions.view_small_icon_view)
self.toolbar.addAction(self.actions.view_detail_view)
self.toolbar.addSeparator()
self.toolbar.addAction(self.actions.zoom_in)
self.toolbar.addAction(self.actions.zoom_out)
self.toolbar.addSeparator()
self.toolbar.addAction(self.actions.lod_in)
self.toolbar.addAction(self.actions.lod_out)
self.toolbar.addSeparator()
self.toolbar.addAction(self.actions.crop_thumbnails)
# Spacer to force right alignment for all following widget
spacer = QWidget()
spacer.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
self.toolbar.addWidget(spacer)
self.toolbar.addAction(self.actions.debug)
self.toolbar.addAction(self.controller.app.actions.enable_filesystem)
# Loading icon
self.loading_movie = QMovie(resource_filename("dirtools", "fileview/icons/gears.gif"))
self.loading_label = QLabel()
self.toolbar.addWidget(self.loading_label)
def show_loading(self):
self.show_info("Loading...")
self.loading_label.setMovie(self.loading_movie)
self.loading_movie.start()
self.loading_label.show()
def hide_loading(self):
self.show_info("")
self.loading_movie.stop()
self.loading_label.setMovie(None)
self.loading_label.setVisible(False)
def zoom_in(self):
self.file_view.zoom_in()
def zoom_out(self):
self.file_view.zoom_out()
def set_location(self, location: Location):
self.location_lineedit.set_location(location)
self.location_buttonbar.set_location(location)
self.setWindowTitle("{} - dt-fileview".format(location.as_human()))
def set_file_list(self):
self.location_lineedit.set_unused_text()
def show_info(self, text):
self.info.setText(" " + text)
def show_current_filename(self, filename):
# FIXME: this causes quite substantial keyboard lag when
# scrolling with PageUp/Down
self.status_bar.showMessage(filename)