37,721
社区成员
发帖
与我相关
我的任务
分享
from PyQt5 import QtGui
pixmap2 = QtGui.QPixmap("xxx.jpg")
# coding:utf-8
import sys
from PyQt4 import QtGui, QtCore
class Example(QtGui.QWidget):
def __init__(self):
super(Example, self).__init__()
self.initUI()
def initUI(self):
hbox = QtGui.QHBoxLayout(self)
#这里改你要显示的图片
pixmap = QtGui.QPixmap("d:/1.png")
lbl = QtGui.QLabel(self)
lbl.setPixmap(pixmap)
hbox.addWidget(lbl)
self.setLayout(hbox)
self.move(300, 200)
self.setWindowTitle(u'测试显示图片')
self.show()
def main():
app = QtGui.QApplication(sys.argv)
ex = Example()
sys.exit(app.exec_())
if __name__ == '__main__':
main()