feat: add application icon and Windows identity for V1.1.3
This commit is contained in:
1 parent
54c41d4525
commit
95c7f9b775
16 files changed
+203
-11
No files matched your search
@@ -1,14 +1,16 @@
|
||||
# DxDesigner 器件批量替换工具
|
||||
|
||||
<img src="docs/user/media/app-icon.png" width="64" height="64" alt="DxPartReplace 应用图标">
|
||||
|
||||
面向 **Windows + DxDesigner / Expedition Enterprise 7.9.5** 的器件批量替换工具。一个工程对应一个任务,可以只替换同料号下的部分位号;支持直接编辑和 Excel BOM 导入,同批工程按顺序执行。
|
||||
|
||||
**最新版本:V1.1.2** · [下载便携包](https://git.simgreek.com/simgreek/dxdesigner-part-replacement/releases/download/v1.1.2/DxPartReplace-1.1.2.zip) · [版本说明与附件](https://git.simgreek.com/simgreek/dxdesigner-part-replacement/releases/tag/v1.1.2) · [完整使用说明](docs/user/v1.1.0-project-tasks.md)
|
||||
**最新版本:V1.1.3** · [下载便携包](https://git.simgreek.com/simgreek/dxdesigner-part-replacement/releases/download/v1.1.3/DxPartReplace-1.1.3.zip) · [版本说明与附件](https://git.simgreek.com/simgreek/dxdesigner-part-replacement/releases/tag/v1.1.3) · [完整使用说明](docs/user/v1.1.0-project-tasks.md)
|
||||
|
||||
当前开发分支新增了[目标封装选择](docs/user/target-cell-selection.md):目标封装可留空,此时工具不主动覆写封装,可后续与中心库同步;需要指定时,在料号规则中读取并选择合法封装。BOM 保持原 11 列。此功能尚未打包到上面的 V1.1.2 下载包。
|
||||
本版提供[目标封装选择](docs/user/target-cell-selection.md):目标封装可留空,此时工具不主动覆写封装,可后续与中心库同步;需要指定时,在料号规则中读取并选择合法封装。BOM 保持原 11 列。
|
||||
|
||||
## 窗口操作教程
|
||||
|
||||
下面的 GIF 来自已验收 EXE 的真实窗口操作,包含创建任务、BOM 导入、错误行提示、保存、顺序执行、查看结果和开始新一轮。共 20 个步骤、47.5 秒;仅记录工具及其弹窗,CAD 等待已压缩,Excel 填表示例在录制之外完成。
|
||||
下面的 GIF 录制于 V1.1.2,操作步骤仍适用于 V1.1.3,图标与版本号以新版为准。包含创建任务、BOM 导入、错误行提示、保存、顺序执行、查看结果和开始新一轮。共 20 个步骤、47.5 秒;仅记录工具及其弹窗,CAD 等待已压缩,Excel 填表示例在录制之外完成。
|
||||
|
||||

|
||||
|
||||
@@ -51,7 +53,7 @@
|
||||
|
||||
### 3. 导入并检查报告
|
||||
|
||||
点击 **导入 BOM**,选择填好的文件。工具先校验表格格式、工程归属,以及能从表中确定的重复声明和料号冲突;通过后,只核验本表涉及的工程。已有位号库存覆盖旧料号时直接匹配;缺少库存时,会调用后台 CAD 只读采集,首次等待可能较长。
|
||||
点击 **导入 BOM**,选择填好的文件。工具先校验表格格式、工程归属,以及能从表中确定的重复声明和料号冲突;通过后,只核验本表涉及的工程。已有位号库存覆盖旧料号时直接匹配;缺少库存时优先通过原生 CLI 采集,不可用时才回退到后台 CAD 只读采集。
|
||||
|
||||
新一轮导入开始后,旧报告会清除,界面显示读表、获取库存、匹配位号等进度;取消选择文件则保留原报告。导入失败或取消会保留已有预览和手动编辑。保存和执行前仍会核验工程。
|
||||
|
||||
@@ -108,11 +110,11 @@ DxPartReplace/
|
||||
|
||||
## 验证范围与已知限制
|
||||
|
||||
V1.1.2 已完成本机冻结 EXE 验收:两个工程实际替换和独立回读、297 字符工程路径、BOM 失败/成功导入、Part Label 写入 Value、旧版任务数据副本、新轮次和自有后台资源释放。详见[成品验收报告](docs/testing/2026-10-15-packaged-acceptance.md)。
|
||||
V1.1.3 的业务代码沿用本机已验收候选:两工程实际替换和独立回读、362 字符工程路径、BOM 失败/成功导入、Part Label 写入 Value、可选封装、旧版任务数据副本、新轮次和自有后台资源释放。新增图标及版本元数据另做冻结包检查。详见[验收报告](docs/testing/2026-10-19-release-preparation.md)。
|
||||
|
||||
当前按 **evaluation-only(评估试用)** 交付。不同机器、中央库和 CAD 版本仍需用工程副本确认兼容性;替换回读通过不代表已通过 Packager、ERC 或网表检查。
|
||||
|
||||
首次采集与 CAD 启动可能需要较长时间,存在已知的偶发 COM 启动阻塞;启动有等待上限和清理机制。本次两工程执行约 4 分 19 秒,不承诺其他工程使用相同时间。长路径兼容已覆盖验证场景,不代表旧 CAD 或中央库支持任意路径。
|
||||
首次采集与 CAD 启动可能需要较长时间,存在已知的偶发 COM 启动阻塞;启动有等待上限和清理机制。验收候选的两工程执行为 167 秒;千步模拟队列为 21.09 秒,两者测量范围不同。长路径兼容已覆盖验证场景,不代表旧 CAD 或中央库支持任意路径。
|
||||
|
||||
## 开发与更多资料
|
||||
|
||||
@@ -131,4 +133,4 @@ py -3.12 -m venv .venv
|
||||
- [Value 与属性继承](docs/user/value-copy-and-layout.md)
|
||||
- [历史流程和独立 CLI 说明](docs/user/trial-task-center.md)
|
||||
- [CLI 与原生批处理集成](docs/user/part-replacement.md)
|
||||
- [V1.1.2 版本说明](docs/releases/v1.1.2.md)
|
||||
- [V1.1.3 版本说明](docs/releases/v1.1.3.md)
|
||||
@@ -0,0 +1,33 @@
|
||||
# DxPartReplace V1.1.3
|
||||
|
||||
发布日期:2026-10-19。交付级别:评估试用,与既有版本一致。
|
||||
|
||||
新增应用图标,统一 EXE、窗口、任务栏和切换窗口显示,补充 Windows 文件版本信息。本版同时发布此前已验收的可选目标封装、原生 CLI 位号采集、执行保护及队列性能优化。
|
||||
|
||||
## 下载与使用
|
||||
|
||||
完整解压 `DxPartReplace-1.1.3.zip`,运行 `DxPartReplace.exe`。无需安装 Python,本机需要可用的 DxDesigner / Expedition Enterprise 7.9.5、许可证和已配置的中央库。
|
||||
|
||||
[中文教程及 GIF](https://git.simgreek.com/simgreek/dxdesigner-part-replacement/src/tag/v1.1.3/README.md)。包内包含离线教程、默认 11 列 BOM 空表及封装使用说明。GIF 录制于 V1.1.2,步骤适用于本版,图标与版本号以本版为准。
|
||||
|
||||
## 本版变化
|
||||
|
||||
- 应用图标支持 16~256 像素,EXE 属性显示 1.1.3 版本。
|
||||
- 目标封装可留空;留空时不主动覆写 Cell Name,可后续与中心库同步。明确选择时仍核验合法性、写入和保存重开结果。
|
||||
- BOM 保持 11 列,优先使用原生 CLI 采集位号;导入报告区分通过、失败、未检查,保存前不写入计划。
|
||||
- 修复窗口销毁后后台结果回调访问已释放控件的问题;保留退出等待后台安全收尾。
|
||||
- 去掉队列中重复的路径解析与日志文件检查,保留逐步证据、fsync、原子发布和实时身份核验。
|
||||
|
||||
## 验证范围
|
||||
|
||||
业务流程沿用提交 e6ec267 的冻结候选验收:两个工程顺序替换、362 字符路径、错误及正确 BOM、保存重开、独立新 CAD 回读、层次及展开网络比对、日志窗口、新一轮、1.1.1 元数据升级和私有桌面释放均通过。仅目标 RV05 属性变化,其余 56 个器件及全部引脚、网络连接不变;原工程和中央库跟踪的 1033 个文件哈希未变。双工程执行 167 秒,千步模拟 21.09 秒,两者测量范围不同。
|
||||
|
||||
本次仅增加图标、应用身份和版本信息,另做源码构建检查、最终 ZIP 解压启动、图标与 Windows 版本资源检查。未把这些外观检查计作新一轮真实 CAD 替换。发布清单核对除 application/version 外的全部业务模块编译码及 VBS 与已验收候选一致。
|
||||
|
||||
详见[验收报告](../testing/2026-10-19-release-preparation.md)及[本版构建记录](v1.1.3-build.md)。
|
||||
|
||||
## 升级
|
||||
|
||||
关闭旧程序并备份 `data`,用本版配套的 EXE 与 `_internal` 运行,保留原数据。不同版本不要同时打开同一数据目录。中断且尚未核验的旧任务先按原流程恢复,保留日志和原始证据。
|
||||
|
||||
旧版本发布附件保持可下载。附件含 ZIP、BOM 空表、GIF、构建清单与 SHA256 校验文件;发布前逐项上传并回下载核对。
|
||||
@@ -0,0 +1,36 @@
|
||||
# V1.1.3 icon and packaging review — 2026-10-19
|
||||
|
||||
## Scope and verdict
|
||||
|
||||
Read-only review of application identity setup, icon assets/generator, package data, PyInstaller icon/data/version settings, Windows version resource, and the targeted test adjustments. No tests, CAD, Git commands, source edits, or release operations were performed. This report is the only output written.
|
||||
|
||||
**Approved for the final reviewed source/packaging design. No remaining Critical or Important findings.** The frozen-resource path issue identified during review is corrected. Final build and frozen runtime verification remain release prerequisites. The review does not invalidate the existing v1.1.2 artifact or authorize overwriting its attachments; v1.1.3 is a separate release scope.
|
||||
|
||||
## Resolved Important finding
|
||||
|
||||
### Resolve the runtime icon from a package module, not the frozen entry script directory
|
||||
|
||||
**Location:** `src/dx_productivity/trial_task_center/application.py:43`.
|
||||
|
||||
The initial `configure_application_identity` constructed `Path(__file__).parent / 'assets/app.ico'`. That works from the source package directory, but the spec supplies `application.py` as the executable's PYSOURCE entry script. PyInstaller's entry-script location differs from the data destination `_internal/dx_productivity/trial_task_center/assets/app.ico`.
|
||||
|
||||
That mismatch could leave a correct EXE/Explorer icon while the application/window QIcon is null. The final reviewed code now imports `dx_productivity.trial_task_center` and resolves the asset from that package module's `__file__`, matching both source and frozen package layouts.
|
||||
|
||||
The new regression replaces the entry module's `__file__` with a relocated script path and checks a non-null application icon and decoded 32-pixel pixmap. The retained red report records 1 failure; the green report records 9 passing application checks. Actual frozen icon/version inspection is still needed for the final artifact.
|
||||
|
||||
## Other reviewed behavior
|
||||
|
||||
- The application AppID is stable and excludes the release version: `DxProductivity.DxPartReplace`. GUI application name/version/icon setup occurs after QApplication construction and before top-level window creation.
|
||||
- Native helper, private CAD action, Cell catalog worker, and SceneOS CLI branches still return before GUI construction and identity setup. The added top-level QIcon import does not itself construct a GUI application.
|
||||
- The packaged EXE icon points directly to the source ICO. The data destination matches the package-data hierarchy. Wheel/source package-data patterns include ICO, PNG, and SVG.
|
||||
- `VERSION`, project package version, and Windows ProductVersion are 1.1.3. Windows fixed versions and FileVersion consistently use 1.1.3.0. Product/Internal/OriginalFilename strings are consistent with DxPartReplace.exe.
|
||||
- The editable SVG is a self-contained vector asset with no external references. The generator validates it, renders a transparent 512-pixel PNG, and creates a multi-size ICO. A read-only binary directory inspection confirms ten ICO sizes: 16, 20, 24, 32, 40, 48, 64, 96, 128, and 256 pixels. The icon assets exist and are nonempty. The coordinator supplied visual inspection; this reviewer did not rerender them.
|
||||
- Comparing current source files to the final v1.1.2 candidate's 101-file source manifest identifies only `application.py` and `version.py` as changed existing product modules. No replacement, Cell authority, CAD mutation, recovery, or persistence module change was found in that comparison.
|
||||
|
||||
## Tests and build evidence
|
||||
|
||||
`build/release-113-bootstrap.xml` records 14 tests, 0 failures, 0 errors. The two fake-Qt startup tests isolate identity configuration without removing the original logging/startup/smoke-close assertions. The project-task UI version assertion now follows `VERSION`; its editing/gating/persistence checks remain intact. `release-113-icon-path-red.xml` records 1 failure and `release-113-icon-path-green.xml` records 9 passes, with no errors.
|
||||
|
||||
The initial full `release-113-build.log` records 699 passes and one failure in the fake-Qt startup recovery test. Its application log identifies `AttributeError: 'Application' object has no attribute 'setApplicationName'`, rather than a recovery assertion failure. The final reviewed recovery test now isolates identity configuration while preserving the paused/failed recovery states, before/after event phases, and diagnostic-log assertions. The replacement full build is recorded separately in `release-113-build-final.log` and was still progressing when inspected. No final build or frozen runtime success is claimed here. Existing preceding-candidate TOCs were not used as v1.1.3 resource evidence.
|
||||
|
||||
Retain the new versioned release identity and verify the newly built EXE's embedded icon/version plus its running window icon before publishing v1.1.3. Business behavior remains outside this icon-only change. The user has authorized packaging/publication; this review itself performs no publication and adds no confirmation requirement.
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 24 KiB |
@@ -17,6 +17,10 @@ if viewdraw_api is None:
|
||||
raise RuntimeError("DxDesigner EE 7.9.5 type library is required for packaging")
|
||||
shutil.copyfile(viewdraw_api.__file__, generated_root / "viewdraw_api.py")
|
||||
legacy_runtime_datas = [
|
||||
(
|
||||
str(project_root / 'src/dx_productivity/trial_task_center/assets/app.ico'),
|
||||
'dx_productivity/trial_task_center/assets',
|
||||
),
|
||||
(
|
||||
str(project_root / "integration" / "dxdesigner795" / "QuickPartReplace.vbs"),
|
||||
"legacy-runtime/dxdesigner795",
|
||||
@@ -82,6 +86,8 @@ exe = EXE(
|
||||
[],
|
||||
exclude_binaries=True,
|
||||
name='DxPartReplace',
|
||||
icon=str(project_root / 'src/dx_productivity/trial_task_center/assets/app.ico'),
|
||||
version=str(project_root / 'packaging/windows-version-info.txt'),
|
||||
debug=False,
|
||||
bootloader_ignore_signals=False,
|
||||
strip=False,
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
# UTF-8
|
||||
VSVersionInfo(
|
||||
ffi=FixedFileInfo(
|
||||
filevers=(1, 1, 3, 0),
|
||||
prodvers=(1, 1, 3, 0),
|
||||
mask=0x3f,
|
||||
flags=0x0,
|
||||
OS=0x40004,
|
||||
fileType=0x1,
|
||||
subtype=0x0,
|
||||
date=(0, 0)
|
||||
),
|
||||
kids=[
|
||||
StringFileInfo([
|
||||
StringTable('040904B0', [
|
||||
StringStruct('CompanyName', 'DxProductivity'),
|
||||
StringStruct('FileDescription', 'DxDesigner Part Replacement'),
|
||||
StringStruct('FileVersion', '1.1.3.0'),
|
||||
StringStruct('InternalName', 'DxPartReplace'),
|
||||
StringStruct('OriginalFilename', 'DxPartReplace.exe'),
|
||||
StringStruct('ProductName', 'DxDesigner Part Replacement'),
|
||||
StringStruct('ProductVersion', '1.1.3')
|
||||
])
|
||||
]),
|
||||
VarFileInfo([VarStruct('Translation', [1033, 1200])])
|
||||
]
|
||||
)
|
||||
+5
-2
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
||||
|
||||
[project]
|
||||
name = "dx-productivity"
|
||||
version = "1.1.2"
|
||||
version = "1.1.3"
|
||||
requires-python = ">=3.12,<3.13"
|
||||
dependencies = ["PySide6>=6.7,<7", "pywin32>=306", "pywinauto>=0.6.9,<1", "openpyxl>=3.1,<4"]
|
||||
|
||||
@@ -13,7 +13,10 @@ dx-part-replace = "dx_productivity.part_replace.cli:main"
|
||||
dx-part-replace-gui = "dx_productivity.trial_task_center.application:main"
|
||||
|
||||
[project.optional-dependencies]
|
||||
dev = ["pytest>=8,<9", "pytest-cov>=5,<7", "coverage>=7,<8", "build>=1.2,<2", "pytest-qt>=4.4,<5", "PyInstaller>=6.10,<7"]
|
||||
dev = ["pytest>=8,<9", "pytest-cov>=5,<7", "coverage>=7,<8", "build>=1.2,<2", "pytest-qt>=4.4,<5", "PyInstaller>=6.10,<7", "Pillow>=10,<13"]
|
||||
|
||||
[tool.setuptools.package-data]
|
||||
"dx_productivity.trial_task_center" = ["assets/*.ico", "assets/*.png", "assets/*.svg"]
|
||||
|
||||
[tool.setuptools.packages.find]
|
||||
where = ["src"]
|
||||
|
||||
@@ -10,6 +10,7 @@ import sys
|
||||
from typing import Sequence
|
||||
|
||||
from PySide6.QtCore import QTimer, QThreadPool
|
||||
from PySide6.QtGui import QIcon
|
||||
from PySide6.QtWidgets import QApplication
|
||||
|
||||
from dx_productivity.trial_task_center.logging_setup import LoggingContext, configure_logging, install_exception_hooks
|
||||
@@ -28,6 +29,22 @@ def _load_window():
|
||||
return TrialTaskCenterWindow
|
||||
|
||||
|
||||
def configure_application_identity(application: QApplication) -> None:
|
||||
"""Use one stable Windows identity and icon for source and portable launches."""
|
||||
from dx_productivity import trial_task_center
|
||||
|
||||
if os.name == 'nt':
|
||||
import ctypes
|
||||
|
||||
set_app_id = ctypes.windll.shell32.SetCurrentProcessExplicitAppUserModelID
|
||||
set_app_id.argtypes = (ctypes.c_wchar_p,)
|
||||
set_app_id.restype = ctypes.c_long
|
||||
set_app_id('DxProductivity.DxPartReplace')
|
||||
application.setApplicationName('DxPartReplace')
|
||||
application.setApplicationVersion(VERSION)
|
||||
application.setWindowIcon(QIcon(str(Path(trial_task_center.__file__).parent / 'assets/app.ico')))
|
||||
|
||||
|
||||
def _parse_arguments(argv: Sequence[str] | None) -> argparse.Namespace:
|
||||
parser = argparse.ArgumentParser(prog="DxPartReplace")
|
||||
parser.add_argument("--smoke-test", action="store_true", help=argparse.SUPPRESS)
|
||||
@@ -127,6 +144,7 @@ def main(argv: Sequence[str] | None = None) -> int:
|
||||
store = TaskStore(database_path)
|
||||
service = TaskCenterService(store, logging_context)
|
||||
qt_application = QApplication([sys.executable, *(argv or ())])
|
||||
configure_application_identity(qt_application)
|
||||
window = _load_window()(service)
|
||||
window.show()
|
||||
if arguments.smoke_test:
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 48 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 24 KiB |
@@ -0,0 +1,18 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="256" height="256" viewBox="0 0 256 256">
|
||||
<defs>
|
||||
<linearGradient id="tile" x1="0" y1="0" x2="1" y2="1">
|
||||
<stop stop-color="#164D91"/>
|
||||
<stop offset="1" stop-color="#079D98"/>
|
||||
</linearGradient>
|
||||
</defs>
|
||||
<rect x="16" y="16" width="224" height="224" rx="52" fill="url(#tile)"/>
|
||||
<g fill="none" stroke="#FFFFFF" stroke-width="12" stroke-linecap="round" stroke-linejoin="round">
|
||||
<path d="M62 97V82Q62 60 84 60H184M169 46L184 60L169 74"/>
|
||||
<path d="M194 159V174Q194 196 172 196H72M87 182L72 196L87 210"/>
|
||||
</g>
|
||||
<g fill="none" stroke="#FFFFFF" stroke-width="9" stroke-linecap="round">
|
||||
<rect x="88" y="96" width="80" height="64" rx="10"/>
|
||||
<path d="M76 112H88M76 128H88M76 144H88M168 112H180M168 128H180M168 144H180"/>
|
||||
</g>
|
||||
<rect x="109" y="117" width="38" height="22" rx="5" fill="#9BF0DE"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 883 B |
@@ -1 +1 @@
|
||||
VERSION = "1.1.2"
|
||||
VERSION = "1.1.3"
|
||||
@@ -78,6 +78,7 @@ def test_main_configures_logging_before_qapplication(tmp_path: Path, monkeypatch
|
||||
monkeypatch.setattr(application, "TaskStore", Store)
|
||||
monkeypatch.setattr(application, "TaskCenterService", Service)
|
||||
monkeypatch.setattr(application, "QApplication", Application)
|
||||
monkeypatch.setattr(application, "configure_application_identity", lambda _app: None)
|
||||
monkeypatch.setattr(application, "_load_window", lambda: Window)
|
||||
|
||||
assert application.main(["--data-root", str(tmp_path)]) == 0
|
||||
@@ -118,6 +119,7 @@ def test_smoke_test_closes_window_with_zero_delay_timer_and_reopens_database(tmp
|
||||
calls.append("closed")
|
||||
|
||||
monkeypatch.setattr(application, "QApplication", Application)
|
||||
monkeypatch.setattr(application, "configure_application_identity", lambda _app: None)
|
||||
monkeypatch.setattr(application, "QTimer", Timer)
|
||||
monkeypatch.setattr(application, "_load_window", lambda: Window)
|
||||
|
||||
@@ -177,3 +179,13 @@ def test_application_module_runs_as_a_script_for_the_frozen_entrypoint(tmp_path:
|
||||
|
||||
assert result.returncode == 0, result.stderr
|
||||
assert "application_clean_shutdown" in (tmp_path / "logs" / "application.log").read_text(encoding="utf-8")
|
||||
|
||||
|
||||
def test_icon_uses_package_location_for_frozen_script_entrypoint(tmp_path, monkeypatch, qapp):
|
||||
from dx_productivity.trial_task_center import application
|
||||
|
||||
monkeypatch.setattr(application, '__file__', str(tmp_path / 'application.py'))
|
||||
application.configure_application_identity(qapp)
|
||||
assert not qapp.windowIcon().isNull()
|
||||
assert not qapp.windowIcon().pixmap(32, 32).isNull()
|
||||
assert qapp.applicationVersion() == application.VERSION
|
||||
@@ -52,7 +52,8 @@ def test_original_window_edits_target_plan_and_nc_without_export(qtbot, tmp_path
|
||||
qtbot.addWidget(window)
|
||||
window.open_task(task.task_id)
|
||||
qtbot.waitUntil(lambda: not window._loading and not window._context_query.busy)
|
||||
assert '1.1.2' in window.windowTitle()
|
||||
from dx_productivity.trial_task_center.version import VERSION
|
||||
assert VERSION in window.windowTitle()
|
||||
table = window.plan_panel.table
|
||||
table.model().setData(table.model().index(0, 0), Qt.CheckState.Checked, Qt.ItemDataRole.CheckStateRole)
|
||||
table.model().setData(table.model().index(0, 9), Qt.CheckState.Unchecked, Qt.ItemDataRole.CheckStateRole)
|
||||
|
||||
@@ -51,6 +51,7 @@ def test_application_restart_preserves_before_and_after_recovery_events(tmp_path
|
||||
pass
|
||||
|
||||
monkeypatch.setattr(application, 'QApplication', Application)
|
||||
monkeypatch.setattr(application, 'configure_application_identity', lambda _app: None)
|
||||
monkeypatch.setattr(application, '_load_window', lambda: Window)
|
||||
assert application.main(['--data-root', str(tmp_path)]) == 0
|
||||
events = [json.loads(line) for line in (tmp_path / 'tasks' / task.task_id / 'events.jsonl').read_text().splitlines()]
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
"""Render the editable SVG into the runtime PNG and Windows multi-size ICO."""
|
||||
from io import BytesIO
|
||||
from pathlib import Path
|
||||
|
||||
from PIL import Image
|
||||
from PySide6.QtCore import QBuffer, QIODevice, Qt
|
||||
from PySide6.QtGui import QImage, QPainter
|
||||
from PySide6.QtSvg import QSvgRenderer
|
||||
|
||||
|
||||
def main():
|
||||
assets = Path(__file__).resolve().parents[1] / 'src/dx_productivity/trial_task_center/assets'
|
||||
renderer = QSvgRenderer(str(assets / 'app.svg'))
|
||||
if not renderer.isValid():
|
||||
raise ValueError('Invalid application icon SVG')
|
||||
canvas = QImage(512, 512, QImage.Format.Format_ARGB32)
|
||||
canvas.fill(Qt.GlobalColor.transparent)
|
||||
painter = QPainter(canvas)
|
||||
try:
|
||||
renderer.render(painter)
|
||||
finally:
|
||||
painter.end()
|
||||
buffer = QBuffer()
|
||||
buffer.open(QIODevice.OpenModeFlag.WriteOnly)
|
||||
if not canvas.save(buffer, 'PNG'):
|
||||
raise OSError('Cannot render application icon')
|
||||
payload = bytes(buffer.data())
|
||||
(assets / 'app.png').write_bytes(payload)
|
||||
with Image.open(BytesIO(payload)) as image:
|
||||
image.save(assets / 'app.ico', sizes=[(n, n) for n in (16, 20, 24, 32, 40, 48, 64, 96, 128, 256)])
|
||||
print(assets / 'app.ico')
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
Reference in new issue
Block a user