2019-03-05 最简单的图片显示

#!/usr/bin/python3

# -*- coding: utf-8 -*-

"""

显示图片于窗口中

#pixmap.py

"""

from PyQt5.QtWidgetsimport (QWidget, QHBoxLayout,QLabel, QApplication)

from PyQt5.QtGuiimport QPixmap

import sys

import cv2

class Example(QWidget):

def __init__(self):

super().__init__()

self.initUI()

def initUI(self):

hbox = QHBoxLayout(self)

pixmap = QPixmap("d002.jpg")

# self.img = cv2.imread( "d002.jpg" )

        lbl = QLabel(self)

lbl.setPixmap(pixmap)

hbox.addWidget( lbl )

self.setLayout(hbox)

self.move(300,200)

self.setWindowTitle('Red Rock' )

self.show()

if __name__ =='__main__':

app = QApplication(sys.argv)

ex = Example()

sys.exit(app.exec_())

你可能感兴趣的:(2019-03-05 最简单的图片显示)