mirror of
https://github.com/muziing/Py2exe-GUI.git
synced 2025-01-27 17:02:55 +08:00
Add __all__
This commit is contained in:
parent
37e7fd48c9
commit
c83614eb17
@ -4,9 +4,5 @@
|
|||||||
"""本 package 中包含所有控件类,集中处理界面(前端)相关功能
|
"""本 package 中包含所有控件类,集中处理界面(前端)相关功能
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from .add_data_widget import AddDataWindow
|
|
||||||
from .arguments_browser import ArgumentsBrowser
|
|
||||||
from .center_widget import CenterWidget
|
|
||||||
from .dialog_widgets import *
|
|
||||||
from .main_window import MainWindow
|
from .main_window import MainWindow
|
||||||
from .subprocess_widget import SubProcessDlg
|
from .subprocess_widget import SubProcessDlg
|
||||||
|
@ -4,6 +4,8 @@
|
|||||||
"""此模块主要包含用于提供 PyInstaller `--add-data` 和 `--add-binary` 功能的窗口类 `AddDataWindow`
|
"""此模块主要包含用于提供 PyInstaller `--add-data` 和 `--add-binary` 功能的窗口类 `AddDataWindow`
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
__all__ = ["AddDataWindow"]
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import Optional
|
from typing import Optional
|
||||||
|
@ -4,6 +4,14 @@
|
|||||||
"""此模块集中处理数个对话框(QDialog)控件
|
"""此模块集中处理数个对话框(QDialog)控件
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
__all__ = [
|
||||||
|
"ScriptFileDlg",
|
||||||
|
"IconFileDlg",
|
||||||
|
"InterpreterFileDlg",
|
||||||
|
"AboutDlg",
|
||||||
|
"PkgBrowserDlg",
|
||||||
|
]
|
||||||
|
|
||||||
import warnings
|
import warnings
|
||||||
from typing import Optional
|
from typing import Optional
|
||||||
|
|
||||||
@ -153,7 +161,7 @@ class PkgBrowserDlg(QDialog):
|
|||||||
self.setLayout(main_layout)
|
self.setLayout(main_layout)
|
||||||
|
|
||||||
def load_pkg_list(self, pkg_list: list[dict[str, str]]) -> None:
|
def load_pkg_list(self, pkg_list: list[dict[str, str]]) -> None:
|
||||||
"""从后端加载包数据,存储到实例属性 pkg_list 中
|
"""从后端加载包数据,存储到实例属性 pkg_list 中,并更新界面
|
||||||
|
|
||||||
self.pkg_list 形如 [("black", "23.12.1"), ...]
|
self.pkg_list 形如 [("black", "23.12.1"), ...]
|
||||||
|
|
||||||
|
@ -6,6 +6,8 @@
|
|||||||
仅包含控件(前端界面)部分,不包含打包任务等(后端)功能
|
仅包含控件(前端界面)部分,不包含打包任务等(后端)功能
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
__all__ = ["open_url", "MainWindow"]
|
||||||
|
|
||||||
from PySide6.QtCore import QUrl
|
from PySide6.QtCore import QUrl
|
||||||
from PySide6.QtGui import QDesktopServices, QIcon, QPixmap
|
from PySide6.QtGui import QDesktopServices, QIcon, QPixmap
|
||||||
from PySide6.QtWidgets import QApplication, QLabel, QMainWindow, QMenuBar, QStatusBar
|
from PySide6.QtWidgets import QApplication, QLabel, QMainWindow, QMenuBar, QStatusBar
|
||||||
|
@ -4,6 +4,8 @@
|
|||||||
"""本模块主要包含用于选择 Python 解释器环境的下拉框控件 `PyEnvComboBox`
|
"""本模块主要包含用于选择 Python 解释器环境的下拉框控件 `PyEnvComboBox`
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
__all__ = ["PyEnvComboBox"]
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
from typing import Optional
|
from typing import Optional
|
||||||
|
|
||||||
@ -52,7 +54,7 @@ class PyEnvComboBox(QComboBox):
|
|||||||
f'Current PyEnv type "{pyenv.type}" is not instance of "PyEnvType"'
|
f'Current PyEnv type "{pyenv.type}" is not instance of "PyEnvType"'
|
||||||
)
|
)
|
||||||
|
|
||||||
data = pyenv # TODO 直接存储 PyEnv 对象是否会造成性能问题?如有,如何解决?
|
data = pyenv
|
||||||
version = pyenv.pyversion
|
version = pyenv.pyversion
|
||||||
|
|
||||||
icon_map = {
|
icon_map = {
|
||||||
|
@ -7,6 +7,8 @@
|
|||||||
`PyinstallerOptionTable` 类是用于显示 PyInstaller 命令行选项的表格控件窗口,界面有待进一步优化
|
`PyinstallerOptionTable` 类是用于显示 PyInstaller 命令行选项的表格控件窗口,界面有待进一步优化
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
__all__ = ["load_pyinst_options", "PyinstallerOptionTable"]
|
||||||
|
|
||||||
import warnings
|
import warnings
|
||||||
from typing import Optional
|
from typing import Optional
|
||||||
|
|
||||||
@ -17,8 +19,6 @@ from PySide6.QtWidgets import QHeaderView, QTableWidget, QTableWidgetItem
|
|||||||
from ..Constants import RUNTIME_INFO
|
from ..Constants import RUNTIME_INFO
|
||||||
from ..Utilities import QtFileOpen
|
from ..Utilities import QtFileOpen
|
||||||
|
|
||||||
__all__ = ["load_pyinst_options", "PyinstallerOptionTable"]
|
|
||||||
|
|
||||||
|
|
||||||
def load_pyinst_options() -> dict[str, str]:
|
def load_pyinst_options() -> dict[str, str]:
|
||||||
"""从数据文件中读取并解析 PyInstaller 命令选项信息,按运行时平台筛选后返回
|
"""从数据文件中读取并解析 PyInstaller 命令选项信息,按运行时平台筛选后返回
|
||||||
|
@ -4,6 +4,8 @@
|
|||||||
"""此模块主要包含用于呈现 PyInstaller 进程运行状态和输出的控件 `SubProcessDlg`
|
"""此模块主要包含用于呈现 PyInstaller 进程运行状态和输出的控件 `SubProcessDlg`
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
__all__ = ["SubProcessDlg"]
|
||||||
|
|
||||||
from PySide6.QtCore import Slot
|
from PySide6.QtCore import Slot
|
||||||
from PySide6.QtGui import QCloseEvent
|
from PySide6.QtGui import QCloseEvent
|
||||||
from PySide6.QtWidgets import (
|
from PySide6.QtWidgets import (
|
||||||
@ -29,7 +31,7 @@ class SubProcessDlg(QDialog):
|
|||||||
super().__init__(parent)
|
super().__init__(parent)
|
||||||
|
|
||||||
self.info_label = QLabel(self)
|
self.info_label = QLabel(self)
|
||||||
self.browser = QTextBrowser(self) # 用于显示子进程输出内容
|
self.text_browser = QTextBrowser(self) # 用于显示子进程输出内容
|
||||||
self.multifunction_btn = QPushButton(self) # 可用于“取消”“打开输出位置”等的多功能按钮
|
self.multifunction_btn = QPushButton(self) # 可用于“取消”“打开输出位置”等的多功能按钮
|
||||||
self._setup()
|
self._setup()
|
||||||
|
|
||||||
@ -38,12 +40,12 @@ class SubProcessDlg(QDialog):
|
|||||||
|
|
||||||
self.setWindowTitle("PyInstaller")
|
self.setWindowTitle("PyInstaller")
|
||||||
self.setMinimumWidth(500)
|
self.setMinimumWidth(500)
|
||||||
self.setModal(True) # 设置为模态对话框
|
self.setModal(True)
|
||||||
|
|
||||||
# 布局管理器
|
# 布局管理器
|
||||||
main_layout = QVBoxLayout()
|
main_layout = QVBoxLayout()
|
||||||
main_layout.addWidget(self.info_label)
|
main_layout.addWidget(self.info_label)
|
||||||
main_layout.addWidget(self.browser)
|
main_layout.addWidget(self.text_browser)
|
||||||
main_layout.addWidget(self.multifunction_btn)
|
main_layout.addWidget(self.multifunction_btn)
|
||||||
self.setLayout(main_layout)
|
self.setLayout(main_layout)
|
||||||
|
|
||||||
@ -53,7 +55,8 @@ class SubProcessDlg(QDialog):
|
|||||||
) -> None:
|
) -> None:
|
||||||
"""处理子进程的输出
|
"""处理子进程的输出
|
||||||
|
|
||||||
:param subprocess_output: 子进程输出,应为二元素元组,第一项为 SubProcessTool
|
:param subprocess_output: 子进程输出,应为二元素元组,第一项为 SubProcessTool.OutputType
|
||||||
|
:raise ValueError: 子进程输出的类型不正确
|
||||||
"""
|
"""
|
||||||
|
|
||||||
output_type, output_text = subprocess_output
|
output_type, output_text = subprocess_output
|
||||||
@ -62,11 +65,13 @@ class SubProcessDlg(QDialog):
|
|||||||
self.info_label.setText(output_text)
|
self.info_label.setText(output_text)
|
||||||
if output_text == "The process is running...":
|
if output_text == "The process is running...":
|
||||||
self.multifunction_btn.setText("取消")
|
self.multifunction_btn.setText("取消")
|
||||||
|
|
||||||
elif (
|
elif (
|
||||||
output_type == SubProcessTool.OutputType.STDOUT
|
output_type == SubProcessTool.OutputType.STDOUT
|
||||||
or output_type == SubProcessTool.OutputType.STDERR
|
or output_type == SubProcessTool.OutputType.STDERR
|
||||||
):
|
):
|
||||||
self.browser.append(output_text)
|
self.text_browser.append(output_text)
|
||||||
|
|
||||||
elif output_type == SubProcessTool.OutputType.FINISHED:
|
elif output_type == SubProcessTool.OutputType.FINISHED:
|
||||||
if output_text == "0":
|
if output_text == "0":
|
||||||
self.info_label.setText("打包完成!")
|
self.info_label.setText("打包完成!")
|
||||||
@ -74,12 +79,16 @@ class SubProcessDlg(QDialog):
|
|||||||
else:
|
else:
|
||||||
self.info_label.setText(f"运行结束,但有错误发生,退出码为 {output_text}")
|
self.info_label.setText(f"运行结束,但有错误发生,退出码为 {output_text}")
|
||||||
self.multifunction_btn.setText("取消")
|
self.multifunction_btn.setText("取消")
|
||||||
|
|
||||||
elif output_type == SubProcessTool.OutputType.ERROR:
|
elif output_type == SubProcessTool.OutputType.ERROR:
|
||||||
self.info_label.setText("PyInstaller错误!")
|
self.info_label.setText("PyInstaller错误!")
|
||||||
self.browser.append(f"PyInstaller 子进程输出信息:{output_text}")
|
self.text_browser.append(f"PyInstaller 子进程输出信息:{output_text}")
|
||||||
self.browser.append("请检查是否已经安装正确版本的 PyInstaller")
|
self.text_browser.append("请检查是否已经安装正确版本的 PyInstaller")
|
||||||
self.multifunction_btn.setText("关闭")
|
self.multifunction_btn.setText("关闭")
|
||||||
|
|
||||||
|
elif not isinstance(output_type, SubProcessTool.OutputType):
|
||||||
|
raise ValueError(f"不支持的输出类型:{output_type}")
|
||||||
|
|
||||||
def closeEvent(self, event: QCloseEvent) -> None:
|
def closeEvent(self, event: QCloseEvent) -> None:
|
||||||
"""重写关闭事件,进行收尾清理
|
"""重写关闭事件,进行收尾清理
|
||||||
|
|
||||||
@ -89,5 +98,5 @@ class SubProcessDlg(QDialog):
|
|||||||
# 显式发送一次 finished 信号,外部接收到此信号后应主动中断 PyInstaller 进程
|
# 显式发送一次 finished 信号,外部接收到此信号后应主动中断 PyInstaller 进程
|
||||||
self.finished.emit(-1)
|
self.finished.emit(-1)
|
||||||
|
|
||||||
self.browser.clear()
|
self.text_browser.clear()
|
||||||
super().closeEvent(event)
|
super().closeEvent(event)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user