pic_scanner.gui.models.element_bases.column

Classes

FrozenProperty

A descriptor class that restricts the setting of a property based on type, value, and custom conditions.

AutoBuildMeta

Metaclass for classes that should build themselves upon instantiation when the auto_build

Column

A class for building a PySimpleGUI Column.

Functions

freeze_property(cls)

Module Contents

class pic_scanner.gui.models.element_bases.column.FrozenProperty(*args, **kwargs)

Bases: inspyre_toolbox.syntactic_sweets.properties.RestrictedSetter

A descriptor class that restricts the setting of a property based on type, value, and custom conditions.

This class is designed to be used as a descriptor for class properties, allowing for the definition of restrictions on the setting of the property. These restrictions can include type checking, value checking, and custom conditions that must be met for the property to be set. If any of the restrictions are violated, an exception is raised.

The RestrictedSetter class also allows for the definition of an initial value for the property, which is used if the property has not been set. This can be useful for defining default values for properties.

Notes

  • If a preferred_type is specified, the value will be converted to that type if possible. If the value cannot be converted to the preferred type, a TypeError will be raised.

  • If a custom condition is specified, the condition must be met for the property to be set. If the condition is not met, an UnmetConditionError will be raised.

  • If an exception is specified, it will be raised instead of the default UnmetConditionError if the custom condition is not met.

  • If allowed_values is specified, the value must be in the set of allowed values for the property to be set. If the value is not in the set, a ValueError will be raised.

  • If restrict_setter is set to True, the setter can only be called within class methods. If the setter is called outside of class methods, a PermissionError will be raised.

pic_scanner.gui.models.element_bases.column.freeze_property(cls)
class pic_scanner.gui.models.element_bases.column.AutoBuildMeta

Bases: abc.ABCMeta

Metaclass for classes that should build themselves upon instantiation when the auto_build attribute is True.

This metaclass overrides the __call__ method to build the instance if the auto_build attribute is True.

class pic_scanner.gui.models.element_bases.column.Column(column_key: str, auto_build=False)

A class for building a PySimpleGUI Column.

This class is used to build a PySimpleGUI Column. It is a subclass of the AutoBuildMeta metaclass.

Properties:
auto_build (bool):

A boolean value that determines whether the class should automatically build itself when instantiated. This is set to False by default. This property is read-only.

building (bool):

A boolean value that determines whether the class is currently building itself. This is set to False by default.

column (psg.Column):

The PySimpleGUI Column object. This is built from the layout, and will only have a value if the class is built.

column_key (str):

The key for the column. This is used to identify the column in the layout. It is set to None by default, and after instantiation it is frozen and cannot be changed.

is_built (bool):

A boolean value that determines whether the class has been built.

layout (list):

A list of elements that make up the layout of the class. This is used to build the column, and is set to an empty list by default.

Parameters:

column_key (str)

column_key
property auto_build: bool

Returns the value of the auto_build attribute.

The auto_build attribute is a boolean value that determines whether the class should automatically build itself when instantiated.

Return type:

bool

abstract build()
property building
Returns the value of the `building` attribute.

The building attribute is a boolean value that determines whether the class is currently building itself.

Returns:

The value of the building attribute.

Return type:

bool

property column
Returns the column.

The column is built from the layout, and will only have a value if the class is built; otherwise it will be None.

Returns:

The column.

Return type:

psg.Column

property layout
Returns the layout.

The layout is a list of elements that make up the layout of the class. This is used to build the column, and is set to an empty list by default.

Returns:

The layout.

Return type:

list

property is_built
Returns whether the class has been built.
Returns:

True if the class has been built, False otherwise.

Return type:

bool