当前位置:网站首页>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]所创,转载请带上原文链接,感谢
边栏推荐
- 阿里云加速增长,进一步巩固领先优势
- 构建者模式(Builder pattern)
- The birth of a new integrated memory and computing chip is conducive to the application of artificial intelligence~
- Elasticsearch 学习一(基础入门).
- 新型存算一体芯片诞生,利好人工智能应用~
- LiteOS-消息队列-实战
- C + + things: from rice cookers to rockets, C + + is everywhere
- laravel8更新之速率限制改进
- (O)ServiceManager分析(一)之BinderInternal.getContextObject
- AI香水来了,你会买吗?
猜你喜欢

Builder pattern

京东落地DevOps平台时爆发的冲突如何解决?

Learn to record and analyze

Huawei has an absolute advantage in the 5g mobile phone market, and the market share of Xiaomi is divided by the market survey organization

DeepMind 最新论文解读:首次提出离散概率树中的因果推理算法

Awk implements SQL like join operation

Use markdown

Welcome to offer, grade P7, face-to-face sharing, 10000 words long text to take you through the interview process

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

腾讯:阿里的大中台虽好,但也不是万能的!
随机推荐
小青台正式踏上不归路的第3天
SQL 速查
LiteOS-消息队列
Arduino ide build esp8266 development environment, slow file download solution | esp-01 make WiFi switch tutorial, transform dormitory lights
Golang 系统ping程序探测存活主机(任意权限)
京东落地DevOps平台时爆发的冲突如何解决?
(O) Analysis of service manager (1) BinderInternal.getContextObject
Flink's sink: a preliminary study
“他,程序猿,35岁,被劝退”:不要只懂代码,会说话,胜过10倍默默努力
Framework - SPI four modes + general device driver implementation - source code
AI周报:允许“员工自愿降薪”;公司回应:员工内心高兴满意;虎牙HR将员工抬出公司;瑞典禁用华为中兴5G设备
Five phases of API life cycle
阿里云的MaxCompute数加(原ODPS)用的怎样?
浅谈,盘点历史上有哪些著名的电脑病毒,80%的人都不知道!
We made a medical version of the MNIST dataset, and found that the common automl algorithm is not so easy to use
(O)ServiceManager分析(一)之BinderInternal.getContextObject
Improvement of rate limit for laravel8 update
RabbitMQ之Helloworld
Mac环境安装Composer
Elasticsearch 学习一(基础入门).