本文整理汇总了Python中PyQt5.QtGui.QMovie.currentPixmap方法的典型用法代码示例。如果您正苦于以下问题:Python QMovie.currentPixmap方法的具体用法?Python QMovie.currentPixmap怎么用?Python QMovie.currentPixmap使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt5.QtGui.QMovie
的用法示例。
在下文中一共展示了QMovie.currentPixmap方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: SystemTrayIcon
# 需要导入模块: from PyQt5.QtGui import QMovie [as 别名]
# 或者: from PyQt5.QtGui.QMovie import currentPixmap [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: IconManagement
# 需要导入模块: from PyQt5.QtGui import QMovie [as 别名]
# 或者: from PyQt5.QtGui.QMovie import currentPixmap [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: MainWindow
# 需要导入模块: from PyQt5.QtGui import QMovie [as 别名]
# 或者: from PyQt5.QtGui.QMovie import currentPixmap [as 别名]
class MainWindow(QMainWindow):
def __init__(self, parent=None):
super(MainWindow, self).__init__(parent)
self.setGeometry(50, 50, 600, 750)
self.setFixedSize(500, 500)
self.startUIWindow()
self.movie = QMovie("mail.gif")
self.movie.frameChanged.connect(self.repaint)
self.movie.start()
def startUIWindow(self):
self.Window = UIWindow(self)
self.setWindowTitle("Email Dialog")
self.show()
def paintEvent(self, event):
currentFrame = self.movie.currentPixmap()
frameRect = currentFrame.rect()
frameRect.moveCenter(self.rect().center())
if frameRect.intersects(event.rect()):
painter = QPainter(self)
painter.drawPixmap(frameRect.left(), frameRect.top(), currentFrame)
示例4: SystemTrayIcon
# 需要导入模块: from PyQt5.QtGui import QMovie [as 别名]
# 或者: from PyQt5.QtGui.QMovie import currentPixmap [as 别名]
class SystemTrayIcon(QMainWindow):
def __init__(self, parent=None):
super(SystemTrayIcon, self).__init__(parent)
self.setAttribute(Qt.WA_DeleteOnClose)
self.settings = QSettings()
self.language = self.settings.value('Language') or ''
self.temp_decimal_bool = self.settings.value('Decimal') or False
# initialize the tray icon type in case of first run: issue#42
self.tray_type = self.settings.value('TrayType') or 'icon&temp'
cond = conditions.WeatherConditions()
self.temporary_city_status = False
self.conditions = cond.trans
self.clouds = cond.clouds
self.wind = cond.wind
self.wind_dir = cond.wind_direction
self.wind_codes = cond.wind_codes
self.inerror = False
self.tentatives = 0
self.baseurl = 'http://api.openweathermap.org/data/2.5/weather?id='
self.accurate_url = 'http://api.openweathermap.org/data/2.5/find?q='
self.forecast_url = ('http://api.openweathermap.org/data/2.5/forecast/'
'daily?id=')
self.day_forecast_url = ('http://api.openweathermap.org/data/2.5/'
'forecast?id=')
self.wIconUrl = 'http://openweathermap.org/img/w/'
apikey = self.settings.value('APPID') or ''
self.appid = '&APPID=' + apikey
self.forecast_icon_url = self.wIconUrl
self.timer = QTimer(self)
self.timer.timeout.connect(self.refresh)
self.menu = QMenu()
self.citiesMenu = QMenu(self.tr('Cities'))
self.tempCityAction = QAction(self.tr('&Temporary city'), self)
self.refreshAction = QAction(self.tr('&Update'), self)
self.settingsAction = QAction(self.tr('&Settings'), self)
self.aboutAction = QAction(self.tr('&About'), self)
self.exitAction = QAction(self.tr('Exit'), self)
self.exitAction.setIcon(QIcon(':/exit'))
self.aboutAction.setIcon(QIcon(':/info'))
self.refreshAction.setIcon(QIcon(':/refresh'))
self.settingsAction.setIcon(QIcon(':/configure'))
self.tempCityAction.setIcon(QIcon(':/tempcity'))
self.citiesMenu.setIcon(QIcon(':/bookmarks'))
self.menu.addAction(self.settingsAction)
self.menu.addAction(self.refreshAction)
self.menu.addMenu(self.citiesMenu)
self.menu.addAction(self.tempCityAction)
self.menu.addAction(self.aboutAction)
self.menu.addAction(self.exitAction)
self.settingsAction.triggered.connect(self.config)
self.exitAction.triggered.connect(qApp.quit)
self.refreshAction.triggered.connect(self.manual_refresh)
self.aboutAction.triggered.connect(self.about)
self.tempCityAction.triggered.connect(self.tempcity)
self.systray = QSystemTrayIcon()
self.systray.setContextMenu(self.menu)
self.systray.activated.connect(self.activate)
self.systray.setIcon(QIcon(':/noicon'))
self.systray.setToolTip(self.tr('Searching weather data...'))
self.notification = ''
self.notification_temp = 0
self.notifications_id = ''
self.systray.show()
# The dictionnary has to be intialized here. If there is an error
# the program couldn't become functionnal if the dictionnary is
# reinitialized in the weatherdata method
self.weatherDataDico = {}
# The traycolor has to be initialized here for the case when we cannot
# reach the tray method (case: set the color at first time usage)
self.traycolor = ''
self.refresh()
def icon_loading(self):
self.gif_loading = QMovie(":/loading")
self.gif_loading.frameChanged.connect(self.update_gif)
self.gif_loading.start()
def update_gif(self):
gif_frame = self.gif_loading.currentPixmap()
self.systray.setIcon(QIcon(gif_frame))
def manual_refresh(self):
self.tentatives = 0
self.refresh()
def cities_menu(self):
# Don't add the temporary city in the list
if self.temporary_city_status:
return
self.citiesMenu.clear()
cities = self.settings.value('CityList') or []
if type(cities) is str:
cities = eval(cities)
try:
current_city = (self.settings.value('City') + '_' +
self.settings.value('Country') + '_' +
self.settings.value('ID'))
except:
# firsttime run,if clic cancel in setings without any city configured
pass
#.........这里部分代码省略.........