mitk.PropertyList#

class mitk.PropertyList#

Bases: pybind11_object

Standalone, owning collection of typed properties.

A PropertyList is a dict-like structure that maps str keys to BaseProperty subclass values. Unlike the property view on an Image, every property in a PropertyList is owned (writable).

The properties accessor returns a mitk.property_view.PropertyView for 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 PropertyList from a dict produced by to_dict().

from_json(json)

Reconstruct a property list from JSON.

get_property(self, key[, raw])

Return the property value for key, or None if 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 dict keyed by property name.

to_json(self)

Serialize this property list to a self-contained JSON string.

Attributes

properties

Live, mutable view of the list's properties.

property_keys

List of all property keys currently stored.

static from_dict(d: dict) mitk.PropertyList#

Reconstruct a PropertyList from a dict produced by to_dict().

Parameters:

d – Dict mapping property names to property dicts.

Returns:

A new PropertyList with 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 None if not set.

By default returns a coerced Python-native value (bool, int, float, str, or (r, g, b) tuple for color properties). Pass raw=True to always get the underlying mitk.BaseProperty object.

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, a MutableMapping suitable for dict-style access.

property_is_owned(self: mitk.PropertyList, key: str) bool#

Return True if key exists in the list.

PropertyList owns every property it stores, so this is equivalent to key 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 BaseProperty subtype (see mitk.Image.set_property() for the type mapping).

to_dict(self: mitk.PropertyList) dict#

Serialize all properties to a Python dict keyed 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().