diff --git a/pyproject.toml b/pyproject.toml index a857ffb..753e8f2 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "py2exe-gui" -version = "0.2.1" +version = "0.3.0" description = "GUI for PyInstaller, based on PySide6" keywords = ["PyInstaller", "GUI", "PySide6"] authors = ["muzing "] @@ -9,7 +9,7 @@ readme = ["README.md", "README_zh.md"] repository = "https://github.com/muziing/Py2exe-GUI" exclude = ["src/py2exe_gui/Resources/Icons", "src/py2exe_gui/Resources/Texts"] classifiers = [ - "Development Status :: 3 - Alpha", + "Development Status :: 4 - Beta", "Operating System :: Microsoft :: Windows", "Operating System :: POSIX :: Linux", "Operating System :: MacOS" diff --git a/src/py2exe_gui/Constants/app_constants.py b/src/py2exe_gui/Constants/app_constants.py index 37798ce..ecce7d0 100644 --- a/src/py2exe_gui/Constants/app_constants.py +++ b/src/py2exe_gui/Constants/app_constants.py @@ -24,7 +24,7 @@ class AppConstant: """应用程序级的常量""" NAME = "Py2exe-GUI" - VERSION = "0.2.1" + VERSION = "0.3.0" AUTHORS = ["muzing "] LICENSE = "GPL-3.0-or-later" HOME_PAGE = APP_URLs["HOME_PAGE"] diff --git a/src/py2exe_gui/Widgets/arguments_browser.py b/src/py2exe_gui/Widgets/arguments_browser.py index 7bd490a..12ac2f8 100644 --- a/src/py2exe_gui/Widgets/arguments_browser.py +++ b/src/py2exe_gui/Widgets/arguments_browser.py @@ -4,9 +4,12 @@ """此模块主要包含用于在界面上预览显示 PyInstaller 命令选项的 `ArgumentsBrowser` 类 """ +__all__ = ["get_line_continuation", "ArgumentsBrowser"] + from typing import Optional -from PySide6.QtWidgets import QTextBrowser, QWidget +from PySide6.QtGui import QContextMenuEvent +from PySide6.QtWidgets import QMenu, QTextBrowser, QWidget from ..Constants import RUNTIME_INFO, Platform @@ -53,20 +56,48 @@ class ArgumentsBrowser(QTextBrowser): super().__init__(parent) + # 右键菜单 + self.context_menu = QMenu(self) + copy_action = self.context_menu.addAction("复制") + copy_action.triggered.connect(self._handle_copy_action) + export_action = self.context_menu.addAction("导出") + export_action.triggered.connect(self._handle_export_action) + + def contextMenuEvent(self, event: QContextMenuEvent) -> None: + """重写右键菜单事件 + + :param event: 事件 + """ + + self.context_menu.exec(event.globalPos()) + + def _handle_copy_action(self) -> None: + """处理复制事件""" + + # TODO 实现复制到系统剪切板 + self.copy() + + def _handle_export_action(self) -> None: + """处理导出事件""" + + # TODO 实现到处到 PowerShell/Bash 脚本 + pass + def enrich_args_text(self, args_list: list[str]) -> None: """对参数进行一定高亮美化后显示 :param args_list: 参数列表 """ - enriched_arg_texts: list[str] = [ - wrap_font_tag(args_list[0], color=colors[4]) - ] # 首个参数一定为待打包的 Python 脚本名 + # 不间断换行(续行)符 + line_continuation = get_line_continuation() + "
" + (" " * 4) + + # 首个参数一定为待打包的 Python 脚本名 + enriched_arg_texts: list[str] = [wrap_font_tag(args_list[0], color=colors[4])] + for arg in args_list[1:]: if arg.startswith("--") or arg.startswith("-"): - enriched_arg_texts.append( - get_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) diff --git a/src/py2exe_gui/__init__.py b/src/py2exe_gui/__init__.py index 86cb39b..0aec820 100644 --- a/src/py2exe_gui/__init__.py +++ b/src/py2exe_gui/__init__.py @@ -7,4 +7,4 @@ designed to provide a complete yet easy-to-use GUI for PyInstaller. HomePage: https://github.com/muziing/Py2exe-GUI """ -__version__ = "0.2.1" +__version__ = "0.3.0"