mirror of
https://github.com/muziing/Py2exe-GUI.git
synced 2025-01-13 16:42:54 +08:00
Update ArgumentsBrowser
更新 `ArgumentsBrowser`: 将显示的PyInstaller命令参数从列表转换为字符串,用户可直接复制字符串到终端中运行或保存为脚本; 添加命令行换行,提高命令可读性;
This commit is contained in:
parent
538c43330d
commit
cd177cbba8
@ -5,11 +5,13 @@ from typing import Optional
|
|||||||
|
|
||||||
from PySide6.QtWidgets import QTextBrowser, QWidget
|
from PySide6.QtWidgets import QTextBrowser, QWidget
|
||||||
|
|
||||||
|
from ..Constants import get_line_continuation
|
||||||
|
|
||||||
# 一组适合浅色背景的颜色
|
# 一组适合浅色背景的颜色
|
||||||
colors = ["#FD6D5A", "#FEB40B", "#6DC354", "#994487", "#518CD8", "#443295"]
|
colors = ["#FD6D5A", "#FEB40B", "#6DC354", "#994487", "#518CD8", "#443295"]
|
||||||
|
|
||||||
|
|
||||||
def wrap_font_tag(raw_text: str, color: str, **kwargs):
|
def wrap_font_tag(raw_text: str, *, color: str, **kwargs):
|
||||||
"""
|
"""
|
||||||
辅助函数,用于为字符添加<font>标签包裹,属性可通过可变关键字参数传入 \n
|
辅助函数,用于为字符添加<font>标签包裹,属性可通过可变关键字参数传入 \n
|
||||||
:param raw_text: 原始字符文本
|
:param raw_text: 原始字符文本
|
||||||
@ -40,11 +42,16 @@ class ArgumentsBrowser(QTextBrowser):
|
|||||||
:param args_list: 参数列表
|
:param args_list: 参数列表
|
||||||
"""
|
"""
|
||||||
|
|
||||||
text: list[str] = [wrap_font_tag(args_list[0], colors[4])]
|
enriched_arg_texts: list[str] = [
|
||||||
|
wrap_font_tag(args_list[0], color=colors[4])
|
||||||
|
] # 首个参数一定为待打包的 Python 脚本名
|
||||||
for arg in args_list[1:]:
|
for arg in args_list[1:]:
|
||||||
if arg.startswith("--") or arg.startswith("-"):
|
if arg.startswith("--") or arg.startswith("-"):
|
||||||
text.append(wrap_font_tag(arg, colors[1]))
|
enriched_arg_texts.append(
|
||||||
|
get_line_continuation() + "<br>"
|
||||||
|
) # 添加换行,便于阅读与复制导出脚本
|
||||||
|
enriched_arg_texts.append(wrap_font_tag(arg, color=colors[1]))
|
||||||
else:
|
else:
|
||||||
text.append(arg)
|
enriched_arg_texts.append(arg)
|
||||||
|
|
||||||
self.setText(str(text))
|
self.setText("pyinstaller " + " ".join(enriched_arg_texts))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user