#!/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_())
网友评论