python 版本:3.6.2
使用pip安装:
pip3 install PyQt5
之后通过安装PyQt5-tools,会自动安装Qt Designer
pip install PyQt5-tools
比着这个学的安装,所以
推荐教程:http://code.py40.com/face
就这么一个简单的内容,我几乎看遍了所有的博客,所有的教程,还是解决不了。
一气之下,自己又开始闭门造车了!
# Jump.py
from PyQt5 import QtCore, QtGui, QtWidgets
from Ui_welcom import Ui_Main
from Ui_welcom2 import Ui_Main2
class Ui_Dialog(QtWidgets.QWidget,Ui_Main2):
def __init__(self):
super(Ui_Dialog,self).__init__()
self.setupUi(self)
#主界面
class login(QtWidgets.QMainWindow,Ui_Main):
def __init__(self):
super(login,self).__init__()
self.setupUi(self)
#定义登录按钮的功能
def loginEvent(self):
self.hide()
self.dia = Ui_Dialog()
self.dia.show()
#运行窗口Login
if __name__=="__main__":
import sys
app=QtWidgets.QApplication(sys.argv)
first=login()
first.show()
first.pushButton.clicked.connect(first.loginEvent)
sys.exit(app.exec_())
# -*- coding: utf-8 -*-
# Form implementation generated from reading ui file 'c:\Users\HP\Desktop\welcom.ui'
#
# Created by: PyQt5 UI code generator 5.10.1
#
# WARNING! All changes made in this file will be lost!
from PyQt5 import QtCore, QtGui, QtWidgets
class Ui_Main(object):
def setupUi(self, Form):
Form.setObjectName("Form")
Form.resize(400, 300)
self.label = QtWidgets.QLabel(Form)
self.label.setGeometry(QtCore.QRect(130, 80, 72, 20))
self.label.setObjectName("label")
self.pushButton = QtWidgets.QPushButton(Form)
self.pushButton.setGeometry(QtCore.QRect(120, 160, 93, 28))
self.pushButton.setObjectName("pushButton")
self.pushButton_2 = QtWidgets.QPushButton(Form)
self.pushButton_2.setGeometry(QtCore.QRect(120, 230, 93, 28))
self.pushButton_2.setObjectName("pushButton_2")
self.retranslateUi(Form)
QtCore.QMetaObject.connectSlotsByName(Form)
def retranslateUi(self, Form):
_translate = QtCore.QCoreApplication.translate
Form.setWindowTitle(_translate("Form", "Form"))
self.label.setText(_translate("Form", "不知名系统"))
self.pushButton.setText(_translate("Form", "进入系统"))
self.pushButton_2.setText(_translate("Form", "退出系统"))
# -*- coding: utf-8 -*-
# Form implementation generated from reading ui file 'c:\Users\HP\Desktop\welcom2.ui'
#
# Created by: PyQt5 UI code generator 5.10.1
#
# WARNING! All changes made in this file will be lost!
from PyQt5 import QtCore, QtGui, QtWidgets
class Ui_Main2(object):
def setupUi(self, Form):
Form.setObjectName("Form")
Form.resize(400, 300)
self.label = QtWidgets.QLabel(Form)
self.label.setGeometry(QtCore.QRect(150, 50, 91, 16))
self.label.setObjectName("label")
self.pushButton = QtWidgets.QPushButton(Form)
self.pushButton.setGeometry(QtCore.QRect(150, 160, 93, 28))
self.pushButton.setObjectName("pushButton")
self.pushButton_2 = QtWidgets.QPushButton(Form)
self.pushButton_2.setGeometry(QtCore.QRect(150, 220, 93, 28))
self.pushButton_2.setObjectName("pushButton_2")
self.retranslateUi(Form)
QtCore.QMetaObject.connectSlotsByName(Form)
def retranslateUi(self, Form):
_translate = QtCore.QCoreApplication.translate
Form.setWindowTitle(_translate("Form", "Form"))
self.label.setText(_translate("Form", "不知名步骤"))
self.pushButton.setText(_translate("Form", "第一关"))
self.pushButton_2.setText(_translate("Form", "第二关"))
希望对您有所帮助。累死直接。