pyinstaller打包工具成品体积更小修改版

行业软件 2020-02-22 13:02:24

pyinstaller打包工具成品体积更小修改版

更新日志
只关联相关的库文件,成品体积更小了,修改后后原来的50多M减少为30M,所以修改为0.2版。

# from PyQt5.Qt import QWidget,QIcon,QTextEdit,QPushButton,QApplication
from PyQt5.QtWidgets import QWidget, QApplication, QPushButton, QTextEdit
from PyQt5.QtGui import QIcon
import sys
import os
 
 
 
class WinDow(QWidget):
 
    def __init__(self):
        super().__init__()
        self.setWindowTitle("pyinstaller_GUI-0.2")
        self.setMinimumSize(500 , 400)
        self.setMaximumSize(500 , 400)
        self.setWindowIcon(QIcon("pussy.ico"))
        self.wenjian_ui()
        self.ico_ui()
        self.anniu_ui()
        self.qingchu_ui()
 
    def wenjian_ui(self):
        wenjian = QTextEdit(self)
        self.wenjian = wenjian
        wenjian.resize(480 , 200)
        wenjian.move(10,10)
        wenjian.setPlaceholderText("请拖动py文件至此:")
 
    def ico_ui(self):
        ico = QTextEdit(self)
        self.ico = ico
        ico.resize(480 , 100)
        ico.move(10,230)
        ico.setPlaceholderText("请拖动ico文件至此:")
 
    def anniu_ui(self):
        anniu = QPushButton(self)
        self.anniu = anniu
        anniu.setText("打包生成EXE")
        anniu.move(190 , 340)
        self.anniu.clicked.connect(self.anniu_cao)
 
    def qingchu_ui(self):
        qingchu = QPushButton(self)
        self.qingchu = qingchu
        qingchu.setText("清空")
        qingchu.move(410 , 340)
        self.qingchu.clicked.connect(self.qingchu_cao)
 
 
    def anniu_cao(self):
 
        if self.ico.toPlainText() == "":
            i = "pyinstaller -F -w "
            j = self.wenjian.toPlainText()
            self.k = i + j[8:]
            shuchu = self.k
            # print(shuchu)
            os.system(shuchu)
 
        else:
            i = "pyinstaller -F -w -i "
            j = self.wenjian.toPlainText()
            h = self.ico.toPlainText()
            self.k = i + h[8:] + " " + j[8:]
            shuchu = self.k
            os.system(shuchu)
            # print(shuchu)
 
    def qingchu_cao(self):
        self.wenjian.clear()
        self.ico.clear()
 
 
if __name__ == "__main__":
 
    app = QApplication(sys.argv)
 
    window = WinDow()
 
    window.show()
 
    sys.exit(app.exec())