diff --git a/Python_Engine/Python/pyproject.toml b/Python_Engine/Python/pyproject.toml index 6a0be4e..6db0bd6 100644 --- a/Python_Engine/Python/pyproject.toml +++ b/Python_Engine/Python/pyproject.toml @@ -16,6 +16,7 @@ dependencies = [ "pytest-cov>=6.0.0", "pytest-order", "virtualenv", + "pythonnet", ] [urls] diff --git a/Python_Engine/Python/src/python_toolkit/bhom/__init__.py b/Python_Engine/Python/src/python_toolkit/bhom/__init__.py index 4933adf..e3ab0b2 100644 --- a/Python_Engine/Python/src/python_toolkit/bhom/__init__.py +++ b/Python_Engine/Python/src/python_toolkit/bhom/__init__.py @@ -6,10 +6,15 @@ import tempfile import importlib.metadata +if os.name == 'nt': + from .installer_info import INSTALLER_INFO +else: + INSTALLER_INFO = {"Version": importlib.metadata.version("python_toolkit")} + BHOM_LOG_FOLDER = Path(path.expandvars("%PROGRAMDATA%/BHoM/Logs")) TEMP_LOG_FOLDER = Path(tempfile.gettempdir()) / "BHoM" / "Logs" TOOLKIT_NAME = "Python_Toolkit" -BHOM_VERSION = importlib.metadata.version("python_toolkit") +BHOM_VERSION = INSTALLER_INFO["Version"] #Environment variable that if set disables BHoM analytics logging. DISABLE_ANALYTICS = os.environ.get("DISABLE_BHOM_ANALYTICS", None) @@ -33,3 +38,4 @@ BHOM_LOG_FOLDER.mkdir(exist_ok=True, parents=True) + diff --git a/Python_Engine/Python/src/python_toolkit/bhom/installer_info.py b/Python_Engine/Python/src/python_toolkit/bhom/installer_info.py new file mode 100644 index 0000000..10f1b76 --- /dev/null +++ b/Python_Engine/Python/src/python_toolkit/bhom/installer_info.py @@ -0,0 +1,17 @@ +import os +import sys +import json + +import clr + +#append assemblies dir +sys.path.append(os.path.expandvars("%ProgramData%\\BHoM\\Assemblies")) + +#add required CLR references (dotnet dlls) +clr.AddReference("UI_Engine") +clr.AddReference("Serialiser_Engine") + +from BH.Engine.UI import Query +from BH.Engine.Serialiser import Convert + +INSTALLER_INFO = json.loads(Convert.ToJson(Query.Information())) \ No newline at end of file diff --git a/Python_Engine/Python/src/python_toolkit/bhom_tkinter/bhom_window_shell.py b/Python_Engine/Python/src/python_toolkit/bhom_tkinter/bhom_window_shell.py index 0b922bb..25c6d3a 100644 --- a/Python_Engine/Python/src/python_toolkit/bhom_tkinter/bhom_window_shell.py +++ b/Python_Engine/Python/src/python_toolkit/bhom_tkinter/bhom_window_shell.py @@ -12,6 +12,8 @@ from python_toolkit.bhom_tkinter.widgets.button import Button from python_toolkit.bhom_tkinter.theming.theme import ThemeManager +from python_toolkit.bhom import BHOM_VERSION + class BHoMWindowShell: """Shared themed window chrome for BHoM Tk root and Toplevel windows.""" @@ -323,7 +325,7 @@ def _build_banner(self, parent: ttk.Frame, title: str, logo_path: Optional[Path] # Subtitle subtitle_label = Label( text_container, - text="powered by BHoM", + text=f"powered by BHoM (v{BHOM_VERSION})", style="Caption.TLabel" ) subtitle_label.pack(anchor="w")