當前位置: 首頁>>代碼示例>>Python>>正文


Python QImageReader.setFileName方法代碼示例

本文整理匯總了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)
開發者ID:se0siris,項目名稱:bing-wallpaper-changer,代碼行數:31,代碼來源:mainwindow.py


注:本文中的PyQt4.QtGui.QImageReader.setFileName方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。