-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPackagingWB.py
More file actions
75 lines (60 loc) · 2.86 KB
/
Copy pathPackagingWB.py
File metadata and controls
75 lines (60 loc) · 2.86 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# SPDX-License-Identifier: LGPL-2.1-or-later
# ***************************************************************************
# * Copyright (c) 2026 Packaging Workbench Team *
# * *
# * This file is part of the Packaging workbench for FreeCAD. *
# * *
# * This program is free software; you can redistribute it and/or modify *
# * it under the terms of the GNU Lesser General Public License (LGPL) *
# * as published by the Free Software Foundation; either version 2.1 of *
# * the License, or (at your option) any later version. *
# ***************************************************************************
"""Main implementation module for the Packaging workbench.
Kept lightweight (stdlib-only imports) so :mod:`InitGui` can import it at
startup just to resolve resource paths; the heavy command/object imports happen
lazily inside :meth:`PackagingWorkbenchManager.register_commands`.
"""
# Defer annotation evaluation so generic builtins like ``list[str]`` parse on
# any Python this code might run under, not only 3.9+.
from __future__ import annotations
import os
# Absolute path to the addon root, used to resolve resource files.
ADDON_DIR = os.path.dirname(__file__)
ICON_DIR = os.path.join(ADDON_DIR, "resources", "icons")
def icon_path(name: str) -> str:
"""Return the absolute path to an icon shipped with the workbench.
Args:
name: File name of the icon inside ``resources/icons`` (e.g.
``"Packaging.svg"``).
Returns:
Absolute filesystem path to the icon.
"""
return os.path.join(ICON_DIR, name)
class PackagingWorkbenchManager:
"""Owns command registration for the Packaging workbench.
Keeping this logic out of :mod:`InitGui` lets the GUI bootstrap stay
lightweight and makes the command set easy to unit-test without a running
GUI.
"""
def register_commands(self) -> list[str]:
"""Register all workbench commands with FreeCAD.
Imports of command modules are kept local (lazy) so this module stays
cheap to import at startup.
Returns:
The ordered list of command identifiers to place on the toolbar and
menu, in display order.
"""
from commands import (
cmd_fefco0201,
cmd_fefco0301,
cmd_fefco0713,
cmd_generate_dieline,
cmd_hello_box,
)
command_ids: list[str] = []
command_ids.append(cmd_hello_box.register())
command_ids.append(cmd_fefco0201.register())
command_ids.append(cmd_fefco0301.register())
command_ids.append(cmd_fefco0713.register())
command_ids.append(cmd_generate_dieline.register())
return command_ids