当前位置:网站首页>Simple process of reading pictures by QT program developed by Python
Simple process of reading pictures by QT program developed by Python
2020-11-08 16:17:00 【Spiritual】
python Development qt The simple flow of the program
One . python install pyqt5
pip install pyqt5 -i https://mirrors.aliyun.com/pypi/simple
Two . install qt designer( Design generation program interface ui)
Download address
( official )https://build-system.fman.io/qt-designer-download
(csdn)https://download.csdn.net/download/qq_26696715/13094628
( Add group download )686070107
3、 ... and . Use qt designer Design generation ui file
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>Dialog</class>
<widget class="QDialog" name="Dialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>635</width>
<height>511</height>
</rect>
</property>
<property name="windowTitle">
<string>Dialog</string>
</property>
<widget class="QPushButton" name="pushButton">
<property name="geometry">
<rect>
<x>20</x>
<y>10</y>
<width>81</width>
<height>31</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>12</pointsize>
<weight>75</weight>
<bold>true</bold>
</font>
</property>
<property name="text">
<string> Select Picture </string>
</property>
</widget>
<widget class="QLabel" name="label">
<property name="geometry">
<rect>
<x>20</x>
<y>70</y>
<width>581</width>
<height>401</height>
</rect>
</property>
<property name="text">
<string/>
</property>
<property name="pixmap">
<pixmap>img/1.tif</pixmap>
</property>
<property name="scaledContents">
<bool>true</bool>
</property>
</widget>
</widget>
<resources/>
<connections/>
</ui>
Four . take ui File conversion to py file
pyuic5 -o ui.py ui.ui
5、 ... and . To write main.py A file called ui.py file
# -*- coding: utf-8 -*-
import sys
import time
from PyQt5.QtCore import *
from PyQt5.QtGui import *
from PyQt5.QtWidgets import *
import numpy as np
import cv2
import qimage2ndarray
from ui import Ui_Dialog
class mwindow(QWidget, Ui_Dialog):
def __init__(self):
super(mwindow, self).__init__()
self.setupUi(self)
# Select Picture
def openimage(self):
# Select Picture
imgName, imgType = QFileDialog.getOpenFileName(self, " Open the picture ", "img", "*.jpg;*.tif;*.png;;All Files(*)")
if imgName=="":
return 0
#qt5 Read the picture
jpg = QPixmap(imgName).scaled(self.label.width(), self.label.height())
# Show the original
self.label.setPixmap(jpg)
if __name__ == '__main__':
app=QApplication(sys.argv)
# Initialize window
m=mwindow()
# Bind button event
m.pushButton.clicked.connect(m.openimage)# Select Picture
m.show()
sys.exit(app.exec_())
6、 ... and . function main.py file
python main.py
There is a problem adding QQ Group :686070107
版权声明
本文为[Spiritual]所创,转载请带上原文链接,感谢
边栏推荐
猜你喜欢
我用 Python 找出了删除我微信的所有人并将他们自动化删除了
Arduino ide build esp8266 development environment, slow file download solution | esp-01 make WiFi switch tutorial, transform dormitory lights
技术总监7年总结,如何进行正确的沟通?
Talking about, check the history of which famous computer viruses, 80% of the people do not know!
wanxin finance
[open source]. Net uses ORM to access Huawei gaussdb database
Don't release resources in finally, unlock a new pose!
Flink's sink: a preliminary study
浅谈,盘点历史上有哪些著名的电脑病毒,80%的人都不知道!
laravel8更新之维护模式改进
随机推荐
How does Alibaba cloud's maxcompute add (original ODPs) work?
SQL quick query
DeepMind 最新论文解读:首次提出离散概率树中的因果推理算法
CSP考试须知与各种小技巧
使用K3S创建本地开发集群
实验
[open source]. Net uses ORM to access Huawei gaussdb database
RestfulApi 学习笔记——父子资源(四)
小米、OPPO在欧洲市场继续飙涨,小米更是直逼苹果
我用 Python 找出了删除我微信的所有人并将他们自动化删除了
华为在5G手机市场占据绝对优势,市调机构对小米的市占出现分歧
Travel notes of Suzhou
laravel8更新之维护模式改进
Improvement of rate limit for laravel8 update
Mac环境安装Composer
C + + things: from rice cookers to rockets, C + + is everywhere
模板引擎的整理归纳
Talk about go code coverage technology and best practices
实验
Summary of rendering of water wave and caustics (etching) in webgl