基于Python+Pyqt5开发一个应用程序
程序员文章站
2022-04-06 22:28:44
介绍你的那个她/他1. ui —mainwindow设计界面及代码# -*- coding: utf-8 -*-# form implementation generated from reading...
介绍你的那个她/他
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. 呈现效果
到此这篇关于基于python+pyqt5开发一个应用程序的文章就介绍到这了,更多相关python+pyqt5应用程序内容请搜索以前的文章或继续浏览下面的相关文章希望大家以后多多支持!
推荐阅读
-
分享一个基于Net Core 3.1开发的模块化的项目
-
一个基于 .NET Core 2.0 开发的简单易用的快速开发框架 - LinFx
-
基于MUI框架+HTML5PLUS 开发 iOS和Android 应用程序(APP)
-
利用VS Code开发你的第一个AngularJS 2应用程序
-
一个基于原生JavaScript开发的、轻量的验证码生成插件
-
基于Swift的iOS应用程序开发:使用UIImagePickerController调取摄像头进行拍照
-
Vular开发手记#1:设计并实现一个拼插式应用程序框架
-
如何开发一个基于Vue的ui组件库
-
编写一个基于 UDP 的文件收发软件,用来将文件发送给开发板。
-
这篇文章教你开发一个Python桌面应用程序 Pythontelerikwiforms