zoukankan      html  css  js  c++  java
  • pyinstall pyqt image

    首先新建一个 .qrcimages.qrc 文件,内容格式如下:

    <RCC>
        <qresource prefix="/" >
            <file>fire.png</file>
        </qresource>
    </RCC>
    

    in the Terminal:

    pyrcc4 -o images_qr.py images.qrc
    

    inner_image.py

    #!/usr/bin/env python
    # _*_ coding: utf-8 _*_
    # @Time     : 2017/3/30 13:00
    # @Author   : otfsenter
    # @File     : inner_img.py
    
    import sys
    from PyQt4 import QtGui, QtCore
    import images_qr
    
    class Example(QtGui.QWidget):
    
        def __init__(self):
            super(Example, self).__init__()
    
            self.initUI()
    
        def initUI(self):
    
            hbox = QtGui.QHBoxLayout(self)
            # 创建图片控件,使用图片的文件名作为参数
            # The colon is important, it must be there
            pixmap = QtGui.QPixmap(':/fire.png')
    
            # 将图片控件放入标签控件中
            lbl = QtGui.QLabel(self)
            lbl.setPixmap(pixmap)
    
            hbox.addWidget(lbl)
            self.setLayout(hbox)
    
            self.move(300, 200)
            self.setWindowTitle('Pixmap')
            self.show()
    
    def main():
    
        app = QtGui.QApplication(sys.argv)
        ex = Example()
        sys.exit(app.exec_())
    
    
    if __name__ == '__main__':
        main()
    
  • 相关阅读:
    USACO 3.3 A Game
    USACO 3.3 Camelot
    USACO 3.3 Shopping Offers
    USACO 3.3 TEXT Eulerian Tour中的Cows on Parade一点理解
    USACO 3.3 Riding the Fences
    USACO 3.2 Magic Squares
    USACO 3.2 Stringsobits
    USACO 3.2 Factorials
    USACO 3.2 Contact
    USACO 3.1 Humble Numbers
  • 原文地址:https://www.cnblogs.com/otfsenter/p/6384703.html
Copyright © 2011-2022 走看看