当前位置:网站首页>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 找出了删除我微信的所有人并将他们自动化删除了
- Hello world of rabbitmq
- 佛萨奇forsage以太坊智能合约是什么?以太坊全球滑落是怎么回事
- Don't release resources in finally, unlock a new pose!
- uni-app实战仿微信app开发
- Golang system ping program to detect the surviving host (any permission)
- 前后端分离跨域问题解决方案
- Liteos message queuing
- Arduino ide build esp8266 development environment, slow file download solution | esp-01 make WiFi switch tutorial, transform dormitory lights
- LeanCloud 十月变化
猜你喜欢
Welcome to offer, grade P7, face-to-face sharing, 10000 words long text to take you through the interview process
Leancloud changes in October
大龄程序员没有出路吗?
我们做了一个医疗版MNIST数据集,发现常见AutoML算法没那么好用
3、 The parameters of the function
One minute comprehensive understanding of forsage smart contract global shared Ethereum matrix plan
Application of four ergodic square of binary tree
Huawei has an absolute advantage in the 5g mobile phone market, and the market share of Xiaomi is divided by the market survey organization
I used Python to find out all the people who deleted my wechat and deleted them automatically
Don't release resources in finally, unlock a new pose!
随机推荐
.NET 大数据量并发解决方案
C++的那些事儿:从电饭煲到火箭,C++无处不在
一分钟全面看懂forsage智能合约全球共享以太坊矩阵计划
Don't release resources in finally, unlock a new pose!
What is forsage Ethereum smart contract? What is the global decline of Ethereum
二叉树的四种遍历方应用
2020-11-05
10 common software architecture patterns
Using k3s to create local development cluster
Rabbitmq (1) - basic introduction
Development of uni app imitating wechat app
RabbitMQ之Helloworld
Comics: looking for the best time to buy and sell stocks
On DSA of OpenGL
B站stm32视频学习
非常规聚合问题举例
Summary of template engine
Js中常见的内存泄漏场景
C + + things: from rice cookers to rockets, C + + is everywhere
Tips and skills of CSP examination