main.py 文件源码

python
阅读 27 收藏 0 点赞 0 评论 0

项目:Electrify 作者: jyapayne 项目源码 文件源码
def set_icon(self, icon_path, icon):
        if icon_path:
            icon_path = utils.path_join(self.project_dir(), icon_path)
            if os.path.exists(icon_path):
                if icon_path.endswith('.icns'):
                    pngs = pngs_from_icns(icon_path)
                    if pngs:
                        ba = QtCore.QByteArray(pngs[-1].data)
                        image = QtGui.QImage.fromData(ba, 'PNG')
                    else:
                        return
                else:
                    image = QtGui.QImage(icon_path)
                if image.width() >= image.height():
                    image = image.scaledToWidth(48,
                                        QtCore.Qt.SmoothTransformation)
                else:
                    image = image.scaledToHeight(48,
                                        QtCore.Qt.SmoothTransformation)
                icon.setPixmap(QtGui.QPixmap.fromImage(image))
                icon.setStyleSheet('')
            else:
                icon.setPixmap(None)
                icon.setStyleSheet(self.icon_style)
        else:
            icon.setPixmap(None)
            icon.setStyleSheet(self.icon_style)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号