Class CellControl
- class ooodev.calc.controls.cell_control.CellControl(calc_obj, lo_inst=None)[source]
Bases:
SheetControlBase
A partial class for a cell control.
- add_event_observers(*args)
Adds observers that gets their
trigger
method called when this classtrigger
method is called.- Parameters:
args (EventObserver) – One or more observers to add.
- Return type:
None
Note
Observers are removed automatically when they are out of scope.
- insert_control_button(label='', *, name='', styles=None)
Inserts a button control into sheet.
By Default the button has tab stop and does focus on click.
- Parameters:
label (str, optional) – Button label (text).
name (str, optional) – Name of control. Must be a unique name. If empty, a unique name is generated.
styles (Iterable[StyleT], optional) – One or more styles to apply to the control shape.
- Returns:
Button Control
- Return type:
- insert_control_check_box(label='', *, name='', tri_state=True, state=TriStateKind.NOT_CHECKED, border=BorderKind.BORDER_3D, styles=None)
Inserts a check box control into the sheet.
- Parameters:
label (str, optional) – Label (text) to assign to checkbox.
name (str, optional) – Name of control. Must be a unique name. If empty, a unique name is generated.
tri_state (TriStateKind, optional) – Specifies that the control may have the state “don’t know”. Defaults to
True
.state (TriStateKind, optional) – Specifies the state of the control.Defaults to
TriStateKind.CHECKED
.border (BorderKind, optional) – Border option. Defaults to
BorderKind.BORDER_3D
.styles (Iterable[StyleT], optional) – One or more styles to apply to the control shape.
- Returns:
Checkbox Control
- Return type:
Hint
BorderKind
can be imported fromooodev.utils.kind.border_kind
.TriStateKind
can be imported fromooodev.utils.kind.tri_state_kind
.
- insert_control_combo_box(*, name='', entries=None, max_text_len=0, drop_down=True, read_only=False, border=BorderKind.BORDER_3D, styles=None)
Inserts a ComboBox control into the sheet.
- Parameters:
name (str, optional) – Name of control. Must be a unique name. If empty, a unique name is generated.
entries (Iterable[str], optional) – Combo box entries
tri_state (TriStateKind, optional) – Specifies that the control may have the state “don’t know”. Defaults to
True
.state (TriStateKind, optional) – Specifies the state of the control.Defaults to
TriStateKind.CHECKED
.max_text_len (int, optional) – Specifies the maximum character count, There’s no limitation, if set to 0. Defaults to
0
.drop_down (bool, optional) – Specifies if the control has a drop down button. Defaults to
True
.read_only (bool, optional) – Specifies that the content of the control cannot be modified by the user. Defaults to
False
.border (BorderKind, optional) – Border option. Defaults to
BorderKind.BORDER_3D
.styles (Iterable[StyleT], optional) – One or more styles to apply to the control shape.
- Returns:
ComboBox Control
- Return type:
Hint
BorderKind
can be imported fromooodev.utils.kind.border_kind
.
- insert_control_currency_field(*, name='', min_value=-1000000.0, max_value=1000000.0, spin_button=False, increment=1, accuracy=2, border=BorderKind.BORDER_3D, styles=None)
Inserts a currency field control into the sheet.
- Parameters:
name (str, optional) – Name of control. Must be a unique name. If empty, a unique name is generated.
min_value (float, optional) – Specifies the smallest value that can be entered in the control. Defaults to
-1000000.0
.max_value (float, optional) – Specifies the largest value that can be entered in the control. Defaults to
1000000.0
.spin_button (bool, optional) – When
True
, a spin button is present. Defaults toFalse
.increment (int, optional) – The step when the spin button is pressed. Defaults to
1
.accuracy (int, optional) – Specifies the decimal accuracy. Default is
2
decimal digitsborder (BorderKind, optional) – Border option. Defaults to
BorderKind.BORDER_3D
.styles (Iterable[StyleT], optional) – One or more styles to apply to the control shape.
- Returns:
Currency Field Control
- Return type:
Hint
BorderKind
can be imported fromooodev.utils.kind.border_kind
.
- insert_control_date_field(*, name='', min_date=datetime.datetime(1900, 1, 1, 0, 0), max_date=datetime.datetime(2200, 12, 31, 0, 0), drop_down=True, date_format=DateFormatKind.SYSTEM_SHORT, border=BorderKind.BORDER_3D, styles=None)
Inserts a Date field control into the form.
- Parameters:
name (str, optional) – Name of control. Must be a unique name. If empty, a unique name is generated.
date_value (datetime.datetime | None, optional) – Specifics control datetime. Defaults to
None
.min_date (datetime.datetime, optional) – Specifics control min datetime. Defaults to
datetime(1900, 1, 1, 0, 0, 0, 0)
.max_date (datetime.datetime, optional) – Specifics control Min datetime. Defaults to
datetime(2200, 12, 31, 0, 0, 0, 0)
.drop_down (bool, optional) – Specifies if the control is a dropdown. Defaults to
True
.date_format (DateFormatKind, optional) – Date format. Defaults to
DateFormatKind.SYSTEM_SHORT
.border (BorderKind, optional) – Border option. Defaults to
BorderKind.BORDER_3D
.styles (Iterable[StyleT], optional) – One or more styles to apply to the control shape.
- Returns:
Date Field Control
- Return type:
Hint
BorderKind
can be imported fromooodev.utils.kind.border_kind
.DateFormatKind
can be imported fromooodev.utils.kind.date_format_kind
.
- insert_control_file(*, name='', styles=None)
Inserts a file control.
- Parameters:
name (str, optional) – Name of control. Must be a unique name. If empty, a unique name is generated.
styles (Iterable[StyleT], optional) – One or more styles to apply to the control shape.
- Returns:
File Control.
- Return type:
- insert_control_formatted_field(*, name='', min_value=-1000000.0, max_value=1000000.0, spin_button=False, border=BorderKind.BORDER_3D, styles=None)
Inserts a currency field control into the form.
- Parameters:
name (str, optional) – Name of control. Must be a unique name. If empty, a unique name is generated.
min_value (float, optional) – Specifies the smallest value that can be entered in the control. Defaults to
-1000000.0
.max_value (float, optional) – Specifies the largest value that can be entered in the control. Defaults to
1000000.0
.spin_button (bool, optional) – When
True
, a spin button is present. Defaults toFalse
.border (BorderKind, optional) – Border option. Defaults to
BorderKind.BORDER_3D
.styles (Iterable[StyleT], optional) – One or more styles to apply to the control shape.
- Returns:
Currency Field Control.
- Return type:
Hint
BorderKind
can be imported fromooodev.utils.kind.border_kind
.
- insert_control_grid(label='', *, name='', styles=None)
Inserts a Grid control.
- Parameters:
name (str, optional) – Name of control. Must be a unique name. If empty, a unique name is generated.
label (str, optional) – Grid label.
styles (Iterable[StyleT], optional) – One or more styles to apply to the control shape.
- Returns:
Grid Control
- Return type:
- insert_control_group_box(label='', *, name='', styles=None)
Inserts a Groupbox control into the form.
- Parameters:
label (str, optional) – Groupbox label.
name (str, optional) – Name of control. Must be a unique name. If empty, a unique name is generated.
styles (Iterable[StyleT], optional) – One or more styles to apply to the control shape.
- Returns:
Groupbox Control
- Return type:
- insert_control_image_button(image_url='', *, name='', border=BorderKind.BORDER_3D, styles=None)
Inserts an Image Button control into the form.
- Parameters:
image_url (PathOrStr, optional) – Image URL. When setting the value it can be a string or a Path object. If a string is passed it can be a URL or a path to a file. Value such as
file:///path/to/image.png
and/path/to/image.png
are valid. Relative paths are supported.name (str, optional) – Name of control. Must be a unique name. If empty, a unique name is generated.
border (BorderKind, optional) – Border option. Defaults to
BorderKind.BORDER_3D
.styles (Iterable[StyleT], optional) – One or more styles to apply to the control shape.
- Returns:
Image Button Control.
- Return type:
Hint
BorderKind
can be imported fromooodev.utils.kind.border_kind
.
- insert_control_label(label, *, name='', styles=None)
Inserts a Label control.
- Parameters:
label (str) – Contents of label.
name (str, optional) – Name of control. Must be a unique name. If empty, a unique name is generated.
styles (Iterable[StyleT], optional) – One or more styles to apply to the control shape.
- Returns:
Label Control.
- Return type:
- insert_control_list_box(*, entries=None, name='', drop_down=True, read_only=False, line_count=5, multi_select=False, border=BorderKind.BORDER_3D, styles=None)
Inserts a ListBox control into the form.
- Parameters:
entries (Iterable[str], optional) – Combo box entries
name (str, optional) – Name of control. Must be a unique name. If empty, a unique name is generated.
drop_down (bool, optional) – Specifies if the control has a drop down button. Defaults to
True
.read_only (bool, optional) – Specifies that the content of the control cannot be modified by the user. Defaults to
False
.line_count (int, optional) – Specifies the number of lines to display. Defaults to
5
.multi_select (int, optional) – Specifies if multiple entries can be selected. Defaults to
False
.border (BorderKind, optional) – Border option. Defaults to
BorderKind.BORDER_3D
.styles (Iterable[StyleT], optional) – One or more styles to apply to the control shape.
- Returns:
ListBox Control.
- Return type:
Hint
BorderKind
can be imported fromooodev.utils.kind.border_kind
.
- insert_control_numeric_field(*, name='', min_value=-1000000.0, max_value=1000000.0, spin_button=False, increment=1, accuracy=2, border=BorderKind.BORDER_3D, styles=None)
Inserts a Numeric field control into the form.
- Parameters:
name (str, optional) – Name of control. Must be a unique name. If empty, a unique name is generated.
min_value (float, optional) – Specifies the smallest value that can be entered in the control. Defaults to
-1000000.0
.max_value (float, optional) – Specifies the largest value that can be entered in the control. Defaults to
1000000.0
.spin_button (bool, optional) – When
True
, a spin button is present. Defaults toFalse
.increment (int, optional) – The step when the spin button is pressed. Defaults to
1
.accuracy (int, optional) – Specifies the decimal accuracy. Default is
2
decimal digitsborder (BorderKind, optional) – Border option. Defaults to
BorderKind.BORDER_3D
.anchor_type (TextContentAnchorType, optional) – Control Anchor Type. Defaults to
TextContentAnchorType.AT_PARAGRAPH
styles (Iterable[StyleT], optional) – One or more styles to apply to the control shape.
- Returns:
Numeric Field Control.
- Return type:
Hint
BorderKind
can be imported fromooodev.utils.kind.border_kind
.
- insert_control_pattern_field(*, name='', edit_mask='', literal_mask='', border=BorderKind.BORDER_3D, styles=None)
Inserts a Pattern field control into the form.
- Parameters:
name (str, optional) – Name of control. Must be a unique name. If empty, a unique name is generated.
edit_mask (str, optional) – Specifies a character code that determines what the user may enter. Defaults to
""
.literal_mask (str, optional) – Specifies the initial values that are displayed in the pattern field. Defaults to
""
.border (BorderKind, optional) – Border option. Defaults to
BorderKind.BORDER_3D
.anchor_type (TextContentAnchorType, optional) – Control Anchor Type. Defaults to
TextContentAnchorType.AT_PARAGRAPH
styles (Iterable[StyleT], optional) – One or more styles to apply to the control shape.
- Returns:
Pattern Field Control.
- Return type:
Hint
BorderKind
can be imported fromooodev.utils.kind.border_kind
.
- insert_control_radio_button(label='', *, state=StateKind.NOT_CHECKED, multiline=False, border=BorderKind.NONE, name='', styles=None)
Inserts a radio button control into the form.
- Parameters:
label (str, optional) – Label (text) of control.
tri_state (StateKind, optional) – Specifies that the control may have the state “don’t know”. Defaults to
True
.state (StateKind, optional) – Specifies the state of the control.Defaults to
StateKind.NOT_CHECKED
.multiline (bool, optional) – Specifies if the control can display multiple lines of text. Defaults to
False
.border (BorderKind, optional) – Border option. Defaults to
BorderKind.NONE
.anchor_type (TextContentAnchorType, optional) – Control Anchor Type. Defaults to
TextContentAnchorType.AT_PARAGRAPH
name (str, optional) – Name of control. Must be a unique name. If empty, a unique name is generated.
styles (Iterable[StyleT], optional) – One or more styles to apply to the control shape.
- Returns:
Radio Button Control.
- Return type:
Hint
BorderKind
can be imported fromooodev.utils.kind.border_kind
.StateKind
can be imported fromooodev.utils.kind.state_kind
.
- insert_control_rich_text(*, name='', border=BorderKind.BORDER_3D, styles=None)
Inserts a Rich Text control.
- Parameters:
name (str, optional) – Name of control. Must be a unique name. If empty, a unique name is generated.
border (BorderKind, optional) – Border option. Defaults to
BorderKind.BORDER_3D
.styles (Iterable[StyleT], optional) – One or more styles to apply to the control shape.
- Returns:
Rich Text Control.
- Return type:
Hint
BorderKind
can be imported fromooodev.utils.kind.border_kind
.
- insert_control_scroll_bar(*, name='', min_value=0, max_value=100, orientation=OrientationKind.HORIZONTAL, border=BorderKind.BORDER_3D, styles=None)
Inserts a Scrollbar control.
- Parameters:
name (str, optional) – Name of control. Must be a unique name. If empty, a unique name is generated.
min_value (float, optional) – Specifies the smallest value that can be entered in the control. Defaults to
0
.max_value (float, optional) – Specifies the largest value that can be entered in the control. Defaults to
100
.orientation (OrientationKind, optional) – Orientation. Defaults to
OrientationKind.HORIZONTAL
.border (BorderKind, optional) – Border option. Defaults to
BorderKind.BORDER_3D
.styles (Iterable[StyleT], optional) – One or more styles to apply to the control shape.
- Returns:
Scrollbar Control.
- Return type:
Hint
BorderKind
can be imported fromooodev.utils.kind.border_kind
.OrientationKind
can be imported fromooodev.utils.kind.orientation_kind
.
- insert_control_spin_button(value=0, *, name='', min_value=-1000000, max_value=1000000, increment=1, border=BorderKind.BORDER_3D, styles=None)
Inserts a Spin Button control into the form.
- Parameters:
value (int, optional) – Specifies the initial value of the control. Defaults to
0
.name (str, optional) – Name of control. Must be a unique name. If empty, a unique name is generated.
min_value (float, optional) – Specifies the smallest value that can be entered in the control. Defaults to
-1000000.0
.max_value (float, optional) – Specifies the largest value that can be entered in the control. Defaults to
1000000.0
.increment (int, optional) – The step when the spin button is pressed. Defaults to
1
.border (BorderKind, optional) – Border option. Defaults to
BorderKind.BORDER_3D
.styles (Iterable[StyleT], optional) – One or more styles to apply to the control shape.
- Returns:
Spin Button Control.
- Return type:
Hint
BorderKind
can be imported fromooodev.utils.kind.border_kind
.
- insert_control_text_field(text='', *, name='', echo_char='', border=BorderKind.NONE, styles=None)
Inserts a Text field control.
- Parameters:
text (str, optional) – Text value.
name (str, optional) – Name of control. Must be a unique name. If empty, a unique name is generated.
echo_char (str, optional) – Character used for masking. Must be a single character.
border (BorderKind, optional) – Border option. Defaults to
BorderKind.NONE
.styles (Iterable[StyleT], optional) – One or more styles to apply to the control shape.
- Returns:
Text Field Control.
- Return type:
Hint
BorderKind
can be imported fromooodev.utils.kind.border_kind
.
- insert_control_time_field(time_value=None, *, name='', min_time=datetime.time(0, 0), max_time=datetime.time(23, 59, 59, 999999), time_format=TimeFormatKind.SHORT_24H, spin_button=True, border=BorderKind.BORDER_3D, styles=None)
Inserts a Time field control into the form.
- Parameters:
time_value (datetime.time | None, optional) – Specifics the control time. Defaults to
None
.name (str, optional) – Name of control. Must be a unique name. If empty, a unique name is generated.
min_time (datetime.time, optional) – Specifics control min time. Defaults to
time(0, 0, 0, 0)
.max_time (datetime.time, optional) – Specifics control min time. Defaults to a
time(23, 59, 59, 999_999)
.drop_down (bool, optional) – Specifies if the control is a dropdown. Defaults to
True
.time_format (TimeFormatKind, optional) – Date format. Defaults to
TimeFormatKind.SHORT_24H
.pin_button (bool, optional) – When
True
, a spin button is present. Defaults toTrue
.border (BorderKind, optional) – Border option. Defaults to
BorderKind.BORDER_3D
.styles (Iterable[StyleT], optional) – One or more styles to apply to the control shape.
spin_button (bool) –
- Returns:
Time Field Control.
- Return type:
Hint
BorderKind
can be imported fromooodev.utils.kind.border_kind
.TimeFormatKind
can be imported fromooodev.utils.kind.time_format_kind
.
- on_finding_control(event_args)
Event handler for finding control.
Triggers the
finding_control
event.- Return type:
None
- Parameters:
event_args (CancelEventArgs) –
- on_insert_control(event_args)
Event handler for insert control.
Triggers the
insert_control
event.- Return type:
None
- Parameters:
event_args (EventArgs) –
- on_setting_shape_props(event_args)
Event handler for setting shape properties.
Triggers the
setting_shape_props
event.- Return type:
None
- Parameters:
event_args (CancelEventArgs) –
- remove_event_observer(observer)
Removes an observer
- Parameters:
observer (EventObserver) – One or more observers to add.
- Returns:
True
if observer has been removed; Otherwise,False
.- Return type:
bool
- subscribe_event(event_name, callback)
Add an event listener to current instance.
- Parameters:
event_name (str) – Event Name.
callback (EventCallback) – Callback of the event listener.
- Return type:
None
- trigger_event(event_name, event_args)
Trigger an event on current instance.
- Parameters:
event_name (str) – Event Name.
event_args (EventArgsT) – Event Args.
- Return type:
None
- unsubscribe_event(event_name, callback)
Remove an event listener from current instance.
- Parameters:
event_name (str) – Event Name.
callback (EventCallback) – Callback of the event listener.
- Return type:
None
- property current_control: Any
Gets/Sets the control.
When setting the control any previous control for the cell is removed.
- Return type:
Any
- property event_observer: EventObserver
Gets/Sets The Event Observer for this instance.
- Return type:
- property extra_data: TheDict
Extra Data Key Value Pair Dictionary.
Properties can be assigned properties and access like a dictionary and with dot notation.
Note
This is a dictionary object that can be used to store key value pairs. Generally speaking this data is not part of the object’s main data structure and is not saved with the object (document).
This property is used to store data that is not part of the object’s main data structure and can be used however the developer sees fit.
- Return type: