PYQT基于label导入图片

#!/usr/bin/python
# coding=gbk
import sys, os, datetime,glob,csv
from ippt import Ui_MainWindow
from PyQt5.QtWidgets import QApplication, QMainWindow,QTableWidget,QTableWidgetItem,QHeaderView

#from sqlalchemy import create_engine




# import tab
# from PyQt5 import QtCore, QtGui, QtWidgets
from PyQt5.QtWidgets import QApplication, QMainWindow
from PyQt5 import QtWidgets, QtCore, QtGui


# from PyQt5 import QtCore, QtGui, QtWidgets
class win(QMainWindow, Ui_MainWindow):  ##QMainWindow要导入,Ui_MainWindow对应jk.ui的类名

    def __init__(self):

        super(win, self).__init__()

        self.setupUi(self)

        png = QtGui.QPixmap('.\\ph\\DC.jpg')
        p1 = self.label
        p1.setPixmap(png)
        self.label.setScaledContents(True)#set picture


if __name__ == '__main__':
    app = QApplication(sys.argv)
    # MainWindow = QMainWindow()
    w = win()
    w.show()
    # ui = Ui_MainWindow()
    # ui.setupUi(MainWindow)
    # MainWindow.show()
    sys.exit(app.exec_())

你可能感兴趣的:(PYTHON,python)