Skip to content

octoprint.schema.config.controls#

ContainerConfig #

Bases: BaseModel

children: List[Union[ContainerConfig, ControlConfig]] = [] class-attribute instance-attribute #

A list of children controls or containers contained within this container.

layout: LayoutEnum = LayoutEnum.vertical class-attribute instance-attribute #

The layout to use for laying out the contained children, either from top to bottom (vertical) or from left to right (horizontal).

name: Optional[str] = None class-attribute instance-attribute #

A name to display above the container, basically a section header.

ControlConfig #

Bases: BaseModel

additionalClasses: Optional[str] = None class-attribute instance-attribute #

Additional classes to apply to the button of a command, commands, script or javascript control, other than the default btn. Can be used to visually style the button, e.g. set to btn-danger to turn the button red.

command: Optional[str] = None class-attribute instance-attribute #

A single GCODE command to send to the printer. Will be rendered as a button which sends the command to the printer upon click. The button text will be the value of the name attribute. Mutually exclusive with commands and script. The rendered button be disabled if the printer is currently offline or printing or alternatively if the requirements defined via the enabled attribute are not met.

commands: Optional[List[str]] = None class-attribute instance-attribute #

A list of GCODE commands to send to the printer. Will be rendered as a button which sends the commands to the printer upon click. The button text will be the value of the name attribute. Mutually exclusive with command and script. The rendered button will be disabled if the printer is currently offline or printing or alternatively if the requirements defined via the enabled attribute are not met.

confirm: Optional[str] = None class-attribute instance-attribute #

A text to display to the user to confirm his button press. Can be used with sensitive custom controls like changing EEPROM values in order to prevent accidental clicks. The text will be displayed in a confirmation dialog.

enabled: Optional[str] = None class-attribute instance-attribute #

A JavaScript snippet returning either true or false determining whether the control should be enabled or not. This allows to override the default logic for the enable state of the control (disabled if printer is offline). The JavaScript snippet is eval'd and processed in a context where the control it is part of is provided as local variable data and the ControlViewModel is available as self.

input: Optional[List[ControlInputConfig]] = [] class-attribute instance-attribute #

A list of definitions of input parameters for a command or commands, to be rendered as additional input fields. command/commands may contain placeholders to be replaced by the values obtained from the user for the defined input fields.

javascript: Optional[str] = None class-attribute instance-attribute #

A JavaScript snippet to be executed when the button rendered for command or commands is clicked. This allows to override the direct sending of the command or commands to the printer with more sophisticated behaviour. The JavaScript snippet is eval'd and processed in a context where the control it is part of is provided as local variable data and the ControlViewModel is available as self.

name: str instance-attribute #

The name of the control, will be displayed either on the button if it's a control sending a command or as a label for controls which only display output.

regex: Optional[str] = None class-attribute instance-attribute #

A regular expression to match against lines received from the printer to retrieve information from it (e.g. specific output). Together with template this allows rendition of received data from the printer within the UI.

script: Optional[str] = None class-attribute instance-attribute #

The name of a full blown GCODE script to send to the printer. Will be rendered as a button which sends the script to the printer upon click. The button text will be the value of the name attribute. Mutually exclusive with command and commands. The rendered button will be disabled if the printer is currently offline or printing or alternatively if the requirements defined via the enabled attribute are not met. Values of input parameters will be available in the template context under the parameter variable (e.g. an input parameter speed will be available in the script template as parameter.speed). On top of that all other variables defined in the GCODE template context will be available.

template: Optional[str] = None class-attribute instance-attribute #

A template to use for rendering the match of regex. May contain placeholders in Python Format String Syntax for either named groups within the regex (e.g. Temperature: {temperature} for a regex T:\s*(?P<temperature>\d+(\.\d*)) or positional groups within the regex (e.g. Position: X={0}, Y={1}, Z={2}, E={3} for a regex X:([0-9.]+) Y:([0-9.]+) Z:([0-9.]+) E:([0-9.]+)).

ControlInputConfig #

Bases: BaseModel

default: Union[str, int, float, bool] instance-attribute #

Default value for the input field.

name: str instance-attribute #

Name to display for the input field.

parameter: str instance-attribute #

Internal parameter name for the input field, used as a placeholder in command/commands.

slider: Optional[ControlSliderInputConfig] = None class-attribute instance-attribute #

If this attribute is included, instead of an input field a slider control will be rendered.

ControlSliderInputConfig #

Bases: BaseModel

max: int = 255 class-attribute instance-attribute #

Maximum value of the slider.

min: int = 0 class-attribute instance-attribute #

Minimum value of the slider.

step: int = 1 class-attribute instance-attribute #

Step size per slider tick.