from pathlib import Path import bpy from .runtime import device_enum_items class SnapFormPreferences(bpy.types.AddonPreferences): bl_idname = __package__ storage_root: bpy.props.StringProperty( name="Storage Root", description=( "Shared user-writable storage for Runtime, models and jobs; " "all Blender versions can use the same directory" ), subtype="DIR_PATH", default=str(Path.home() / ".snapform"), ) device: bpy.props.EnumProperty( name="Device", description=( "Inference device used by production tasks; only devices supported " "on this machine are listed" ), items=device_enum_items, default=0, ) def draw(self, _context): from .operators import active_job from .runtime import runtime_directory, runtime_ready layout = self.layout layout.prop(self, "storage_root") layout.prop(self, "device") layout.separator() layout.label(text=f"Runtime: {runtime_directory()}") if runtime_ready(): layout.label(text="Runtime is ready", icon="CHECKMARK") else: install_row = layout.row() install_row.enabled = active_job() is None operator = install_row.operator( "snapform.run_job", text="Install Runtime", icon="IMPORT", ) operator.job_type = "INSTALL_RUNTIME" layout.separator() operator = layout.operator( "snapform.control_host", text="Open Host Log", icon="TEXT", ) operator.action = "LOG"