# -*- coding: utf-8 -*-
# Form implementation generated from reading ui file 'LoginUi.ui'
#
# Created by: PyQt5 UI code generator 5.9.2
#
# WARNING! All changes made in this file will be lost!
from PyQt5 import QtCore, QtGui, QtWidgets
class Ui_LoginWindow(object):
def setupUi(self, LoginWindow):
LoginWindow.setObjectName("LoginWindow")
LoginWindow.resize(800, 583)
self.centralwidget = QtWidgets.QWidget(LoginWindow)
self.centralwidget.setObjectName("centralwidget")
self.frame_2 = QtWidgets.QFrame(self.centralwidget)
self.frame_2.setGeometry(QtCore.QRect(390, 150, 300, 300))
self.frame_2.setStyleSheet("#frame_2{background-color: rgb(255, 255, 255);}\n"
"")
self.frame_2.setFrameShape(QtWidgets.QFrame.StyledPanel)
self.frame_2.setFrameShadow(QtWidgets.QFrame.Raised)
self.frame_2.setObjectName("frame_2")
self.label = QtWidgets.QLabel(self.frame_2)
self.label.setGeometry(QtCore.QRect(90, 20, 121, 31))
self.label.setStyleSheet("font: 20pt \"Khmer OS Content\";")
self.label.setObjectName("label")
self.frame_3 = QtWidgets.QFrame(self.frame_2)
self.frame_3.setGeometry(QtCore.QRect(0, 60, 300, 230))
self.frame_3.setMinimumSize(QtCore.QSize(300, 230))
self.frame_3.setFrameShape(QtWidgets.QFrame.StyledPanel)
self.frame_3.setFrameShadow(QtWidgets.QFrame.Raised)
self.frame_3.setObjectName("frame_3")
self.verticalLayout = QtWidgets.QVBoxLayout(self.frame_3)
self.verticalLayout.setContentsMargins(0, 0, 0, 0)
self.verticalLayout.setSpacing(0)
self.verticalLayout.setObjectName("verticalLayout")
self.frame_4 = QtWidgets.QFrame(self.frame_3)
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Expanding)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(6)
sizePolicy.setHeightForWidth(self.frame_4.sizePolicy().hasHeightForWidth())
self.frame_4.setSizePolicy(sizePolicy)
self.frame_4.setFrameShape(QtWidgets.QFrame.StyledPanel)
self.frame_4.setFrameShadow(QtWidgets.QFrame.Raised)
self.frame_4.setObjectName("frame_4")
self.verticalLayout_3 = QtWidgets.QVBoxLayout(self.frame_4)
self.verticalLayout_3.setContentsMargins(0, 0, 0, 0)
self.verticalLayout_3.setSpacing(0)
self.verticalLayout_3.setObjectName("verticalLayout_3")
self.frame_6 = QtWidgets.QFrame(self.frame_4)
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Expanding)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(5)
sizePolicy.setHeightForWidth(self.frame_6.sizePolicy().hasHeightForWidth())
self.frame_6.setSizePolicy(sizePolicy)
self.frame_6.setStyleSheet("QLineEdit{\n"
" background-color : rgba(255,255,255,0);\n"
" border:none;\n"
" border-bottom:1px solid blacj;\n"
"}\n"
"QPushButton{\n"
"background-color:rgb(0,0,0);\n"
"color:rgb(255,255,255);\n"
"border-radius:7px;\n"
"}\n"
"QPushButton{\n"
"padding-top:5px;\n"
"padding-left:5px;}")
self.frame_6.setFrameShape(QtWidgets.QFrame.StyledPanel)
self.frame_6.setFrameShadow(QtWidgets.QFrame.Raised)
self.frame_6.setObjectName("frame_6")
self.verticalLayout_4 = QtWidgets.QVBoxLayout(self.frame_6)
self.verticalLayout_4.setObjectName("verticalLayout_4")
self.lineEdit_L_username = QtWidgets.QLineEdit(self.frame_6)
self.lineEdit_L_username.setMinimumSize(QtCore.QSize(0, 30))
self.lineEdit_L_username.setStyleSheet("QLineEdit{\n"
" background-color : rgba(255,255,255,0);\n"
" border:none;\n"
" border-bottom:1px solid blacj;\n"
"}")
self.lineEdit_L_username.setObjectName("lineEdit_L_username")
self.verticalLayout_4.addWidget(self.lineEdit_L_username)
self.lineEdit_L_password = QtWidgets.QLineEdit(self.frame_6)
self.lineEdit_L_password.setMinimumSize(QtCore.QSize(0, 30))
self.lineEdit_L_password.setEchoMode(QtWidgets.QLineEdit.Password)
self.lineEdit_L_password.setObjectName("lineEdit_L_password")
self.verticalLayout_4.addWidget(self.lineEdit_L_password)
self.pushButton_L_ok = QtWidgets.QPushButton(self.frame_6)
self.pushButton_L_ok.setMinimumSize(QtCore.QSize(0, 35))
self.pushButton_L_ok.setObjectName("pushButton_L_ok")
self.verticalLayout_4.addWidget(self.pushButton_L_ok)
self.verticalLayout_3.addWidget(self.frame_6)
self.frame_7 = QtWidgets.QFrame(self.frame_4)
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Expanding)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(2)
sizePolicy.setHeightForWidth(self.frame_7.sizePolicy().hasHeightForWidth())
self.frame_7.setSizePolicy(sizePolicy)
self.frame_7.setFrameShape(QtWidgets.QFrame.StyledPanel)
self.frame_7.setFrameShadow(QtWidgets.QFrame.Raised)
self.frame_7.setObjectName("frame_7")
self.horizontalLayout = QtWidgets.QHBoxLayout(self.frame_7)
self.horizontalLayout.setObjectName("horizontalLayout")
self.pushButton_L_login = QtWidgets.QPushButton(self.frame_7)
self.pushButton_L_login.setObjectName("pushButton_L_login")
self.horizontalLayout.addWidget(self.pushButton_L_login)
self.pushButton_L_signup = QtWidgets.QPushButton(self.frame_7)
self.pushButton_L_signup.setObjectName("pushButton_L_signup")
self.horizontalLayout.addWidget(self.pushButton_L_signup)
self.verticalLayout_3.addWidget(self.frame_7)
self.verticalLayout.addWidget(self.frame_4)
self.frame_5 = QtWidgets.QFrame(self.frame_3)
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Expanding)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(1)
sizePolicy.setHeightForWidth(self.frame_5.sizePolicy().hasHeightForWidth())
self.frame_5.setSizePolicy(sizePolicy)
self.frame_5.setFrameShape(QtWidgets.QFrame.StyledPanel)
self.frame_5.setFrameShadow(QtWidgets.QFrame.Raised)
self.frame_5.setObjectName("frame_5")
self.verticalLayout_2 = QtWidgets.QVBoxLayout(self.frame_5)
self.verticalLayout_2.setContentsMargins(0, 0, 0, 0)
self.verticalLayout_2.setSpacing(0)
self.verticalLayout_2.setObjectName("verticalLayout_2")
self.stackedWidget = QtWidgets.QStackedWidget(self.frame_5)
self.stackedWidget.setObjectName("stackedWidget")
self.page = QtWidgets.QWidget()
self.page.setObjectName("page")
self.stackedWidget.addWidget(self.page)
self.page_2 = QtWidgets.QWidget()
self.page_2.setObjectName("page_2")
self.stackedWidget.addWidget(self.page_2)
self.verticalLayout_2.addWidget(self.stackedWidget)
self.verticalLayout.addWidget(self.frame_5)
self.pushButton_2 = QtWidgets.QPushButton(self.frame_2)
self.pushButton_2.setGeometry(QtCore.QRect(270, 0, 31, 24))
self.pushButton_2.setObjectName("pushButton_2")
self.frame = QtWidgets.QFrame(self.centralwidget)
self.frame.setGeometry(QtCore.QRect(90, 150, 300, 300))
self.frame.setStyleSheet("#frame{\n"
" background-color: rgb(20, 20, 20);\n"
"}")
self.frame.setFrameShape(QtWidgets.QFrame.StyledPanel)
self.frame.setFrameShadow(QtWidgets.QFrame.Raised)
self.frame.setObjectName("frame")
self.pushButton = QtWidgets.QPushButton(self.frame)
self.pushButton.setGeometry(QtCore.QRect(0, 0, 300, 300))
self.pushButton.setText("")
icon = QtGui.QIcon()
icon.addPixmap(QtGui.QPixmap(":/icons/1.jpg"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
self.pushButton.setIcon(icon)
self.pushButton.setIconSize(QtCore.QSize(300, 300))
self.pushButton.setObjectName("pushButton")
LoginWindow.setCentralWidget(self.centralwidget)
self.retranslateUi(LoginWindow)
self.stackedWidget.setCurrentIndex(1)
self.pushButton_2.clicked.connect(LoginWindow.close)
QtCore.QMetaObject.connectSlotsByName(LoginWindow)
def retranslateUi(self, LoginWindow):
_translate = QtCore.QCoreApplication.translate
LoginWindow.setWindowTitle(_translate("LoginWindow", "MainWindow"))
self.label.setText(_translate("LoginWindow", "Welcome"))
self.lineEdit_L_username.setPlaceholderText(_translate("LoginWindow", "Username:"))
self.lineEdit_L_password.setPlaceholderText(_translate("LoginWindow", "Password:"))
self.pushButton_L_ok.setText(_translate("LoginWindow", "OK"))
self.pushButton_L_login.setText(_translate("LoginWindow", "Sign up"))
self.pushButton_L_signup.setText(_translate("LoginWindow", "Forget Password"))
self.pushButton_2.setText(_translate("LoginWindow", "X"))
import res_rc
以上为QtDesign画完框架后生成的代码
接下来用以下的主函数调用,运行主函数可显示制作的界面
# This Python file uses the following encoding: utf-8
import sqlite3
import traceback
from PyQt5.QtGui import QMouseEvent
from LoginUi import *
from InterfaceUi import *
from RightMenu import *
import sys
from PyQt5.QtWidgets import QApplication, QMainWindow, QAbstractItemView, QMessageBox
from PyQt5.QtCore import Qt, QPoint
import pandas as pd
from pandas.core.frame import DataFrame
class LoginWindow(QMainWindow):
def __init__(self):
super().__init__()
self.ui = Ui_LoginWindow()
self.ui.setupUi(self)
# 设置为无边框的界面
# self.setWindowFlag(QtCore.Qt.FramelessWindowHint)
self.setWindowFlags(QtCore.Qt.FramelessWindowHint | QtCore.Qt.WindowStaysOnTopHint)
self.setAttribute(QtCore.Qt.WA_TranslucentBackground)
self.ui.pushButton_L_ok.clicked.connect(self.login_in)
self.show()
if __name__ == '__main__':
app = QApplication(sys.argv)
main = LoginWindow()
sys.exit(app.exec_())