模仿QQ登录界面窗口~PYQT6,实现登录、天气预报查询

我新手小白,一直想学习做一款程序,今天终于让我实现了一部分

  1. 登录窗口实现,
    1. 模仿QQ登录界面
      1. 背景动态渐变效果,每次打开都不一样,是动态的会不断变化
      2. 用户输入框和密码输入框在默认状态显示灰色,当选中时:图标变色、底部边框变色
      3. 关于动态渐变色思路:一开始想的时动态图片,后来怎么都觉得不好看,于是就想到动态背景,弄了半天效果都不好,突然灵光一现,在窗口增加了很多颜色粒子,让他们在窗体移动,然后在该一层的模糊滤镜
      4. 添加运动粒子添加滤镜效果设置70模糊度效果就有了,因为时随机生成颜色,就要限制下颜色范围,不要低饱和度的,
      5. 鼠标可以拖动窗体,添加阴影
    2. UI界面代码
      # Form implementation generated from reading ui file 'LoginUi.ui'
      #
      # Created by: PyQt6 UI code generator 6.4.2
      #
      # WARNING: Any manual changes made to this file will be lost when pyuic6 is
      # run again.  Do not edit this file unless you know what you are doing.
      
      
      from PyQt6 import QtCore, QtGui, QtWidgets
      
      
      class Ui_Form(object):
          def setupUi(self, Form):
              Form.setObjectName("Form")
              Form.resize(496, 409)
              Form.setStyleSheet("QPushButton {\n"
                                 "background-color: rgba(255, 255, 255, 0); /* 背景颜色 */\n"
                                 "border:0px; /* 边框样式 */\n"
                                 "border-radius: 3px;         /* 圆角 */\n"
                                 "padding: 2px 4px;           /* 内边距 */\n"
                                 "color: white;               /* 文字颜色 */\n"
                                 "\n"
                                 "    }\n"
                                 "    QPushButton:hover {\n"
                                 "        background-color:rgba(0, 0, 0, 50);  /* 鼠标悬停时的背景颜色 */\n"
                                 "    }\n"
                                 "    QPushButton:pressed {\n"
                                 "        background-color: rgba(0, 0, 0, 150);  /* 按下时的背景颜色 */\n"
                                 "    }\n"
                                 "\n"
                                 "\n"
                                 "QLineEdit {\n"
                                 "        border-bottom-width: 0px;      /* 默认底部边框隐藏 */\n"
                                 "        border-style: solid;\n"
                                 "        padding: 30px;\n"
                                 "        background-color: #FFFFFF;\n"
                                 "        color: #000000;\n"
                                 "        border-bottom-width: 2px;      /* 获取焦点时底部边框宽度 */\n"
                                 "        border-bottom-color: rgb(172, 172, 172);     /* 获取焦点时底部边框颜色 */\n"
                                 "    }\n"
                                 "    QLineEdit:focus {\n"
                                 "        border-bottom-width: 2px;      /* 获取焦点时底部边框宽度 */\n"
                                 "        border-bottom-color: rgb(0, 170, 255);     /* 获取焦点时底部边框颜色 */\n"
                                 "        border-bottom-style: solid;    /* 获取焦点时底部边框样式 */\n"
                                 "    }\n"
                                 "\n"
                                 "\n"
                                 "")
              self.LoginMain = QtWidgets.QFrame(parent=Form)
              self.LoginMain.setGeometry(QtCore.QRect(30, 30, 430, 330))
              self.LoginMain.setMinimumSize(QtCore.QSize(430, 330))
              self.LoginMain.setMaximumSize(QtCore.QSize(430, 430))
              self.LoginMain.setStyleSheet("QFrame {\n"
                                           "border-radius: 5px;\n"
                                           "background-color: qlineargradient(spread:pad, x1:1, y1:0.023, x2:0, y2:0.994, stop:0 rgba(105, 183, 206, 255), stop:1 rgba(63, 111, 118, 255));\n"
                                           "border: 1px solid rgb(100, 169, 139);\n"
                                           "   }")
              self.LoginMain.setFrameShape(QtWidgets.QFrame.Shape.StyledPanel)
              self.LoginMain.setFrameShadow(QtWidgets.QFrame.Shadow.Raised)
              self.LoginMain.setObjectName("LoginMain")
              self.UserName = QtWidgets.QLineEdit(parent=self.LoginMain)
              self.UserName.setGeometry(QtCore.QRect(95, 170, 240, 30))
              self.UserName.setMinimumSize(QtCore.QSize(240, 30))
              self.UserName.setMaximumSize(QtCore.QSize(240, 30))
              self.UserName.setStyleSheet("QLineEdit {\n"
                                          "    border-top-left-radius: 10px;  /* 左上角圆角 */\n"
                                          "    border-top-right-radius: 10px; /* 右上角圆角 */\n"
                                          "    background-image: url(res/Weather/loginicon/icon_Hui/yonghuming.png); /* 图标1 */\n"
                                          "    background-repeat: no-repeat;\n"
                                          "    background-position: left center;\n"
                                          "    padding-left: 35px; /* 调整这个值以确保文本与图标之间有足够的间距 */\n"
                                          "    background-size: 20px 20px; /* 明确设置图标大小 */\n"
                                          "}\n"
                                          "\n"
                                          "QLineEdit::focus {\n"
                                          "    background-image: url(res/Weather/loginicon/icon_Lan/yonghuming.png); /* 图标2 */\n"
                                          "    background-repeat: no-repeat;\n"
                                          "    background-position: left center;\n"
                                          "    padding-left: 35px; /* 调整这个值以确保文本与图标之间有足够的间距 */\n"
                                          "    background-size: 20px 20px; /* 明确设置图标大小 */\n"
                                          "}\n"
                                          "")
              self.UserName.setObjectName("UserName")
              self.FPbutton = QtWidgets.QPushButton(parent=self.LoginMain)
              self.FPbutton.setGeometry(QtCore.QRect(175, 230, 80, 30))
              self.FPbutton.setMinimumSize(QtCore.QSize(0, 30))
              self.FPbutton.setMaximumSize(QtCore.QSize(16777215, 30))
              font = QtGui.QFont()
              font.setPointSize(9)
              self.FPbutton.setFont(font)
              self.FPbutton.setStyleSheet("QPushButton\n"
                                          "{background-color: rgba(255, 255, 255, 0);\n"
                                          "}\n"
                                          "QPushButton:hover {\n"
                                          "color:rgba(0, 0, 0, 50);  /* 鼠标悬停时的背景颜色 */\n"
                                          " }\n"
                                          " QPushButton:pressed {\n"
                                          "color: rgba(0, 0, 0, 150);  /* 按下时的背景颜色 */\n"
                                          " }")
              self.FPbutton.setObjectName("FPbutton")
              self.RPbutton = QtWidgets.QCheckBox(parent=self.LoginMain)
              self.RPbutton.setGeometry(QtCore.QRect(95, 231, 79, 30))
              self.RPbutton.setMinimumSize(QtCore.QSize(0, 30))
              self.RPbutton.setMaximumSize(QtCore.QSize(16777215, 30))
              self.RPbutton.setStyleSheet("QCheckBox\n"
                                          "{\n"
                                          "background-color: rgba(255, 255, 255, 0);\n"
                                          "    color: rgb(255, 255, 255);\n"
                                          "}\n"
                                          "QCheckBox:hover {\n"
                                          "color:rgba(0, 0, 0, 50);  /* 鼠标悬停时的背景颜色 */\n"
                                          " }\n"
                                          " QCheckBox:pressed {\n"
                                          "color: rgba(0, 0, 0, 150);  /* 按下时的背景颜色 */\n"
                                          " }")
              self.RPbutton.setObjectName("RPbutton")
              self.PassWord = QtWidgets.QLineEdit(parent=self.LoginMain)
              self.PassWord.setGeometry(QtCore.QRect(95, 200, 240, 30))
              self.PassWord.setMinimumSize(QtCore.QSize(240, 3))
              self.PassWord.setMaximumSize(QtCore.QSize(240, 30))
              self.PassWord.setContextMenuPolicy(QtCore.Qt.ContextMenuPolicy.PreventContextMenu)
              self.PassWord.setStyleSheet("QLineEdit {\n"
                                          "        border-bottom-left-radius: 10px;  /* 左上角圆角 */\n"
                                          "        border-bottom-right-radius: 10px; /* 右上角圆角 */\n"
                                          "         background-image: url(res/Weather/loginicon/icon_Hui/tianchongxing-_1.png); /* 图标1 */\n"
                                          "            background-repeat: no-repeat;\n"
                                          "            background-position: left center;\n"
                                          "    padding-left: 35px; /* 调整这个值以确保文本与图标之间有足够的间距 */\n"
                                          "        }\n"
                                          "QLineEdit::focus {\n"
                                          "            background-image:url(res/Weather/loginicon/icon_Lan/tianchongxing-.png); /* 图标2 */\n"
                                          "            background-repeat: no-repeat;\n"
                                          "            background-position: left center;\n"
                                          "    padding-left: 35px; /* 调整这个值以确保文本与图标之间有足够的间距 */\n"
                                          "        }")
              self.PassWord.setEchoMode(QtWidgets.QLineEdit.EchoMode.Password)
              self.PassWord.setObjectName("PassWord")
              self.LoginButton = QtWidgets.QPushButton(parent=self.LoginMain)
              self.LoginButton.setGeometry(QtCore.QRect(95, 265, 240, 35))
              self.LoginButton.setMinimumSize(QtCore.QSize(240, 35))
              self.LoginButton.setMaximumSize(QtCore.QSize(240, 35))
              self.LoginButton.setStyleSheet("QPushButton {\n"
                                             "background-color: rgb(0, 170, 255); /* 背景颜色 */\n"
                                             "border:0px; /* 边框样式 */\n"
                                             "border-radius: 8px;         /* 圆角 */\n"
                                             "font-size: 16px;            /* 字体大小 */\n"
                                             "    }\n"
                                             "    QPushButton:hover {\n"
                                             "        background-color:rgb(0, 145, 218);  /* 鼠标悬停时的背景颜色 */\n"
                                             "    }\n"
                                             "    QPushButton:pressed {\n"
                                             "        background-color: rgb(0, 113, 170);  /* 按下时的背景颜色 */\n"
                                             "    }")
              self.LoginButton.setObjectName("LoginButton")
              self.RAbutton = QtWidgets.QPushButton(parent=self.LoginMain)
              self.RAbutton.setGeometry(QtCore.QRect(255, 231, 79, 30))
              self.RAbutton.setMinimumSize(QtCore.QSize(0, 30))
              self.RAbutton.setMaximumSize(QtCore.QSize(16777215, 30))
              self.RAbutton.setStyleSheet("QPushButton\n"
                                          "{background-color: rgba(255, 255, 255, 0);\n"
                                          "}\n"
                                          "QPushButton:hover {\n"
                                          "color:rgba(0, 0, 0, 50);  /* 鼠标悬停时的背景颜色 */\n"
                                          " }\n"
                                          " QPushButton:pressed {\n"
                                          "color: rgba(0, 0, 0, 150);  /* 按下时的背景颜色 */\n"
                                          " }")
              self.RAbutton.setObjectName("RAbutton")
              self.CloseButton = QtWidgets.QPushButton(parent=self.LoginMain)
              self.CloseButton.setGeometry(QtCore.QRect(400, 0, 30, 30))
              self.CloseButton.setMinimumSize(QtCore.QSize(30, 30))
              self.CloseButton.setMaximumSize(QtCore.QSize(30, 30))
              self.CloseButton.setStyleSheet("QPushButton:hover {\n"
                                             "background-color: rgba(170, 0, 0, 150);  /* 鼠标悬停时的背景颜色 */\n"
                                             "}\n"
                                             "QPushButton:pressed {\n"
                                             "background-color: rgba(170, 0, 0, 250);  /* 按下时的背景颜色 */\n"
                                             "}")
              
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值