代码拉取完成,页面将自动刷新
同步操作将从 PyQt5/CustomWidgets 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Created on 2019年7月26日
@author: Irony
@site: https://pyqt5.com https://github.com/892768447
@email: 892768447@qq.com
@file: TestCAvatar
@description:
"""
from PyQt5.QtCore import QSize
from PyQt5.QtWidgets import QWidget, QHBoxLayout
from CustomWidgets.CAvatar import CAvatar
__Author__ = 'Irony'
__Copyright__ = 'Copyright (c) 2019 Irony'
__Version__ = 1.0
class Window(QWidget):
def __init__(self, *args, **kwargs):
super(Window, self).__init__(*args, **kwargs)
layout = QHBoxLayout(self)
# 没有头像
layout.addWidget(CAvatar(self))
# 路径错误
layout.addWidget(CAvatar(self, url='test.jpg'))
# 本地三种尺寸头像
layout.addWidget(CAvatar(
self, shape=CAvatar.Circle, url='TestData/example-1.jpg', size=CAvatar.SizeSmall))
layout.addWidget(CAvatar(
self, shape=CAvatar.Circle, url='TestData/example-2.jpg', animation=True))
layout.addWidget(CAvatar(
self, shape=CAvatar.Rectangle, url='TestData/example-3.jpg', size=QSize(48, 48)))
# 本地gif, 不支持animation
layout.addWidget(CAvatar(
self, shape=CAvatar.Circle, url='TestData/example-1.gif'))
# 网络头像
layout.addWidget(CAvatar(
self, shape=CAvatar.Rectangle,
url='https://www.thiswaifudoesnotexist.net/example-1000.jpg', size=CAvatar.SizeSmall))
layout.addWidget(CAvatar(
self, shape=CAvatar.Circle, animation=True,
url='https://www.thiswaifudoesnotexist.net/example-1001.jpg'))
# 假装路径错误
layout.addWidget(CAvatar(
self, shape=CAvatar.Rectangle,
url='https://www.thiswaifudoesnotexist.net/example.jpg'))
# 加载网络gif
layout.addWidget(CAvatar(
self, shape=CAvatar.Rectangle, size=CAvatar.SizeLarge,
url='https://n.sinaimg.cn/tech/transform/761/w404h357/20190923/d71b-iewtena6804980.gif'))
if __name__ == '__main__':
import sys
import cgitb
sys.excepthook = cgitb.enable(1, None, 5, '')
from PyQt5.QtWidgets import QApplication
app = QApplication(sys.argv)
w = Window()
w.show()
sys.exit(app.exec_())
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。