本文整理汇总了Python中PyQt4.QtGui.QImageReader.setFileName方法的典型用法代码示例。如果您正苦于以下问题:Python QImageReader.setFileName方法的具体用法?Python QImageReader.setFileName怎么用?Python QImageReader.setFileName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PyQt4.QtGui.QImageReader
的用法示例。
在下文中一共展示了QImageReader.setFileName方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_archive_wallpapers
# 需要导入模块: from PyQt4.QtGui import QImageReader [as 别名]
# 或者: from PyQt4.QtGui.QImageReader import setFileName [as 别名]
def get_archive_wallpapers(self):
"""
Generator returning the date, path and copyright info (via db lookup) of each file found in the
archive location.
:rtype: QDate, unicode, unicode
"""
image_reader = QImageReader()
regex_date_split = re.compile(r'(\d{4})(\d{2})(\d{2})')
copyright_info = self.copyright_db.get_all_info()
archive_folder = self.settings.archive_location
for filename in reversed([x for x in os.listdir(archive_folder) if re_archive_file.match(x)]):
year, month, day = map(int, regex_date_split.findall(filename)[0])
wallpaper_date = QDate(year, month, day)
wallpaper_copyright = copyright_info.get('{0:04d}-{1:02d}-{2:02d}'.format(year, month, day), '')
wallpaper_filename = os.path.join(unicode(archive_folder), filename)
image_reader.setFileName(wallpaper_filename)
image_size = image_reader.size()
image_size.scale(QSize(200, 125), Qt.IgnoreAspectRatio)
image_reader.setScaledSize(image_size)
thumbnail_image = image_reader.read()
if thumbnail_image.isNull():
continue
self.lw_wallpaper_history.add_item(thumbnail_image, wallpaper_date, wallpaper_copyright,
archive_path=wallpaper_filename)
self.app.processEvents()
self.lw_wallpaper_history.sortItems(Qt.AscendingOrder)