Update pkg_browser_dlg

将 PkgBrowserDlg 的实例从 hidden_import_dlg 中移出到 CenterWidget 中;
为涉及模块添加 `__all__`;
This commit is contained in:
muzing 2023-12-31 21:28:22 +08:00
parent 6f4966cff1
commit 3b98417164
2 changed files with 21 additions and 6 deletions

View File

@ -9,6 +9,8 @@ WinMacCenterWidget 继承自 CenterWidget额外添加了仅 Windows 和 macOS
PyInstaller 功能所对应的控件及其槽函数
"""
__all__ = ["CenterWidget", "WinMacCenterWidget"]
from pathlib import Path
from PySide6 import QtCore
@ -32,7 +34,12 @@ from ..Core import InterpreterValidator
from ..Utilities import PyEnv
from .add_data_widget import AddDataWindow
from .arguments_browser import ArgumentsBrowser
from .dialog_widgets import IconFileDlg, InterpreterFileDlg, ScriptFileDlg
from .dialog_widgets import (
IconFileDlg,
InterpreterFileDlg,
PkgBrowserDlg,
ScriptFileDlg,
)
from .multi_item_edit_widget import MultiPkgEditWindow
from .pyenv_combobox import PyEnvComboBox
from .pyinstaller_option_widget import load_pyinst_options
@ -62,6 +69,9 @@ class CenterWidget(QWidget):
# 读取PyInstaller选项详细描述用于各控件ToolTip
self.option_dict = load_pyinst_options() # TODO 待优化:避免重复加载
# 展示已安装的包
self.pkg_browser_dlg = PkgBrowserDlg()
# 待打包的入口脚本
self.script_path_label = QLabel()
self.script_file_dlg = ScriptFileDlg()
@ -93,7 +103,7 @@ class CenterWidget(QWidget):
# 添加隐式导入
self.hidden_import_btn = QPushButton()
self.hidden_import_dlg = MultiPkgEditWindow()
self.hidden_import_dlg = MultiPkgEditWindow(self.pkg_browser_dlg)
self.hidden_import_list: list[str] = []
# 清理缓存与临时文件
@ -297,8 +307,6 @@ class CenterWidget(QWidget):
pyenv_layout = QHBoxLayout()
pyenv_layout.addWidget(self.pyenv_combobox)
pyenv_layout.addWidget(self.pyenv_browse_btn)
pyenv_layout.setStretchFactor(self.pyenv_combobox, 3)
pyenv_layout.setStretchFactor(self.pyenv_browse_btn, 1)
name_layout = QVBoxLayout()
name_layout.addWidget(self.project_name_label)

View File

@ -8,6 +8,8 @@
`MultiPkgEditWindow` 继承自 `MultiItemEditWindow`多了一个浏览当前 Python 环境中已安装 Python 包的功能
"""
__all__ = ["MultiItemEditWindow", "MultiPkgEditWindow"]
from typing import Optional
from PySide6.QtCore import Qt, Signal, Slot
@ -165,13 +167,18 @@ class MultiPkgEditWindow(MultiItemEditWindow):
并将包名作为条目添加的功能
"""
def __init__(self, parent: Optional[QWidget] = None) -> None:
def __init__(
self, pkg_browser_dlg: PkgBrowserDlg, parent: Optional[QWidget] = None
) -> None:
"""
:param pkg_browser_dlg: PkgBrowserDlg 实例用于显示已安装包的列表
:param parent: 父控件对象
"""
# TODO 新增一种可以由用户选中的已安装包浏览器,并替代目前的 PkgBrowserDlg
self.browse_pkg_button = QPushButton()
self.pkg_browser_dlg = PkgBrowserDlg()
self.pkg_browser_dlg = pkg_browser_dlg
super().__init__(parent)
def _setup_ui(self) -> None: