Python+Pyqt 5 기반 응용 프로그램 개발

14110 단어 PythonPyqt5순서
너 를 소개 한 그녀/그
1.UI―MainWindow 디자인 인터페이스 및 코드

# -*- coding: utf-8 -*-

# Form implementation generated from reading ui file '/media/sf_data/onemore_tjj/Again_tjj/MainWindow.ui'
#
# Created by: PyQt5 UI code generator 5.14.1
#
# WARNING! All changes made in this file will be lost!


from PyQt5 import QtCore, QtGui, QtWidgets


class Ui_MainWindow(object):
    def setupUi(self, MainWindow):
        MainWindow.setObjectName("MainWindow")
        MainWindow.resize(788, 634)
        self.centralwidget = QtWidgets.QWidget(MainWindow)
        self.centralwidget.setObjectName("centralwidget")
        self.groupBox_2 = QtWidgets.QGroupBox(self.centralwidget)
        self.groupBox_2.setGeometry(QtCore.QRect(40, 270, 691, 321))
        self.groupBox_2.setObjectName("groupBox_2")
        self.txtResume = QtWidgets.QTextEdit(self.groupBox_2)
        self.txtResume.setGeometry(QtCore.QRect(10, 30, 671, 281))
        self.txtResume.setObjectName("txtResume")
        self.butGenerate = QtWidgets.QPushButton(self.centralwidget)
        self.butGenerate.setGeometry(QtCore.QRect(390, 230, 101, 51))
        self.butGenerate.setObjectName("butGenerate")
        self.groupBox_3 = QtWidgets.QGroupBox(self.centralwidget)
        self.groupBox_3.setGeometry(QtCore.QRect(500, 10, 231, 271))
        self.groupBox_3.setObjectName("groupBox_3")
        self.label_6 = QtWidgets.QLabel(self.groupBox_3)
        self.label_6.setGeometry(QtCore.QRect(6, 30, 221, 241))
        self.label_6.setMinimumSize(QtCore.QSize(221, 0))
        self.label_6.setMaximumSize(QtCore.QSize(221, 16777215))
        self.label_6.setText("")
        self.label_6.setPixmap(QtGui.QPixmap(":/tjj.jpg"))
        self.label_6.setObjectName("label_6")
        self.label_6.setScaledContents(True)    #     
        self.groupBox = QtWidgets.QGroupBox(self.centralwidget)
        self.groupBox.setGeometry(QtCore.QRect(30, 20, 231, 201))
        self.groupBox.setObjectName("groupBox")
        self.txtName = QtWidgets.QLineEdit(self.groupBox)
        self.txtName.setGeometry(QtCore.QRect(50, 30, 151, 25))
        self.txtName.setObjectName("txtName")
        self.label = QtWidgets.QLabel(self.groupBox)
        self.label.setGeometry(QtCore.QRect(10, 32, 67, 17))
        self.label.setObjectName("label")
        self.txtRelationship = QtWidgets.QLineEdit(self.groupBox)
        self.txtRelationship.setGeometry(QtCore.QRect(50, 60, 151, 25))
        self.txtRelationship.setObjectName("txtRelationship")
        self.label_2 = QtWidgets.QLabel(self.groupBox)
        self.label_2.setGeometry(QtCore.QRect(6, 90, 67, 17))
        self.label_2.setObjectName("label_2")
        self.txtHobby = QtWidgets.QLineEdit(self.groupBox)
        self.txtHobby.setGeometry(QtCore.QRect(48, 120, 151, 25))
        self.txtHobby.setObjectName("txtHobby")
        self.txtCharacter = QtWidgets.QLineEdit(self.groupBox)
        self.txtCharacter.setGeometry(QtCore.QRect(48, 150, 151, 25))
        self.txtCharacter.setObjectName("txtCharacter")
        self.label_4 = QtWidgets.QLabel(self.groupBox)
        self.label_4.setGeometry(QtCore.QRect(6, 122, 67, 17))
        self.label_4.setObjectName("label_4")
        self.label_3 = QtWidgets.QLabel(self.groupBox)
        self.label_3.setGeometry(QtCore.QRect(6, 60, 67, 17))
        self.label_3.setObjectName("label_3")
        self.label_5 = QtWidgets.QLabel(self.groupBox)
        self.label_5.setGeometry(QtCore.QRect(6, 153, 67, 17))
        self.label_5.setObjectName("label_5")
        self.txtSpecialty = QtWidgets.QLineEdit(self.groupBox)
        self.txtSpecialty.setGeometry(QtCore.QRect(49, 90, 151, 25))
        self.txtSpecialty.setObjectName("txtSpecialty")
        self.groupBox_5 = QtWidgets.QGroupBox(self.centralwidget)
        self.groupBox_5.setGeometry(QtCore.QRect(270, 20, 221, 201))
        self.groupBox_5.setObjectName("groupBox_5")
        self.label_7 = QtWidgets.QLabel(self.groupBox_5)
        self.label_7.setGeometry(QtCore.QRect(10, 40, 67, 17))
        self.label_7.setObjectName("label_7")
        self.label_8 = QtWidgets.QLabel(self.groupBox_5)
        self.label_8.setGeometry(QtCore.QRect(10, 70, 67, 17))
        self.label_8.setObjectName("label_8")
        self.label_9 = QtWidgets.QLabel(self.groupBox_5)
        self.label_9.setGeometry(QtCore.QRect(10, 100, 67, 17))
        self.label_9.setObjectName("label_9")
        self.label_10 = QtWidgets.QLabel(self.groupBox_5)
        self.label_10.setGeometry(QtCore.QRect(10, 130, 67, 17))
        self.label_10.setObjectName("label_10")
        self.label_11 = QtWidgets.QLabel(self.groupBox_5)
        self.label_11.setGeometry(QtCore.QRect(10, 160, 67, 17))
        self.label_11.setObjectName("label_11")
        self.txtHair = QtWidgets.QLineEdit(self.groupBox_5)
        self.txtHair.setGeometry(QtCore.QRect(60, 40, 113, 25))
        self.txtHair.setObjectName("txtHair")
        self.txtHeight = QtWidgets.QLineEdit(self.groupBox_5)
        self.txtHeight.setGeometry(QtCore.QRect(60, 70, 113, 25))
        self.txtHeight.setObjectName("txtHeight")
        self.txtWeight = QtWidgets.QLineEdit(self.groupBox_5)
        self.txtWeight.setGeometry(QtCore.QRect(60, 100, 113, 25))
        self.txtWeight.setObjectName("txtWeight")
        self.txtOffice = QtWidgets.QLineEdit(self.groupBox_5)
        self.txtOffice.setGeometry(QtCore.QRect(60, 130, 113, 25))
        self.txtOffice.setObjectName("txtOffice")
        self.txtAddress = QtWidgets.QLineEdit(self.groupBox_5)
        self.txtAddress.setGeometry(QtCore.QRect(60, 160, 113, 25))
        self.txtAddress.setObjectName("txtAddress")
        self.label_14 = QtWidgets.QLabel(self.groupBox_5)
        self.label_14.setGeometry(QtCore.QRect(175, 73, 67, 17))
        self.label_14.setObjectName("label_14")
        self.label_15 = QtWidgets.QLabel(self.groupBox_5)
        self.label_15.setGeometry(QtCore.QRect(175, 101, 67, 17))
        self.label_15.setObjectName("label_15")
        MainWindow.setCentralWidget(self.centralwidget)

        self.retranslateUi(MainWindow)
        self.butGenerate.clicked.connect(MainWindow.Generate)
        QtCore.QMetaObject.connectSlotsByName(MainWindow)

    def retranslateUi(self, MainWindow):
        _translate = QtCore.QCoreApplication.translate
        MainWindow.setWindowTitle(_translate("MainWindow", "          "))
        self.groupBox_2.setTitle(_translate("MainWindow", "  :"))
        self.butGenerate.setText(_translate("MainWindow", "  "))
        self.groupBox_3.setTitle(_translate("MainWindow", "  "))
        self.groupBox.setTitle(_translate("MainWindow", "    :"))
        self.label.setText(_translate("MainWindow", "  :"))
        self.label_2.setText(_translate("MainWindow", "  :"))
        self.label_4.setText(_translate("MainWindow", "  :"))
        self.label_3.setText(_translate("MainWindow", "  :"))
        self.label_5.setText(_translate("MainWindow", "  :"))
        self.groupBox_5.setTitle(_translate("MainWindow", "  :"))
        self.label_7.setText(_translate("MainWindow", "  :"))
        self.label_8.setText(_translate("MainWindow", "  :"))
        self.label_9.setText(_translate("MainWindow", "  :"))
        self.label_10.setText(_translate("MainWindow", "  :"))
        self.label_11.setText(_translate("MainWindow", "  :"))
        self.label_14.setText(_translate("MainWindow", "m"))
        self.label_15.setText(_translate("MainWindow", "kg"))
import picture_rc
2.응용 프로그램 코드

#    
import sys
from PyQt5 import QtCore, QtGui, QtWidgets
#    
from Ui_MainWindow import Ui_MainWindow
class Cjianjie:
    hair = ""
    height = ""
    weight = ""
    office = ""
    address = ""
    bmi=0.0
    def OutputHair(self):
        strOutput = "          " + self.hair
        return strOutput
    def OutputHeight(self):
        strOutput = "       ,"+ self.height + "   "
        return strOutput
    def OutputWeight(self):
        strOutput = "     , " + self.weight + "  "
        return strOutput

    def OutputOffice(self):
        strOutput = "     " + self.office + "            ,       ,       "
        return strOutput
    def OutputAddress(self):
        strOutput = "    "  + self.address + "K41         ,          "
        return strOutput
    def OutputResume(self):
        strOutput = "    " + self.OutputHair() + ","
        strOutput = strOutput + self.OutputHeight() + ","
        strOutput = strOutput + self.OutputWeight() + ","
        strOutput = strOutput + self.OutputOffice() + "。"
        strOutput = strOutput + self.OutputAddress() + "。"
        return strOutput
class CFriend(Cjianjie):
    name = ""
    restionship = ""
    speciatly = ""
    hobby = ""
    character = ""
    def OutputName(self):
        strOutput = "              " + self.name
        return strOutput
    def OutputRestionship(self):
        strOutput = "    "+ self.restionship + ";      ,               ,             ,             " 
        return strOutput
    def OutputSpecialty(self):
        strOutput = "   " + self.speciatly + ",        ,       ,           ;    ,    "
        return strOutput
    def OutputHobby(self):
        strOutput = "  " + self.hobby + ",          ,           、  、     ,  ,              " 
        return strOutput
    def OutputCharacter(self):
        strOutput = "   " + self.character + ",      ,      ,              ,                ,   :“   !”" 
        return strOutput

    def OutputResume(self):
        strOutput= Cjianjie.OutputResume(self)
        strOutput = strOutput+ self.OutputName() + ","
        strOutput = strOutput + self.OutputRestionship() + "。"
        strOutput = strOutput + self.OutputSpecialty() + "。"
        strOutput = strOutput + self.OutputHobby() + "。"
        strOutput = strOutput + self.OutputCharacter() + "。"
        return strOutput

class CMainWindow(QtWidgets.QMainWindow, Ui_MainWindow):
    def __init__(self, parent = None):
        super(CMainWindow, self).__init__(parent)
        self.setupUi(self)

        #      
        self.show()


    def Generate(self):
        f = CFriend()
        f.hair = self.txtHair.text()
        f.height = self.txtHeight.text()
        f.weight = self.txtWeight.text()
        f.office = self.txtOffice.text()
        f.address = self.txtAddress.text()
        f.name = self.txtName.text()
        f.restionship = self.txtRelationship.text()
        f.speciatly= self.txtSpecialty.text()
        f.character= self.txtCharacter.text()
        f.hobby = self.txtHobby.text()
       
        
        self.txtResume.setText(f.OutputResume())


if __name__ == '__main__':
    app = QtWidgets.QApplication(sys.argv)
    MainWindow = CMainWindow()
    sys.exit(app.exec_())
3.비디오 재생 프로그램 이미지 및 코드

import numpy as np
import cv2 as cv
cap = cv.VideoCapture('video1.avi')
while cap.isOpened():
    ret, frame = cap.read()
    # if frame is read correctly ret is True
    if not ret:
        print("Can't receive frame (stream end?). Exiting ...")
        break
    # show gray picture
    #gray = cv.cvtColor(frame, cv.COLOR_BGR2GRAY)
    #cv.imshow('frame', gray)
    cv.imshow('frame', frame)
    if cv.waitKey(1) == ord('q'):
        break
cap.release()
cv.destroyAllWindows()
4.효 과 를 나타 낸다


파 이 썬+Pyqt 5 를 기반 으로 한 애플 리 케 이 션 개발 에 관 한 이 글 은 여기까지 소개 되 었 습 니 다.더 많은 파 이 썬+Pyqt 5 애플 리 케 이 션 내용 은 우리 의 이전 글 을 검색 하거나 아래 의 관련 글 을 계속 찾 아 보 세 요.앞으로 많은 지원 바 랍 니 다!

좋은 웹페이지 즐겨찾기