pyqt-todolist/view/UserLabel.py

51 lines
1.7 KiB
Python
Raw Normal View History

2022-04-01 22:25:19 +08:00
import os
import sys
from PyQt5.QtWidgets import *
from PyQt5.QtGui import *
from utils.QSSLoader import QSSLoader
from PyQt5.QtCore import Qt
class User(QLabel):
def __init__(self):
super(User, self).__init__()
self.widget = QWidget(self)
self.resize(200, 60)
# todo
# 修改布局使适合微软todo的样式
# 设置点击事件,使用右键菜单的样式添加设置、同步、退出
# 暂时就这样
layout = QHBoxLayout()
info_layout = QVBoxLayout()
self.pic_label = QLabel('')
self.pic_label.setPixmap(
QPixmap(os.path.abspath('../') + '/images/user.svg').scaled(50, 50, Qt.IgnoreAspectRatio,
Qt.SmoothTransformation))
layout.addWidget(self.pic_label, Qt.AlignCenter)
layout.addStretch(2)
self.user_name = QLabel("用户登录")
self.user_mail = QLabel('邮箱')
self.user_mail.setStyleSheet('font-size:16px')
info_layout.addWidget(self.user_name)
info_layout.addWidget(self.user_mail)
layout.addLayout(info_layout)
layout.addStretch(0)
self.widget.setLayout(layout)
# # 设置自定义的QListWidgetItem的sizeHint不然无法显示
# self.setSizeHint(self.widget.sizeHint())
if __name__ == "__main__":
app = QApplication(sys.argv)
main = User()
style_sheet = QSSLoader.read_qss_file('../resource/current.qss')
main.setStyleSheet(style_sheet)
# print(os.path.abspath('../'))
app.setWindowIcon(QIcon(os.path.abspath('../') + '/images/todo.svg'))
main.show()
sys.exit(app.exec_())