介绍


例子

创建


1#encoding: utf-8
2import sys
3
4from PyQt5.QtWidgets import QMainWindow, QApplication, QPushButton
5from PyQt5.QtWidgets import QLCDNumber, QLabel, QVBoxLayout, QHBoxLayout
6from PyQt5.QtGui import QPixmap
7from PyQt5.QtCore import QDate, Qt, QRect
8
9
10class Example(QMainWindow):
11    def __init__(self):
12        super().__init__()
13        self.initUI()
14
15    def initUI(self):
16        hbox = QHBoxLayout(self)
17        pixmap = QPixmap("computer.png")
18
19        lbl = QLabel(self)
20        lbl.setPixmap(pixmap)
21
22        hbox.addWidget(lbl)
23        hbox.setGeometry(QRect(0, 0, 600, 550))
24        self.setLayout(hbox)
25
26        self.setGeometry(300, 300, 600, 600)
27        self.setWindowTitle('Image View')
28        self.show()
29
30if __name__ == '__main__':
31    app = QApplication(sys.argv)
32    ex = Example()
33    sys.exit(app.exec_())
#encoding: utf-8

import sys



from PyQt5.QtWidgets import QMainWindow, QApplication, QPushButton

from PyQt5.QtWidgets import QLCDNumber, QLabel, QVBoxLayout, QHBoxLayout

from PyQt5.QtGui import QPixmap

from PyQt5.QtCore import QDate, Qt, QRect





class Example(QMainWindow):

    def __init__(self):

        super().__init__()

        self.initUI()



    def initUI(self):

        hbox = QHBoxLayout(self)

        pixmap = QPixmap("computer.png")



        lbl = QLabel(self)

        lbl.setPixmap(pixmap)



        hbox.addWidget(lbl)

        hbox.setGeometry(QRect(0, 0, 600, 550))

        self.setLayout(hbox)



        self.setGeometry(300, 300, 600, 600)

        self.setWindowTitle('Image View')

        self.show()



if __name__ == '__main__':

    app = QApplication(sys.argv)

    ex = Example()

    sys.exit(app.exec_())


如果有任何问题请发邮件到 isteps@126.com


广告内容, 如果不忙, 跪求点击