mitk.PropertyList#
- class mitk.PropertyList#
Bases:
pybind11_objectStandalone, owning collection of typed properties.
A
PropertyListis a dict-like structure that mapsstrkeys toBasePropertysubclass values. Unlike the property view on anImage, every property in aPropertyListis owned (writable).The
propertiesaccessor returns amitk.property_view.PropertyViewfor ergonomic dict-style use.- __init__(self: mitk.PropertyList) None#
Construct an empty property list.
Methods
__init__(self)Construct an empty property list.
from_dict(d)Reconstruct a
PropertyListfrom a dict produced byto_dict().from_json(json)Reconstruct a property list from JSON.
get_property(self, key[, raw])Return the property value for key, or
Noneif not set.property_is_owned(self, key)Return True if key exists in the list.
remove_property(self, key)Remove the property key if it exists.
set_property(self, key, value)Set the property key to value.
to_dict(self)Serialize all properties to a Python
dictkeyed by property name.to_json(self)Serialize this property list to a self-contained JSON string.
Attributes
Live, mutable view of the list's properties.
List of all property keys currently stored.
- static from_dict(d: dict) mitk.PropertyList#
Reconstruct a
PropertyListfrom a dict produced byto_dict().- Parameters:
d – Dict mapping property names to property dicts.
- Returns:
A new
PropertyListwith the properties from d.
- static from_json(json: str) mitk.PropertyList#
Reconstruct a property list from JSON.
- Parameters:
json – JSON string produced by
to_json().
- get_property(self: mitk.PropertyList, key: str, raw: bool = False) object#
Return the property value for key, or
Noneif not set.By default returns a coerced Python-native value (
bool,int,float,str, or(r, g, b)tuple for color properties). Passraw=Trueto always get the underlyingmitk.BasePropertyobject.- Parameters:
key – Property name.
raw – Return the underlying property object instead of a coerced Python value. Defaults to False.
- property properties#
Live, mutable view of the list’s properties.
Returns a
mitk.property_view.PropertyView, aMutableMappingsuitable for dict-style access.
- property_is_owned(self: mitk.PropertyList, key: str) bool#
Return True if key exists in the list.
PropertyListowns every property it stores, so this is equivalent tokey in pl.properties.
- property property_keys#
List of all property keys currently stored.
- remove_property(self: mitk.PropertyList, key: str) None#
Remove the property key if it exists.
- set_property(self: mitk.PropertyList, key: str, value: object) None#
Set the property key to value.
The value is auto-wrapped into the appropriate
BasePropertysubtype (seemitk.Image.set_property()for the type mapping).
- to_dict(self: mitk.PropertyList) dict#
Serialize all properties to a Python
dictkeyed by property name.Each value is itself a dict describing the property’s type and content, matching the format consumed by
property_from_dict().
- to_json(self: mitk.PropertyList) str#
Serialize this property list to a self-contained JSON string.
The string carries type information for every property so the list can be fully reconstructed with
from_json().