Source code for fastpyxl.worksheet.controls

# Copyright (c) 2010-2024 fastpyxl

from fastpyxl.typed_serialisable.base import Serialisable
from fastpyxl.typed_serialisable.fields import Field
from fastpyxl.xml.constants import REL_NS

from .ole import ObjectAnchor


[docs] class ControlProperty(Serialisable): tagname = "controlPr" anchor: ObjectAnchor | None = Field.element(expected_type=ObjectAnchor, allow_none=True, default=None) locked: bool | None = Field.attribute(expected_type=bool, allow_none=True, default=None) defaultSize: bool | None = Field.attribute(expected_type=bool, allow_none=True, default=None) _print: bool | None = Field.attribute(expected_type=bool, allow_none=True, xml_name="print", default=None) disabled: bool | None = Field.attribute(expected_type=bool, allow_none=True, default=None) recalcAlways: bool | None = Field.attribute(expected_type=bool, allow_none=True, default=None) uiObject: bool | None = Field.attribute(expected_type=bool, allow_none=True, default=None) autoFill: bool | None = Field.attribute(expected_type=bool, allow_none=True, default=None) autoLine: bool | None = Field.attribute(expected_type=bool, allow_none=True, default=None) autoPict: bool | None = Field.attribute(expected_type=bool, allow_none=True, default=None) macro: str | None = Field.attribute(expected_type=str, allow_none=True, default=None) altText: str | None = Field.attribute(expected_type=str, allow_none=True, default=None) linkedCell: str | None = Field.attribute(expected_type=str, allow_none=True, default=None) listFillRange: str | None = Field.attribute(expected_type=str, allow_none=True, default=None) cf: str | None = Field.attribute(expected_type=str, allow_none=True, default=None) id: str | None = Field.attribute(expected_type=str, allow_none=True, namespace=REL_NS, default=None) xml_order = ("anchor",) def __init__(self, anchor=None, locked=True, defaultSize=True, _print=True, disabled=False, recalcAlways=False, uiObject=False, autoFill=True, autoLine=True, autoPict=True, macro=None, altText=None, linkedCell=None, listFillRange=None, cf='pict', id=None, ): self.anchor = anchor self.locked = locked self.defaultSize = defaultSize self._print = _print self.disabled = disabled self.recalcAlways = recalcAlways self.uiObject = uiObject self.autoFill = autoFill self.autoLine = autoLine self.autoPict = autoPict self.macro = macro self.altText = altText self.linkedCell = linkedCell self.listFillRange = listFillRange self.cf = cf self.id = id
[docs] class Control(Serialisable): tagname = "control" controlPr: ControlProperty | None = Field.element(expected_type=ControlProperty, allow_none=True, default=None) shapeId: int | None = Field.attribute(expected_type=int, allow_none=True, default=None) name: str | None = Field.attribute(expected_type=str, allow_none=True, default=None) xml_order = ("controlPr",) def __init__(self, controlPr=None, shapeId=None, name=None, ): self.controlPr = controlPr self.shapeId = shapeId self.name = name
[docs] class Controls(Serialisable): tagname = "controls" control: list[Control] = Field.sequence(expected_type=Control, default=list) xml_order = ("control",) def __init__(self, control=(), ): self.control = list(control)