mirror of
https://github.com/muziing/Py2exe-GUI.git
synced 2025-01-13 16:42:54 +08:00
Reformat code with black
This commit is contained in:
parent
b60e774a3b
commit
641c142e9a
@ -39,7 +39,10 @@ def export_requirements() -> int:
|
||||
print(f"poetry export 进程错误:{e}")
|
||||
raise e
|
||||
else:
|
||||
print(f"已将当前项目依赖导出至 requirements.txt,poetry export 返回码:{result.returncode}")
|
||||
print(
|
||||
"已将当前项目依赖导出至 requirements.txt,"
|
||||
f"poetry export 返回码:{result.returncode}"
|
||||
)
|
||||
return result.returncode
|
||||
|
||||
|
||||
|
@ -42,19 +42,19 @@ class PackagingTask(QtCore.QObject):
|
||||
# 保存打包时使用的 Python 环境
|
||||
self.pyenv: Optional[PyEnv] = None
|
||||
|
||||
# 保存所有参数值,None表示未设置
|
||||
# 保存所有参数值,None 表示未设置
|
||||
self.using_option: dict[PyInstOpt, Any] = {value: None for value in PyInstOpt}
|
||||
# TODO: 设法为值补充类型注解
|
||||
|
||||
# self.script_path: Optional[Path] = None
|
||||
# self.icon_path: Optional[Path] = None
|
||||
# self.add_data_list: Optional[list[AddDataWindow.data_item]] = None
|
||||
# self.add_binary_list: Optional[list[AddDataWindow.data_item]] = None
|
||||
# self.out_name: Optional[str] = None
|
||||
# self.FD: Optional[bool] = None
|
||||
# self.console: Optional[str] = None
|
||||
# self.hidden_import: Optional[list[str]] = None
|
||||
# self.clean: Optional[bool] = None
|
||||
# self.using_option = {
|
||||
# PyInstOpt.script_path: Path,
|
||||
# PyInstOpt.icon_path: Path,
|
||||
# PyInstOpt.FD: bool,
|
||||
# PyInstOpt.console: str,
|
||||
# PyInstOpt.out_name: str,
|
||||
# PyInstOpt.add_data: list[tuple[Path, str]],
|
||||
# PyInstOpt.add_binary: list[tuple[Path, str]],
|
||||
# PyInstOpt.hidden_import: list[str],
|
||||
# PyInstOpt.clean: bool,
|
||||
# }
|
||||
|
||||
@QtCore.Slot(tuple)
|
||||
def on_opt_selected(self, option: tuple[PyInstOpt, Any]) -> None:
|
||||
@ -73,7 +73,8 @@ class PackagingTask(QtCore.QObject):
|
||||
self.using_option[PyInstOpt.script_path] = script_path
|
||||
self.ready_to_pack.emit(True)
|
||||
self.option_set.emit(option)
|
||||
self.using_option[PyInstOpt.out_name] = script_path.stem # 输出名默认与脚本名相同
|
||||
# 输出名默认与脚本名相同
|
||||
self.using_option[PyInstOpt.out_name] = script_path.stem
|
||||
self.option_set.emit((PyInstOpt.out_name, script_path.stem))
|
||||
else:
|
||||
self.ready_to_pack.emit(False)
|
||||
|
@ -87,7 +87,9 @@ class SubProcessTool(QObject):
|
||||
self._connect_signals()
|
||||
self._process.setWorkingDirectory(self._working_directory)
|
||||
self._process.start(self.program, self._arguments, mode)
|
||||
return self._process.waitForStarted(time_out) # 阻塞,直到成功启动子进程或超时
|
||||
return self._process.waitForStarted(
|
||||
time_out
|
||||
) # 阻塞,直到成功启动子进程或超时
|
||||
return False
|
||||
|
||||
def abort_process(self, timeout: int = 5000) -> bool:
|
||||
@ -99,7 +101,9 @@ class SubProcessTool(QObject):
|
||||
|
||||
if self._process:
|
||||
self._process.terminate()
|
||||
is_finished = self._process.waitForFinished(timeout) # 阻塞,直到进程终止或超时
|
||||
is_finished = self._process.waitForFinished(
|
||||
timeout
|
||||
) # 阻塞,直到进程终止或超时
|
||||
if not is_finished:
|
||||
self._process.kill() # 超时后杀死子进程
|
||||
return is_finished
|
||||
|
@ -29,7 +29,8 @@ class AddDataWindow(QObjTr, QWidget):
|
||||
"""用于提供 PyInstaller --add-data 和 --add-binary 功能的窗口"""
|
||||
|
||||
# 类型别名
|
||||
data_item = tuple[Path, str] # 数据条目,第一项为在文件系统中的路径,第二项为捆绑后环境中的路径
|
||||
# 数据条目,第一项为在文件系统中的路径,第二项为捆绑后环境中的路径
|
||||
data_item = tuple[Path, str]
|
||||
|
||||
# 自定义信号
|
||||
data_selected = Signal(list) # 用户在添加数据窗口完成所有编辑后,提交的信号
|
||||
|
@ -78,13 +78,13 @@ class ArgumentsBrowser(QObjTr, QTextBrowser):
|
||||
def _handle_copy_action(self) -> None:
|
||||
"""处理复制事件"""
|
||||
|
||||
# TODO 实现复制到系统剪切板
|
||||
self.selectAll()
|
||||
self.copy()
|
||||
|
||||
def _handle_export_action(self) -> None:
|
||||
"""处理导出事件"""
|
||||
|
||||
# TODO 实现到处到 PowerShell/Bash 脚本
|
||||
# TODO 实现导出至 PowerShell/Bash 脚本
|
||||
pass
|
||||
|
||||
def enrich_args_text(self, args_list: list[str]) -> None:
|
||||
@ -93,7 +93,7 @@ class ArgumentsBrowser(QObjTr, QTextBrowser):
|
||||
:param args_list: 参数列表
|
||||
"""
|
||||
|
||||
# 不间断换行(续行)符
|
||||
# 不间断换行
|
||||
line_continuation = get_line_continuation() + "<br>" + (" " * 4)
|
||||
|
||||
# 首个参数一定为待打包的 Python 脚本名
|
||||
@ -101,7 +101,8 @@ class ArgumentsBrowser(QObjTr, QTextBrowser):
|
||||
|
||||
for arg in args_list[1:]:
|
||||
if arg.startswith("--") or arg.startswith("-"):
|
||||
enriched_arg_texts.append(line_continuation) # 添加换行,便于阅读与复制导出脚本
|
||||
# 添加换行,便于阅读与复制导出脚本
|
||||
enriched_arg_texts.append(line_continuation)
|
||||
enriched_arg_texts.append(wrap_font_tag(arg, color=colors[1]))
|
||||
else:
|
||||
enriched_arg_texts.append(arg)
|
||||
|
@ -65,7 +65,9 @@ class MainWindow(QObjTr, QMainWindow):
|
||||
"""配置主窗口菜单栏"""
|
||||
|
||||
file_menu = self.menu_bar.addMenu(MainWindow.tr("&File"))
|
||||
file_menu.addAction(MainWindow.tr("Import Config From JSON File")) # 暂时只为占位
|
||||
file_menu.addAction(
|
||||
MainWindow.tr("Import Config From JSON File")
|
||||
) # 暂时只为占位
|
||||
file_menu.addAction(MainWindow.tr("Export Config To JSON File")) # 暂时只为占位
|
||||
file_menu.addSeparator()
|
||||
file_menu.addAction(MainWindow.tr("&Settings")) # 暂时只为占位
|
||||
|
@ -33,7 +33,8 @@ from .dialog_widgets import PkgBrowserDlg
|
||||
class MultiItemEditWindow(QObjTr, QWidget):
|
||||
"""用于添加多个条目的窗口控件,实现如 --hidden-import、--collect-submodules 等功能"""
|
||||
|
||||
items_selected = Signal(list) # 用户在添加条目窗口完成所有编辑后,提交的信号.完整数据类型为 list[str]
|
||||
# 用户在添加条目窗口完成所有编辑后,提交的信号.完整数据类型为 list[str]
|
||||
items_selected = Signal(list)
|
||||
|
||||
def __init__(self, parent: Optional[QWidget] = None) -> None:
|
||||
"""
|
||||
|
@ -33,7 +33,8 @@ class SubProcessDlg(QObjTr, QDialog):
|
||||
|
||||
self.info_label = QLabel(self)
|
||||
self.text_browser = QTextBrowser(self) # 用于显示子进程输出内容
|
||||
self.multifunction_btn = QPushButton(self) # 可用于“取消”“打开输出位置”等的多功能按钮
|
||||
# 可用于“取消”“打开输出位置”等的多功能按钮
|
||||
self.multifunction_btn = QPushButton(self)
|
||||
self._setup()
|
||||
|
||||
def _setup(self) -> None:
|
||||
|
Loading…
x
Reference in New Issue
Block a user