当前位置:网站首页>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]所创,转载请带上原文链接,感谢
边栏推荐
- markdown使用
- “他,程序猿,35岁,被劝退”:不要只懂代码,会说话,胜过10倍默默努力
- TypeScript(1-2-2)
- The birth of a new integrated memory and computing chip is conducive to the application of artificial intelligence~
- 构建者模式(Builder pattern)
- C + + things: from rice cookers to rockets, C + + is everywhere
- Arduino IDE搭建ESP8266开发环境,文件下载过慢解决方法 | ESP-01制作WiFi开关教程,改造宿舍灯
- How does the system response time and throughput change with the increase of concurrency pressure during performance pressure testing
- When to write disk IO after one byte of write file
- How to cooperate with people in software development? |Daily anecdotes
猜你喜欢

学习记录并且简单分析

I used Python to find out all the people who deleted my wechat and deleted them automatically

How to cooperate with people in software development? |Daily anecdotes

Arduino IDE搭建ESP8266开发环境,文件下载过慢解决方法 | ESP-01制作WiFi开关教程,改造宿舍灯

Examples of unconventional aggregation

小青台正式踏上不归路的第3天

我用 Python 找出了删除我微信的所有人并将他们自动化删除了

Design by contract (DBC) and its application in C language

刚刚好,才是最理想的状态

Talking about, check the history of which famous computer viruses, 80% of the people do not know!
随机推荐
write文件一个字节后何时发起写磁盘IO
AI周报:允许“员工自愿降薪”;公司回应:员工内心高兴满意;虎牙HR将员工抬出公司;瑞典禁用华为中兴5G设备
实验
Talk about go code coverage technology and best practices
wanxin finance
构建者模式(Builder pattern)
. net large data concurrency solution
我用 Python 找出了删除我微信的所有人并将他们自动化删除了
Hello world of rabbitmq
Mac环境安装Composer
Drink soda, a bottle of soda water 1 yuan, two empty bottles can change a bottle of soda, give 20 yuan, how much soda can you
Your random IO hard disk
Jsliang job series - 07 - promise
新型存算一体芯片诞生,利好人工智能应用~
打工人,打工魂,抽终身会员,成为人上人!
How to make a correct summary for 7 years?
小米、OPPO在欧洲市场继续飙涨,小米更是直逼苹果
One minute comprehensive understanding of forsage smart contract global shared Ethereum matrix plan
习题五
聊聊Go代码覆盖率技术与最佳实践