|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
本帖最后由 hejialiangya 于 2023-3-20 08:59 编辑
环境:pycharm+pyqt6+pyside6
python版本3.11.2,pyqt6+pyside6版本为6.4.2
学完了课程手痒想练练,就学着写了个登录界面,
login.py是直接通过pyside6转的
新手没有发图权限,所以只能贴代码
-----------界面为QtDesign排版---------------
用户名:QLineEdit框
密 码:QLineEdit框
QPushButton(登录) QPushButton(退出)
-----Main.py-------
import Login
import sys
from PyQt6.QtWidgets import QApplication,QMainWindow
if __name__ == 'main':
app = QApplication(sys.argv)
window = QMainWindow()
LoginUI = Login.Ui_MainWindow()
LoginUI.setupUi(window)
window.show()
sys.exit(app.exec_())
--------login.py------------
# -*- coding: utf-8 -*-
################################################################################
## Form generated from reading UI file 'Login.ui'
##
## Created by: Qt User Interface Compiler version 6.4.2
##
## WARNING! All changes made in this file will be lost when recompiling UI file!
################################################################################
from PySide6.QtCore import (QCoreApplication, QDate, QDateTime, QLocale,
QMetaObject, QObject, QPoint, QRect,
QSize, QTime, QUrl, Qt)
from PySide6.QtGui import (QBrush, QColor, QConicalGradient, QCursor,
QFont, QFontDatabase, QGradient, QIcon,
QImage, QKeySequence, QLinearGradient, QPainter,
QPalette, QPixmap, QRadialGradient, QTransform)
from PySide6.QtWidgets import (QApplication, QFrame, QLabel, QLineEdit,
QMainWindow, QMenuBar, QPushButton, QSizePolicy,
QStatusBar, QWidget)
class Ui_MainWindow(object):
def setupUi(self, MainWindow):
if not MainWindow.objectName():
MainWindow.setObjectName(u"MainWindow")
MainWindow.resize(641, 446)
self.centralwidget = QWidget(MainWindow)
self.centralwidget.setObjectName(u"centralwidget")
self.frame = QFrame(self.centralwidget)
self.frame.setObjectName(u"frame")
self.frame.setGeometry(QRect(90, 90, 471, 211))
self.frame.setFrameShape(QFrame.StyledPanel)
self.frame.setFrameShadow(QFrame.Raised)
self.LoginButton = QPushButton(self.frame)
self.LoginButton.setObjectName(u"LoginButton")
self.LoginButton.setGeometry(QRect(76, 150, 140, 31))
font = QFont()
font.setPointSize(12)
self.LoginButton.setFont(font)
self.LoginButton.setStyleSheet(u"background-color: rgb(170, 85, 255);")
self.UserNameLabel = QLabel(self.frame)
self.UserNameLabel.setObjectName(u"UserNameLabel")
self.UserNameLabel.setGeometry(QRect(74, 29, 71, 31))
self.UserNameLabel.setFont(font)
self.PasswordLabel = QLabel(self.frame)
self.PasswordLabel.setObjectName(u"PasswordLabel")
self.PasswordLabel.setGeometry(QRect(74, 93, 53, 16))
self.PasswordLabel.setFont(font)
self.PasswordEdit = QLineEdit(self.frame)
self.PasswordEdit.setObjectName(u"PasswordEdit")
self.PasswordEdit.setGeometry(QRect(140, 83, 260, 40))
self.UserNameEdit = QLineEdit(self.frame)
self.UserNameEdit.setObjectName(u"UserNameEdit")
self.UserNameEdit.setGeometry(QRect(140, 25, 260, 40))
self.ExitButton = QPushButton(self.frame)
self.ExitButton.setObjectName(u"ExitButton")
self.ExitButton.setGeometry(QRect(261, 150, 140, 31))
self.ExitButton.setFont(font)
self.ExitButton.setStyleSheet(u"background-color: rgb(170, 85, 255);")
MainWindow.setCentralWidget(self.centralwidget)
self.menubar = QMenuBar(MainWindow)
self.menubar.setObjectName(u"menubar")
self.menubar.setGeometry(QRect(0, 0, 641, 22))
MainWindow.setMenuBar(self.menubar)
self.statusbar = QStatusBar(MainWindow)
self.statusbar.setObjectName(u"statusbar")
MainWindow.setStatusBar(self.statusbar)
self.retranslateUi(MainWindow)
self.ExitButton.clicked.connect(MainWindow.close)
QMetaObject.connectSlotsByName(MainWindow)
# setupUi
def retranslateUi(self, MainWindow):
MainWindow.setWindowTitle(QCoreApplication.translate("MainWindow", u"MainWindow", None))
self.LoginButton.setText(QCoreApplication.translate("MainWindow", u"\u767b\u5f55", None))
self.UserNameLabel.setText(QCoreApplication.translate("MainWindow", u"\u7528\u6237\u540d", None))
self.PasswordLabel.setText(QCoreApplication.translate("MainWindow", u"\u5bc6\u7801", None))
self.ExitButton.setText(QCoreApplication.translate("MainWindow", u"\u9000\u51fa", None))
# retranslateUi
编译后“进程已结束,退出代码0”
不报错,但是也不跳出登录界面, 请问我问题出在哪里了? |
|