Live Chat

We'll need to share your messages (and your email address if you're logged in) with our live chat provider, Drift. Here's their privacy policy.

If you don't want to do this, you can email us instead at contact@anvil.works.

anvil Module

Classes

BlobMedia

Create a Media object with the specified content_type (a string such as ‘text/plain’) and data (a binary string). Optionally specify a filename as well.


Base class: anvil.Media

Constructor

BlobMedia(content_type, data, [name=None])

Button

Create a new ‘Button’ object


Base class: anvil.Component

Constructor

Button([width=], [spacing_above=], [spacing_below=], [enabled=], [text=], [align=], [font_size=], [font=], [bold=], [italic=], [underline=], [background=], [foreground=], [border=], [visible=], [role=], [icon=], [icon_align=], [tag=], [tooltip=])

Button Properties

align - string

The position of this button in the available space.

background - color

The background colour of this component.

bold - boolean

Display this component’s text in bold

border - string

The border of this component.

enabled - boolean

True if this component should allow user interaction.

font - string

The font to use for this component.

font_size - number

The height of text displayed on this component in pixels

foreground - color

The foreground colour of this component.

icon - icon

The icon to display on this component. Either a URL, or a FontAwesome Icon, e.g. ‘fa:user’.

icon_align - string

The alignment of the icon on this component. Set to ‘top’ for a centred icon on a component with no text.

italic - boolean

Display this component’s text in italics

parent

role - themeRole

Choose how this component can appear, based on your app’s visual theme.

spacing_above - string

The vertical space above this component.

spacing_below - string

The vertical space below this component.

tag - object

Use this property to store any extra information about this component

text - string

The text displayed on this component

tooltip - string

Text to display when you hover the mouse over this component

underline - boolean

Display this component’s text underlined

visible - boolean

Should this component be displayed?

width - string

The width of this Button, or “default” to have the width set by the container.


Button Events

click()

When the button is clicked

show()

When the Button is shown on the screen

hide()

When the Button is removed from the screen


Canvas

Create a new ‘Canvas’ object


Base class: anvil.Component

Constructor

Canvas([width=], [spacing_above=], [spacing_below=], [height=], [background=], [foreground=], [border=], [visible=], [role=], [tag=], [tooltip=])

Canvas Methods

arc(x, y, radius, start_angle=0, end_angle=PI*2, anticlockwise=False)

Adds an arc to the end of the current path with specified center and radius.

begin_path()

Begin a path on the canvas.

bezier_curve_to(cp1x, cp1y, cp2x, cp2y, x, y)

Adds a Bezier curve at the end of the current path to (x,y) with control points (cp1x,cp1y) and (cp2x,cp2y).

clear_rect(x, y, width, height)

Clear the specified rectangle with the background color of the canvas.

clip()

Turn the current path into the clipping region of the canvas.

close_path()

Close the current path with a straight line back to the start point.

create_linear_gradient(x0, y0, x1, y1)

Returns a gradient object representing a linear gradient from (x0,y0) to (x1,y1).

create_radial_gradient(x0, y0, x1, y1)

Returns a gradient object representing a radial gradient from (x0,y0) with radius r0 to (x1,y1) with radius r1.

draw_image(media, [x], [y], [width], [height])

Draw an image (from a Media object) onto the canvas at the specified coordinates (optionally scaling to the specified width and height)

draw_image_part(media, sx, sy, s_width, s_height, dx, dy, d_width, d_height)

Draw a subset of an image (from a Media object) onto the canvas.

sx, sy, s_width and s_height specify which pixels within the source image of the source image to draw. dx and dy (and optionally d_width and d_height) specify where (and optionally what dimensions) on the canvas to draw the image.

fill()

Fill the current path with the current fill style of the canvas.

fill_rect(x, y, width, height)

Fill the specified rectangle with the current fill style of the canvas.

fill_text(text, x, y)

Draw the specified text at the required position.

get_height()

Get the pixel height of this canvas.

get_image()

Take a snapshot of the canvas and return an image as a Media object.

get_width()

Get the pixel width of this canvas.

line_to(x, y)

Adds a straight line segment at the end of the current path to the specified position.

measure_text(text)

Get the size of the specified text in the current font.

move_to(x, y)

Moves the current path position to the specified point without drawing.

quadratic_curve_to(cpx, cpy, x, y)

Adds a quadratic curve at the end of the current path to (x,y) with control point (cpx, cpy).

reset_context()

Reset the drawing context for this canvas. Called automatically after a window resize.

reset_transform()

Reset the current transform to the identity matrix.

restore()

Restores a drawing transform saved by the ‘save()’ function

rotate(angle)

Rotate all subsequent drawing by ‘angle’ radians.

save()

Saves the current drawing transform, which can be restored by calling ‘restore()’

scale(x, y)

Scale all subsequent drawing operations by ‘x’ horizontally and ‘y’ vertically.

set_transform()

Set the current transform matrix to the specified values.

stroke()

Draw the current path with the current stroke style of the canvas.

stroke_rect(x, y, width, height)

Outline the specified rectangle with the current stroke style of the canvas.

stroke_text(text, x, y)

Draw the outline of the specified text at the required position.

transform(a, b, c, d, e, f)

Multiply the current transform matrix by the specified matrix.

translate(x, y)

Translate all subsequent drawing by ‘x’ pixels across and ‘y’ pixels down.


Canvas Properties

arc - arc

Adds an arc to the end of the current path with specified center and radius.

background - color

The background colour of this component.

begin_path - begin_path

Begin a path on the canvas.

bezier_curve_to - bezier_curve_to

Adds a Bezier curve at the end of the current path to (x,y) with control points (cp1x,cp1y) and (cp2x,cp2y).

border - string

The border of this component.

clear_rect - clear_rect

Clear the specified rectangle with the background color of the canvas.

clip - clip

Turn the current path into the clipping region of the canvas.

close_path - close_path

Close the current path with a straight line back to the start point.

create_linear_gradient - create_linear_gradient

Returns a gradient object representing a linear gradient from (x0,y0) to (x1,y1).

create_radial_gradient - create_radial_gradient

Returns a gradient object representing a radial gradient from (x0,y0) with radius r0 to (x1,y1) with radius r1.

draw_image - draw_image

Draw an image (from a Media object) onto the canvas at the specified coordinates (optionally scaling to the specified width and height)

draw_image_part - draw_image_part

Draw a subset of an image (from a Media object) onto the canvas.

sx, sy, s_width and s_height specify which pixels within the source image of the source image to draw. dx and dy (and optionally d_width and d_height) specify where (and optionally what dimensions) on the canvas to draw the image.

fill - fill

Fill the current path with the current fill style of the canvas.

fill_rect - fill_rect

Fill the specified rectangle with the current fill style of the canvas.

fill_style - string

The color or gradient to use when filling shapes and paths.

fill_text - fill_text

Draw the specified text at the required position.

font - string

The font to use when drawing text on this canvas.

foreground - color

The foreground colour of this component.

get_height - get_height

Get the pixel height of this canvas.

get_image - get_image

Take a snapshot of the canvas and return an image as a Media object.

get_width - get_width

Get the pixel width of this canvas.

global_alpha - number

The global opacity to draw with, in the range 0-1.

global_composite_operation - number

The global composite operation to draw with. Defaults to ‘source-over’

height - string

The height of this component.

line_cap - string

The line cap to use when drawing lines on this canvas.

line_join - string

The line join to use when connecting lines on this canvas.

line_to - line_to

Adds a straight line segment at the end of the current path to the specified position.

line_width - number

The width of lines drawn on this canvas.

measure_text - measure_text

Get the size of the specified text in the current font.

miter_limit - number

The limit of line join miters, in pixels.

move_to - move_to

Moves the current path position to the specified point without drawing.

parent

quadratic_curve_to - quadratic_curve_to

Adds a quadratic curve at the end of the current path to (x,y) with control point (cpx, cpy).

reset_context - reset_context

Reset the drawing context for this canvas. Called automatically after a window resize.

reset_transform - reset_transform

Reset the current transform to the identity matrix.

restore - restore

Restores a drawing transform saved by the ‘save()’ function

role - themeRole

Choose how this component can appear, based on your app’s visual theme.

rotate - rotate

Rotate all subsequent drawing by ‘angle’ radians.

save - save

Saves the current drawing transform, which can be restored by calling ‘restore()’

scale - scale

Scale all subsequent drawing operations by ‘x’ horizontally and ‘y’ vertically.

set_transform - set_transform

Set the current transform matrix to the specified values.

shadow_blur - number

The required shadow blur, in pixels.

shadow_color - string

The color to use for shadows.

shadow_offset_x - number

The horizontal shadow offset, in pixels.

shadow_offset_y - number

The vertical shadow offset, in pixels.

spacing_above - string

The vertical space above this component.

spacing_below - string

The vertical space below this component.

stroke - stroke

Draw the current path with the current stroke style of the canvas.

stroke_rect - stroke_rect

Outline the specified rectangle with the current stroke style of the canvas.

stroke_style - string

The color or gradient to use when drawing outlines.

stroke_text - stroke_text

Draw the outline of the specified text at the required position.

tag - object

Use this property to store any extra information about this component

text_align - string

Text alignment, relative to the drawing point.

text_baseline - string

Text baseline, relative to the drawing point.

tooltip - string

Text to display when you hover the mouse over this component

transform - transform

Multiply the current transform matrix by the specified matrix.

translate - translate

Translate all subsequent drawing by ‘x’ pixels across and ‘y’ pixels down.

visible - boolean

Should this component be displayed?

width - string

The width of this Canvas, or “default” to have the width set by the container.


Canvas Events

show()

When the Canvas is shown on the screen

hide()

When the Canvas is removed from the screen

mouse_enter(x, y)

When the mouse cursor enters this component

  • x - The x coordinate of the mouse pointer, within this component
  • y - The y coordinate of the mouse pointer, within this component

mouse_leave(x, y)

When the mouse cursor leaves this component

  • x - The x coordinate of the mouse pointer relative to this component
  • y - The y coordinate of the mouse pointer relative to this component

mouse_move(x, y)

When the mouse cursor moves over this component

  • x - The x coordinate of the mouse pointer within this component
  • y - The y coordinate of the mouse pointer within this component

mouse_down(x, y, button)

When a mouse button is pressed on this component

  • x - The x coordinate of the mouse pointer within this component
  • y - The y coordinate of the mouse pointer within this component
  • button - The button that was pressed (1 = left, 2 = middle, 3 = right)

mouse_up(x, y, button)

When a mouse button is released on this component

  • x - The x coordinate of the mouse pointer within this component
  • y - The y coordinate of the mouse pointer within this component
  • button - The button that was released (1 = left, 2 = middle, 3 = right)


CheckBox

Create a new ‘CheckBox’ object


Base class: anvil.Component

Constructor

CheckBox([checked=], [enabled=], [width=], [spacing_above=], [spacing_below=], [text=], [align=], [font_size=], [font=], [bold=], [italic=], [underline=], [background=], [foreground=], [border=], [visible=], [role=], [tooltip=], [tag=])

CheckBox Methods

focus()

Set the keyboard focus to this component


CheckBox Properties

align - string

Align this component’s text

background - color

The background colour of this component.

bold - boolean

Display this component’s text in bold

border - string

The border of this component.

checked - boolean

The status of the checkbox

enabled - boolean

True if this component should allow user interaction.

focus - focus

Set the keyboard focus to this component

font - string

The font to use for this component.

font_size - number

The height of text displayed on this component in pixels

foreground - color

The foreground colour of this component.

italic - boolean

Display this component’s text in italics

parent

role - themeRole

Choose how this component can appear, based on your app’s visual theme.

spacing_above - string

The vertical space above this component.

spacing_below - string

The vertical space below this component.

tag - object

Use this property to store any extra information about this component

text - string

The text displayed on this component

tooltip - string

Text to display when you hover the mouse over this component

underline - boolean

Display this component’s text underlined

visible - boolean

Should this component be displayed?

width - string

The width of this CheckBox, or “default” to have the width set by the container.


CheckBox Events

change()

When this checkbox is checked or unchecked

show()

When the CheckBox is shown on the screen

hide()

When the CheckBox is removed from the screen


ColumnPanel

Create a new ‘ColumnPanel’ object


Base class: anvil.Container

Constructor

ColumnPanel([col_widths=], [wrap_on=], [col_spacing=], [width=], [spacing_above=], [spacing_below=], [row_spacing=], [background=], [foreground=], [border=], [visible=], [role=], [tag=], [tooltip=])

ColumnPanel Methods

add_component(component, full_width_row=False, layout_props)

Add a component to the bottom of this ColumnPanel. Useful layout properties:

full_width_row = True|False row_background = [colour]


ColumnPanel Properties

add_component - add_component

Add a component to the bottom of this ColumnPanel. Useful layout properties:

full_width_row = True|False row_background = [colour]

background - color

The background colour of this component.

border - string

The border of this component.

col_spacing - string

Space between columns

col_widths - string

Custom column widths in this panel

foreground - color

The foreground colour of this component.

parent

role - themeRole

Choose how this component can appear, based on your app’s visual theme.

row_spacing - number

The spacing between rows of components in this container, in pixels.

spacing_above - string

The vertical space above this component.

spacing_below - string

The vertical space below this component.

tag - object

Use this property to store any extra information about this component

tooltip - string

Text to display when you hover the mouse over this component

visible - boolean

Should this component be displayed?

width - string

The width of this ColumnPanel, or “default” to have the width set by the container.

wrap_on - string

The largest display on which to wrap columns in this panel


ColumnPanel Events

show()

When the ColumnPanel is shown on the screen

hide()

When the ColumnPanel is removed from the screen


Component

You can set properties on a new component by passing them as keyword arguments. For example:

x = Label(text=‘Hello’)

Constructor

Component(properties)

Instance Methods

raise_event(event_name, event_args)

Trigger the ‘event_name’ event on this component. Any keyword arguments are passed to the handler function.

remove_from_parent()

Remove this component from its parent container.

scroll_into_view()

Scroll the window to make sure this component is in view.

set_event_handler(event_name, handler_func)

Set a function to call when the ‘event_name’ event happens on this component.


Component Attributes

raise_event - raise_event

Trigger the ‘event_name’ event on this component. Any keyword arguments are passed to the handler function.

remove_from_parent - remove_from_parent

Remove this component from its parent container.

scroll_into_view - scroll_into_view

Scroll the window to make sure this component is in view.

set_event_handler - set_event_handler

Set a function to call when the ‘event_name’ event happens on this component.


Container

Create a new ‘Container’ object


Base class: anvil.Component

Constructor

Container()

Instance Methods

add_component(component)

Add a component to this container.

clear()

Remove all components from this container

get_components()

Get a list of components in this container

raise_event_on_children(event_name, event_args)

Trigger the ‘event_name’ event on all children of this component. Any keyword arguments are passed to the handler function.


Container Attributes

add_component - add_component

Add a component to this container.

clear - clear

Remove all components from this container

get_components - get_components

Get a list of components in this container

raise_event_on_children - raise_event_on_children

Trigger the ‘event_name’ event on all children of this component. Any keyword arguments are passed to the handler function.


DataGrid

Create a new ‘DataGrid’ object


Base class: anvil.Container

Constructor

DataGrid([columns=], [auto_header=], [show_page_controls=], [rows_per_page=], [auto_display_data=], [width=], [spacing_above=], [spacing_below=], [row_spacing=], [background=], [foreground=], [border=], [visible=], [role=], [tag=], [tooltip=])

DataGrid Methods

add_component(component, [index=None], [pinned=False])

Add a component to this DataGrid, in the ‘index’th position. If ‘index’ is not specified, adds to the bottom.


DataGrid Properties

add_component - add_component

Add a component to this DataGrid, in the ‘index’th position. If ‘index’ is not specified, adds to the bottom.

auto_display_data - boolean

Whether to automatically display data in this row.

auto_header - boolean

Whether to display an automatic header at the top of this Data Grid.

background - color

The background colour of this component.

border - string

The border of this component.

columns - dataGridColumns

A list of columns to display in this Data Grid.

foreground - color

The foreground colour of this component.

parent

role - themeRole

Choose how this component can appear, based on your app’s visual theme.

row_spacing - number

The spacing between rows of components in this container, in pixels.

rows_per_page - number

The maximum number of rows to display at one time.

show_page_controls - boolean

Whether to display the next/previous page buttons.

spacing_above - string

The vertical space above this component.

spacing_below - string

The vertical space below this component.

tag - object

Use this property to store any extra information about this component

tooltip - string

Text to display when you hover the mouse over this component

visible - boolean

Should this component be displayed?

width - string

The width of this DataGrid, or “default” to have the width set by the container.


DataGrid Events

show()

When the DataGrid is shown on the screen

hide()

When the DataGrid is removed from the screen


DataRowPanel

Create a new ‘DataRowPanel’ object


Base class: anvil.Container

Constructor

DataRowPanel([item=], [text=], [align=], [font_size=], [font=], [bold=], [italic=], [underline=], [width=], [spacing_above=], [spacing_below=], [row_spacing=], [background=], [foreground=], [border=], [visible=], [role=], [tooltip=], [tag=])

DataRowPanel Methods

add_component(component, [column=None])

Add a component to the specified column of this DataRowPanel. TODO: If ‘column’ is not specified, adds the component full-width.


DataRowPanel Properties

add_component - add_component

Add a component to the specified column of this DataRowPanel. TODO: If ‘column’ is not specified, adds the component full-width.

align - string

Align this component’s text

background - color

The background colour of this component.

bold - boolean

Display this component’s text in bold

border - string

The border of this component.

font - string

The font to use for this component.

font_size - number

The height of text displayed on this component in pixels

foreground - color

The foreground colour of this component.

italic - boolean

Display this component’s text in italics

item - object

The data to display in this row by default.

parent

role - themeRole

Choose how this component can appear, based on your app’s visual theme.

row_spacing - number

The spacing between rows of components in this container, in pixels.

spacing_above - string

The vertical space above this component.

spacing_below - string

The vertical space below this component.

tag - object

Use this property to store any extra information about this component

text - string

The text displayed on this component

tooltip - string

Text to display when you hover the mouse over this component

underline - boolean

Display this component’s text underlined

visible - boolean

Should this component be displayed?

width - string

The width of this DataRowPanel, or “default” to have the width set by the container.


DataRowPanel Events

show()

When the DataRowPanel is shown on the screen

hide()

When the DataRowPanel is removed from the screen


DatePicker

Create a new ‘DatePicker’ object


Base class: anvil.Component

Constructor

DatePicker([date=], [format=], [pick_time=], [min_date=], [max_date=], [placeholder=], [text=], [align=], [font_size=], [font=], [bold=], [italic=], [underline=], [width=], [spacing_above=], [spacing_below=], [enabled=], [background=], [foreground=], [border=], [visible=], [role=], [tooltip=], [tag=])

DatePicker Methods

focus()

Set the keyboard focus to this component


DatePicker Properties

align - string

Align this component’s text

background - color

The background colour of this component.

bold - boolean

Display this component’s text in bold

border - string

The border of this component.

date - string

The date selected on this component.

enabled - boolean

True if this component should allow user interaction.

focus - focus

Set the keyboard focus to this component

font - string

The font to use for this component.

font_size - number

The height of text displayed on this component in pixels

foreground - color

The foreground colour of this component.

format - string

The format in which to display the selected date.

italic - boolean

Display this component’s text in italics

max_date - string

The maximum date the user can select.

min_date - string

The minimum date the user can select.

parent

pick_time - boolean

Whether the user should be able to select a time as well as a date

placeholder - string

A string to display when the DatePicker is empty.

role - themeRole

Choose how this component can appear, based on your app’s visual theme.

spacing_above - string

The vertical space above this component.

spacing_below - string

The vertical space below this component.

tag - object

Use this property to store any extra information about this component

text - string

The text displayed on this component

tooltip - string

Text to display when you hover the mouse over this component

underline - boolean

Display this component’s text underlined

visible - boolean

Should this component be displayed?

width - string

The width of this DatePicker, or “default” to have the width set by the container.


DatePicker Events

change()

When the selected date changes

show()

When the DatePicker is shown on the screen

hide()

When the DatePicker is removed from the screen


Create a new ‘DropDown’ object


Base class: anvil.Component
DropDown([items=], [selected_value=], [include_placeholder=], [placeholder=], [width=], [spacing_above=], [spacing_below=], [enabled=], [align=], [font_size=], [font=], [bold=], [italic=], [underline=], [background=], [foreground=], [border=], [visible=], [role=], [tag=], [tooltip=])

focus()

Set the keyboard focus to this component


align - string

The position of this dropdown in the available space.

background - color

The background colour of this component.

bold - boolean

Display this component’s text in bold

border - string

The border of this component.

enabled - boolean

True if this component should allow user interaction.

focus - focus

Set the keyboard focus to this component

font - string

The font to use for this component.

font_size - number

The height of text displayed on this component in pixels

foreground - color

The foreground colour of this component.

include_placeholder - boolean

Whether to add a placeholder item to the list with value None

italic - boolean

Display this component’s text in italics

items - text[]

The items to display in this dropdown.

parent

placeholder - string

The text to be displayed when the selected_value is None.

role - themeRole

Choose how this component can appear, based on your app’s visual theme.

selected_value - object

The value of the currently selected item. Can only be set at runtime.

spacing_above - string

The vertical space above this component.

spacing_below - string

The vertical space below this component.

tag - object

Use this property to store any extra information about this component

tooltip - string

Text to display when you hover the mouse over this component

underline - boolean

Display this component’s text underlined

visible - boolean

Should this component be displayed?

width - string

The width of this DropDown, or “default” to have the width set by the container.


change()

When an item is selected

show()

When the DropDown is shown on the screen

hide()

When the DropDown is removed from the screen


FileLoader

Create a new ‘FileLoader’ object


Base class: anvil.Component

Constructor

FileLoader([multiple=], [show_state=], [file=], [files=], [file_types=], [width=], [spacing_above=], [spacing_below=], [text=], [align=], [font_size=], [font=], [bold=], [italic=], [underline=], [background=], [foreground=], [border=], [visible=], [role=], [icon=], [icon_align=], [enabled=], [tag=], [tooltip=])

FileLoader Methods

clear()

Clear any selected files from this FileLoader

focus()

Set the keyboard focus to this FileLoader


FileLoader Properties

align - string

Align this component’s text

background - color

The background colour of this component.

bold - boolean

Display this component’s text in bold

border - string

The border of this component.

clear - clear

Clear any selected files from this FileLoader

enabled - boolean

True if this component should allow user interaction.

file - anvil.Media instance

The currently selected file (or the first, if multiple files are selected). This is a Media object.

file_types - string

Specify what type of file to upload. Can accept a MIME type (eg “image/png” or “image/*“), or an extension (eg “.png”), or a comma-separated set of them (eg “.png,.jpg,.jpeg”)

files - list(anvil.Media instance)

A list of currently selected files. Each file is a Media object.

focus - focus

Set the keyboard focus to this FileLoader

font - string

The font to use for this component.

font_size - number

The height of text displayed on this component in pixels

foreground - color

The foreground colour of this component.

icon - icon

The icon to display on this component. Either a URL, or a FontAwesome Icon, e.g. ‘fa:user’.

icon_align - string

The alignment of the icon on this component. Set to ‘top’ for a centred icon on a component with no text.

italic - boolean

Display this component’s text in italics

multiple - boolean

If True, this FileLoader can load multiple files at the same time

parent

role - themeRole

Choose how this component can appear, based on your app’s visual theme.

show_state - boolean

If True, display a message describing selected files.

spacing_above - string

The vertical space above this component.

spacing_below - string

The vertical space below this component.

tag - object

Use this property to store any extra information about this component

text - string

The text displayed on this component

tooltip - string

Text to display when you hover the mouse over this component

underline - boolean

Display this component’s text underlined

visible - boolean

Should this component be displayed?

width - string

The width of this FileLoader, or “default” to have the width set by the container.


FileLoader Events

change(file, files)

When a new file is loaded into this FileLoader

  • file - The first selected file. Set the 'multiple' property to allow loading more than one file.
  • files - A list of loaded files. Set the 'multiple' property to allow loading more than one file.

show()

When the FileLoader is shown on the screen

hide()

When the FileLoader is removed from the screen

focus()

When the FileLoader gets focus

lost_focus()

When the FileLoader loses focus


FlowPanel

Create a new ‘FlowPanel’ object


Base class: anvil.Container

Constructor

FlowPanel([align=], [spacing=], [background=], [foreground=], [border=], [visible=], [role=], [tag=], [width=], [spacing_above=], [spacing_below=], [tooltip=])

FlowPanel Methods

add_component(component, [index=], [width=])

Add a component to this panel. Optionally specify the position in the panel to add it, or the width to apply to components that can’t self-size width-wise.


FlowPanel Properties

add_component - add_component

Add a component to this panel. Optionally specify the position in the panel to add it, or the width to apply to components that can’t self-size width-wise.

align - string

Align this component’s content

background - color

The background colour of this component.

border - string

The border of this component.

foreground - color

The foreground colour of this component.

parent

role - themeRole

Choose how this component can appear, based on your app’s visual theme.

spacing - string

Space between components

spacing_above - string

The vertical space above this component.

spacing_below - string

The vertical space below this component.

tag - object

Use this property to store any extra information about this component

tooltip - string

Text to display when you hover the mouse over this component

visible - boolean

Should this component be displayed?

width - string

The width of this FlowPanel, or “default” to have the width set by the container.


FlowPanel Events

show()

When the FlowPanel is shown on the screen

hide()

When the FlowPanel is removed from the screen


GoogleMap

Create a new ‘GoogleMap’ object


Base class: anvil.Container

Constructor

GoogleMap([map_data=], [background_color=], [center=], [clickable_icons=], [disable_default_ui=], [disable_double_click_zoom=], [draggable=], [draggable_cursor=], [dragging_cursor=], [fullscreen_control=], [fullscreen_control_options=], [gesture_handling=], [heading=], [keyboard_shortcuts=], [map_type_control=], [map_type_control_options=], [map_type_id=], [max_zoom=], [min_zoom=], [rotate_control=], [rotate_control_options=], [scale_control=], [scale_control_options=], [scroll_wheel=], [street_view_control=], [street_view_control_options=], [zoom=], [zoom_control=], [zoom_control_options=], [width=], [spacing_above=], [spacing_below=], [height=], [visible=], [tag=])

GoogleMap Methods

add_component(map_component) → anvil.Component instance

Add a map component to this GoogleMap

fit_bounds(lat_lng_bounds, [padding])

Sets the viewport to contain the given bounds. Adds some padding around the bounds by default - set padding to 0 to match the bounds exactly.

get_bounds() → anvil.GoogleMap.LatLngBounds instance

Returns the lat/lng bounds of the current viewport.

pan_by(dx, dy)

Changes the center of the map by the given distance in pixels.

pan_to(position)

Changes the center of the map to the given LatLng position.

pan_to_bounds(lat_lng_bounds, [padding])

Pans the map by the minimum amount necessary to contain the given LatLngBounds. Adds some padding around the bounds by default - set padding to 0 to match the bounds exactly.


GoogleMap Properties

add_component - add_component

Add a map component to this GoogleMap

background_color - string

Color used for the background of the Map div. This color will be visible when tiles have not yet loaded as the user pans.

center - anvil.GoogleMap.LatLng instance

The Map center.

clickable_icons - boolean

When false, map icons are not clickable. A map icon represents a point of interest

disable_default_ui - boolean

Enables/disables all default UI.

disable_double_click_zoom - boolean

Enables/disables zoom and center on double click.

draggable - boolean

If false, prevents the map from being dragged.

draggable_cursor - string

The name or url of the cursor to display when mousing over a draggable map.

dragging_cursor - string

The name or url of the cursor to display when the map is being dragged.

fit_bounds - fit_bounds

Sets the viewport to contain the given bounds. Adds some padding around the bounds by default - set padding to 0 to match the bounds exactly.

fullscreen_control - boolean

The enabled/disabled state of the Fullscreen control.

fullscreen_control_options - anvil.GoogleMap.FullscreenControlOptions instance

The display options for the Fullscreen control.

gesture_handling - string

This setting controls how gestures on the map are handled.

get_bounds - get_bounds

Returns the lat/lng bounds of the current viewport.

heading - number

The heading for aerial imagery in degrees measured clockwise from cardinal direction North.

height - string

The height of this component.

keyboard_shortcuts - boolean

If false, prevents the map from being controlled by the keyboard.

map_data - anvil.GoogleMap.Data instance

Map data

map_type_control - boolean

The enabled/disabled state of the Map type control.

map_type_control_options - anvil.GoogleMap.MapTypeControlOptions instance

The display options for the Map type control.

map_type_id - anvil.GoogleMap.MapTypeId

The map type ID. Defaults to MapTypeId.ROADMAP

max_zoom - number

The maximum zoom level which will be displayed on the map.

min_zoom - number

The minimum zoom level which will be displayed on the map.

pan_by - pan_by

Changes the center of the map by the given distance in pixels.

pan_to - pan_to

Changes the center of the map to the given LatLng position.

pan_to_bounds - pan_to_bounds

Pans the map by the minimum amount necessary to contain the given LatLngBounds. Adds some padding around the bounds by default - set padding to 0 to match the bounds exactly.

parent

rotate_control - boolean

The enabled/disabled state of the rotate control.

rotate_control_options - anvil.GoogleMap.RotateControlOptions instance

The display options for the rotate control.

scale_control - boolean

The enabled/disabled state of the scale control.

scale_control_options - anvil.GoogleMap.ScaleControlOptions instance

The display options for the scale control.

scroll_wheel - boolean

If false, disables scrollwheel zooming on the map.

spacing_above - string

The vertical space above this component.

spacing_below - string

The vertical space below this component.

street_view_control - boolean

The enabled/disabled state of the street view control.

street_view_control_options - anvil.GoogleMap.StreetViewControlOptions instance

The display options for the street view control.

tag - object

Use this property to store any extra information about this component

visible - boolean

Should this component be displayed?

width - string

The width of this GoogleMap, or “default” to have the width set by the container.

zoom - number

The map zoom level.

zoom_control - boolean

The enabled/disabled state of the zoom control.

zoom_control_options - anvil.GoogleMap.ZoomControlOptions instance

The display options for the zoom control.


GoogleMap Events

bounds_changed()

when the viewport bounds have changed.

center_changed()

when the map center property changes.

click(lat_lng, pixel)

when the user clicks on the map.

  • lat_lng - The position that was clicked.
  • pixel - The position that was clicked.

dbl_click(lat_lng, pixel)

when the user double-clicks on the map.

  • lat_lng - The position that was double-clicked.
  • pixel - The position that was double-clicked.

drag()

This event is repeatedly fired while the user drags the map.

dragend()

when the user stops dragging the map.

dragstart()

when the user starts dragging the map.

heading_changed()

when the map heading property changes.

idle()

when the map becomes idle after panning or zooming.

maptypeid_changed()

when the mapTypeId property changes.

mousemove(lat_lng, pixel)

whenever the user’s mouse moves over the map container.

  • lat_lng - The position of the cursor.
  • pixel - The position of the cursor.

mouseout(lat_lng, pixel)

when the user’s mouse exits the map container.

  • lat_lng - The position of the cursor.
  • pixel - The position of the cursor.

mouseover(lat_lng, pixel)

when the user’s mouse enters the map container.

  • lat_lng - The position of the cursor.
  • pixel - The position of the cursor.

projection_changed()

when the projection has changed.

rightclick(lat_lng, pixel)

when the user right-clicks on the map container.

  • lat_lng - The position that was right-clicked.
  • pixel - The position that was right-clicked.

tilesloaded()

when the visible tiles have finished loading.

tilt_changed()

when the map tilt property changes.

zoom_changed()

when the map zoom property changes.

data_addfeature(feature)

when the viewport bounds have changed.

  • feature - The feature that was added.

data_click(feature, lat_lng)

for a click on the geometry.

  • feature - The feature that was clicked.
  • lat_lng - The position that was clicked.

data_dbl_click(feature, lat_lng)

for a double click on the geometry.

  • feature - The feature that was double-clicked.
  • lat_lng - The position that was double-clicked.

data_mousedown(feature, lat_lng)

for a mousedown on the geometry.

  • feature - The feature the mouse is over.
  • lat_lng - The position of the cursor.

data_mouseout(feature, lat_lng)

when the mouse leaves the area of the geometry.

  • feature - The feature the mouse left.
  • lat_lng - The position of the cursor.

data_mouseover(feature, lat_lng)

when the mouse enters the area of the geometry.

  • feature - The feature the mouse is over.
  • lat_lng - The position of the cursor.

data_mouseup(feature, lat_lng)

for a mouseup on the geometry.

  • feature - The feature the mouse is over.
  • lat_lng - The position of the cursor.

data_removefeature(feature)

when a feature is removed from the collection.

  • feature - The feature that was removed.

data_removeproperty(feature, name, old_value)

when a feature’s property is removed.

  • feature - The feature whose property was removed.
  • name - The name of the property that was removed.
  • old_value - The old value of the property that was removed.

data_rightclick(feature, lat_lng)

for a right-click on the geometry.

  • feature - The feature that was right-clicked.
  • lat_lng - The position that was right-clicked.

data_setgeometry(feature, new_geometry, old_geometry)

when a feature’s geometry is set.

  • feature - The feature that was removed.
  • new_geometry - The geometry that was set.
  • old_geometry - The geometry that was replaced.

data_setproperty(feature, name, new_value, old_value)

when a feature’s property is set.

  • feature - The feature whose property was set.
  • name - The name of the property that was set.
  • new_value - The new value of the property that was set.
  • old_value - The old value of the property that was set.

show()

When the GoogleMap is shown on the screen

hide()

When the GoogleMap is removed from the screen


GridPanel

Create a new ‘GridPanel’ object


Base class: anvil.Container

Constructor

GridPanel([width=], [spacing_above=], [spacing_below=], [row_spacing=], [background=], [foreground=], [border=], [visible=], [role=], [tag=], [tooltip=])

GridPanel Methods

add_component(component, [row=], [col_xs=], [width_xs=])

Add a component to this GridPanel


GridPanel Properties

add_component - add_component

Add a component to this GridPanel

background - color

The background colour of this component.

border - string

The border of this component.

foreground - color

The foreground colour of this component.

parent

role - themeRole

Choose how this component can appear, based on your app’s visual theme.

row_spacing - number

The spacing between rows of components in this container, in pixels.

spacing_above - string

The vertical space above this component.

spacing_below - string

The vertical space below this component.

tag - object

Use this property to store any extra information about this component

tooltip - string

Text to display when you hover the mouse over this component

visible - boolean

Should this component be displayed?

width - string

The width of this GridPanel, or “default” to have the width set by the container.


GridPanel Events

show()

When the GridPanel is shown on the screen

hide()

When the GridPanel is removed from the screen


HtmlTemplate

Create a new ‘HtmlTemplate’ object


Base class: anvil.Container

Constructor

HtmlTemplate([tag=], [tooltip=])

HtmlTemplate Methods

add_component(component, [slot="default"])

Add a component to the named slot of this HTML templated panel. If no slot is specified, the ‘default’ slot will be used.

call_js(js_function_name, args)

Call a Javascript function


HtmlTemplate Properties

add_component - add_component

Add a component to the named slot of this HTML templated panel. If no slot is specified, the ‘default’ slot will be used.

call_js - call_js

Call a Javascript function

parent

tag - object

Use this property to store any extra information about this component

tooltip - string

Text to display when you hover the mouse over this component


HtmlTemplate Events

show()

When the HtmlTemplate is shown on the screen

hide()

When the HtmlTemplate is removed from the screen


Image

Create a new ‘Image’ object


Base class: anvil.Component

Constructor

Image([display_mode=], [vertical_align=], [source=], [width=], [spacing_above=], [spacing_below=], [height=], [background=], [foreground=], [border=], [visible=], [role=], [tooltip=], [tag=])

Image Properties

background - color

The background colour of this component.

border - string

The border of this component.

display_mode - string

Determines how the image’s size should be adjusted to fit the size of this Image component

foreground - color

The foreground colour of this component.

height - string

The height of this component.

parent

role - themeRole

Choose how this component can appear, based on your app’s visual theme.

source - uri

The image source - set a string for a URL or a Media object in code

spacing_above - string

The vertical space above this component.

spacing_below - string

The vertical space below this component.

tag - object

Use this property to store any extra information about this component

tooltip - string

Text to display when you hover the mouse over this component

vertical_align - string

Position the image vertically within this component

visible - boolean

Should this component be displayed?

width - string

The width of this Image, or “default” to have the width set by the container.


Image Events

show()

When the Image is shown on the screen

hide()

When the Image is removed from the screen

mouse_enter(x, y)

When the mouse cursor enters this component

  • x - The x coordinate of the mouse pointer, within this component
  • y - The y coordinate of the mouse pointer, within this component

mouse_leave(x, y)

When the mouse cursor leaves this component

  • x - The x coordinate of the mouse pointer relative to this component
  • y - The y coordinate of the mouse pointer relative to this component

mouse_move(x, y)

When the mouse cursor moves over this component

  • x - The x coordinate of the mouse pointer within this component
  • y - The y coordinate of the mouse pointer within this component

mouse_down(x, y, button)

When a mouse button is pressed on this component

  • x - The x coordinate of the mouse pointer within this component
  • y - The y coordinate of the mouse pointer within this component
  • button - The button that was pressed (1 = left, 2 = middle, 3 = right)

mouse_up(x, y, button)

When a mouse button is released on this component

  • x - The x coordinate of the mouse pointer within this component
  • y - The y coordinate of the mouse pointer within this component
  • button - The button that was released (1 = left, 2 = middle, 3 = right)


Label

Create a new ‘Label’ object


Base class: anvil.Component

Constructor

Label([width=], [spacing_above=], [spacing_below=], [text=], [align=], [font_size=], [font=], [bold=], [italic=], [underline=], [background=], [foreground=], [border=], [visible=], [role=], [icon=], [icon_align=], [tooltip=], [tag=])

Label Properties

align - string

Align this component’s text

background - color

The background colour of this component.

bold - boolean

Display this component’s text in bold

border - string

The border of this component.

font - string

The font to use for this component.

font_size - number

The height of text displayed on this component in pixels

foreground - color

The foreground colour of this component.

icon - icon

The icon to display on this component. Either a URL, or a FontAwesome Icon, e.g. ‘fa:user’.

icon_align - string

The alignment of the icon on this component. Set to ‘top’ for a centred icon on a component with no text.

italic - boolean

Display this component’s text in italics

parent

role - themeRole

Choose how this component can appear, based on your app’s visual theme.

spacing_above - string

The vertical space above this component.

spacing_below - string

The vertical space below this component.

tag - object

Use this property to store any extra information about this component

text - string

The text displayed on this component

tooltip - string

Text to display when you hover the mouse over this component

underline - boolean

Display this component’s text underlined

visible - boolean

Should this component be displayed?

width - string

The width of this Label, or “default” to have the width set by the container.


Label Events

show()

When the Label is shown on the screen

hide()

When the Label is removed from the screen


LinearPanel

Create a new ‘LinearPanel’ object


Base class: anvil.Container

Constructor

LinearPanel([width=], [spacing_above=], [spacing_below=], [row_spacing=], [background=], [foreground=], [border=], [visible=], [role=], [tooltip=], [tag=])

LinearPanel Methods

add_component(component, [index=None])

Add a component to this LinearPanel, in the ‘index’th position. If ‘index’ is not specified, adds to the bottom.


LinearPanel Properties

add_component - add_component

Add a component to this LinearPanel, in the ‘index’th position. If ‘index’ is not specified, adds to the bottom.

background - color

The background colour of this component.

border - string

The border of this component.

foreground - color

The foreground colour of this component.

parent

role - themeRole

Choose how this component can appear, based on your app’s visual theme.

row_spacing - number

The spacing between rows of components in this container, in pixels.

spacing_above - string

The vertical space above this component.

spacing_below - string

The vertical space below this component.

tag - object

Use this property to store any extra information about this component

tooltip - string

Text to display when you hover the mouse over this component

visible - boolean

Should this component be displayed?

width - string

The width of this LinearPanel, or “default” to have the width set by the container.


LinearPanel Events

show()

When the LinearPanel is shown on the screen

hide()

When the LinearPanel is removed from the screen


Create a new ‘Link’ object


Base class: anvil.LinearPanel
Link([url=], [text=], [align=], [font_size=], [font=], [bold=], [italic=], [underline=], [icon=], [icon_align=], [tooltip=], [tag=], [width=], [spacing_above=], [spacing_below=], [row_spacing=], [background=], [foreground=], [border=], [visible=], [role=])

align - string

Align this component’s text

bold - boolean

Display this component’s text in bold

font - string

The font to use for this component.

font_size - number

The height of text displayed on this component in pixels

icon - icon

The icon to display on this component. Either a URL, or a FontAwesome Icon, e.g. ‘fa:user’.

icon_align - string

The alignment of the icon on this component. Set to ‘top’ for a centred icon on a component with no text.

italic - boolean

Display this component’s text in italics

parent

tag - object

Use this property to store any extra information about this component

text - string

The text displayed on this component

tooltip - string

Text to display when you hover the mouse over this component

underline - boolean

Display this component’s text underlined

url - string

The target URL of the link. Can be set to a URL string or to a Media object.


click()

When the link is clicked

show()

When the Link is shown on the screen

hide()

When the Link is removed from the screen


Media

Create a new ‘Media’ object

Constructor

Media()

Instance Methods

get_bytes()

Get a binary string of the data represented by this Media object


Media Attributes

content_type - string

The MIME type of this Media

get_bytes - get_bytes

Get a binary string of the data represented by this Media object

length - number

The length of this Media, in bytes

name - string

The file name associated with this Media, or None if it has no name

url - string

The URL where you can download this Media, or None if it is not downloadable


Notification

Create a popup notification. Call the show() method to display it.

Constructor

Notification(message, [title=""], [style="info"], [timeout=2])

Instance Methods

__enter__() → anvil.Notification instance

Show the notification when entering a ‘with’ block

__exit__() → anvil.Notification instance

Hide the notification when exiting a ‘with’ block

hide()

Hides the notification immediately

show() → anvil.Notification instance

Shows the notification


Notification Attributes

__enter__ - __enter__

Show the notification when entering a ‘with’ block

__exit__ - __exit__

Hide the notification when exiting a ‘with’ block

hide - hide

Hides the notification immediately

show - show

Shows the notification


Plot

Create a new ‘Plot’ object


Base class: anvil.Component

Constructor

Plot([data=], [layout=], [interactive=], [width=], [spacing_above=], [spacing_below=], [height=], [visible=], [tooltip=], [tag=])

Plot Methods

extend_traces(data, traces)

Adds data to an existing trace.

prepend_traces(data, traces)

Prepends data to an existing trace.

redraw()

Redraws the chart. Call this function if you have updated data or layout properties.

relayout(update)

A more efficient means of updating just the layout in a graphDiv. The call signature and arguments for relayout are similar (but simpler) to restyle.

restyle(update, traces)

A more efficient means of changing attributes in the data array. When restyling, you may choose to have the specified changes effect as many traces as desired.

to_image(options) → anvil.URLMedia instance

Returns a Media object containing a snapshot of this plot. The argument is a dictionary specifying image options.


Plot Properties

data - object

Plot traces

extend_traces - extend_traces

Adds data to an existing trace.

height - string

The height of this component.

interactive - boolean

Whether this plot should be interactive

layout - plotly.graph_objs.Layout instance

Plot layout

parent

prepend_traces - prepend_traces

Prepends data to an existing trace.

redraw - redraw

Redraws the chart. Call this function if you have updated data or layout properties.

relayout - relayout

A more efficient means of updating just the layout in a graphDiv. The call signature and arguments for relayout are similar (but simpler) to restyle.

restyle - restyle

A more efficient means of changing attributes in the data array. When restyling, you may choose to have the specified changes effect as many traces as desired.

spacing_above - string

The vertical space above this component.

spacing_below - string

The vertical space below this component.

tag - object

Use this property to store any extra information about this component

to_image - to_image

Returns a Media object containing a snapshot of this plot. The argument is a dictionary specifying image options.

tooltip - string

Text to display when you hover the mouse over this component

visible - boolean

Should this component be displayed?

width - string

The width of this Plot, or “default” to have the width set by the container.


Plot Events

click(points)

when a data point is clicked.

  • points - A list of the data points that were clicked.

double_click()

when the plot is double-clicked.

select(points)

when a data point is selected.

  • points - A list of the data points that were selected.

hover(points)

when a data point is hovered.

  • points - A list of the data points that were hovered.

unhover(points)

when a data point is unhovered.

  • points - A list of the data points that were unhovered.

show()

When the Plot is shown on the screen

hide()

When the Plot is removed from the screen


RadioButton

Create a new ‘RadioButton’ object


Base class: anvil.Component

Constructor

RadioButton([selected=], [value=], [group_name=], [text=], [align=], [font_size=], [font=], [bold=], [italic=], [underline=], [width=], [spacing_above=], [spacing_below=], [enabled=], [background=], [foreground=], [border=], [visible=], [role=], [tooltip=], [tag=])

RadioButton Properties

align - string

Align this component’s text

background - color

The background colour of this component.

bold - boolean

Display this component’s text in bold

border - string

The border of this component.

enabled - boolean

True if this component should allow user interaction.

font - string

The font to use for this component.

font_size - number

The height of text displayed on this component in pixels

foreground - color

The foreground colour of this component.

group_name - string

The name of the group this radio button belongs to.

italic - boolean

Display this component’s text in italics

parent

role - themeRole

Choose how this component can appear, based on your app’s visual theme.

selected - boolean

The status of the radio button

spacing_above - string

The vertical space above this component.

spacing_below - string

The vertical space below this component.

tag - object

Use this property to store any extra information about this component

text - string

The text displayed on this component

tooltip - string

Text to display when you hover the mouse over this component

underline - boolean

Display this component’s text underlined

value - string

The value of the group when this radio button is selected

visible - boolean

Should this component be displayed?

width - string

The width of this RadioButton, or “default” to have the width set by the container.


RadioButton Events

clicked()

When this radio button is selected

show()

When the RadioButton is shown on the screen

hide()

When the RadioButton is removed from the screen


RepeatingPanel

Create a new ‘RepeatingPanel’ object


Base class: anvil.Component

Constructor

RepeatingPanel([item_template=], [items=], [background=], [foreground=], [border=], [visible=], [role=], [width=], [spacing_above=], [spacing_below=], [tooltip=], [tag=])

RepeatingPanel Methods

get_components()

Get the list of components created by this Repeating Panel. Each will be an instance of ‘item_template’, one for each item in ‘items’.

raise_event_on_children(event_name, event_args)

Trigger the ‘event_name’ event on all children of this component. Any keyword arguments are passed to the handler function.


RepeatingPanel Properties

background - color

The background colour of this component.

border - string

The border of this component.

foreground - color

The foreground colour of this component.

get_components - get_components

Get the list of components created by this Repeating Panel. Each will be an instance of ‘item_template’, one for each item in ‘items’.

item_template - form

The name of the form to repeat for every item

items - object

A list of items for which the ‘item_template’ will be instantiated.

parent

raise_event_on_children - raise_event_on_children

Trigger the ‘event_name’ event on all children of this component. Any keyword arguments are passed to the handler function.

role - themeRole

Choose how this component can appear, based on your app’s visual theme.

spacing_above - string

The vertical space above this component.

spacing_below - string

The vertical space below this component.

tag - object

Use this property to store any extra information about this component

tooltip - string

Text to display when you hover the mouse over this component

visible - boolean

Should this component be displayed?

width - string

The width of this RepeatingPanel, or “default” to have the width set by the container.


RepeatingPanel Events

show()

When the RepeatingPanel is shown on the screen

hide()

When the RepeatingPanel is removed from the screen


Spacer

Create a new ‘Spacer’ object


Base class: anvil.Component

Constructor

Spacer([visible=], [width=], [spacing_above=], [spacing_below=], [height=], [tooltip=], [tag=])

Spacer Properties

height - string

The height of this component.

parent

spacing_above - string

The vertical space above this component.

spacing_below - string

The vertical space below this component.

tag - object

Use this property to store any extra information about this component

tooltip - string

Text to display when you hover the mouse over this component

visible - boolean

Should this component be displayed?

width - string

The width of this Spacer, or “default” to have the width set by the container.


Spacer Events

show()

When the Spacer is shown on the screen

hide()

When the Spacer is removed from the screen


TextArea

Create a new ‘TextArea’ object


Base class: anvil.Component

Constructor

TextArea([placeholder=], [auto_expand=], [width=], [spacing_above=], [spacing_below=], [height=], [text=], [align=], [font_size=], [font=], [bold=], [italic=], [underline=], [enabled=], [background=], [foreground=], [border=], [visible=], [role=], [tooltip=], [tag=])

TextArea Methods

focus()

Set the keyboard focus to this TextArea

select()

Select all the text in this TextArea


TextArea Properties

align - string

Align this component’s text

auto_expand - boolean

If true, the text area will expand vertically to fit its contents

background - color

The background colour of this component.

bold - boolean

Display this component’s text in bold

border - string

The border of this component.

enabled - boolean

True if this component should allow user interaction.

focus - focus

Set the keyboard focus to this TextArea

font - string

The font to use for this component.

font_size - number

The height of text displayed on this component in pixels

foreground - color

The foreground colour of this component.

height - string

The height of this component.

italic - boolean

Display this component’s text in italics

parent

placeholder - string

The text to be displayed when the component is empty.

role - themeRole

Choose how this component can appear, based on your app’s visual theme.

select - select

Select all the text in this TextArea

spacing_above - string

The vertical space above this component.

spacing_below - string

The vertical space below this component.

tag - object

Use this property to store any extra information about this component

text - string

The text displayed on this component

tooltip - string

Text to display when you hover the mouse over this component

underline - boolean

Display this component’s text underlined

visible - boolean

Should this component be displayed?

width - string

The width of this TextArea, or “default” to have the width set by the container.


TextArea Events

change()

When the text in this text area is edited

show()

When the TextArea is shown on the screen

hide()

When the TextArea is removed from the screen

focus()

When the TextArea gets focus

lost_focus()

When the TextArea loses focus


TextBox

Create a new ‘TextBox’ object


Base class: anvil.Component

Constructor

TextBox([placeholder=], [hide_text=], [type=], [width=], [spacing_above=], [spacing_below=], [text=], [align=], [font_size=], [font=], [bold=], [italic=], [underline=], [enabled=], [background=], [foreground=], [border=], [visible=], [role=], [tooltip=], [tag=])

TextBox Methods

focus()

Set the keyboard focus to this TextBox

select()

Select the text in this TextBox


TextBox Properties

align - string

Align this component’s text

background - color

The background colour of this component.

bold - boolean

Display this component’s text in bold

border - string

The border of this component.

enabled - boolean

True if this component should allow user interaction.

focus - focus

Set the keyboard focus to this TextBox

font - string

The font to use for this component.

font_size - number

The height of text displayed on this component in pixels

foreground - color

The foreground colour of this component.

hide_text - boolean

Display stars instead of the text in this box

italic - boolean

Display this component’s text in italics

parent

placeholder - string

The text to be displayed when the component is empty.

role - themeRole

Choose how this component can appear, based on your app’s visual theme.

select - select

Select the text in this TextBox

spacing_above - string

The vertical space above this component.

spacing_below - string

The vertical space below this component.

tag - object

Use this property to store any extra information about this component

text - string

The text displayed on this component

tooltip - string

Text to display when you hover the mouse over this component

type - string

What type of data will be entered into this box?

underline - boolean

Display this component’s text underlined

visible - boolean

Should this component be displayed?

width - string

The width of this TextBox, or “default” to have the width set by the container.


TextBox Events

change()

When the text in this text box is edited

pressed_enter()

When the user presses Enter in this text box

show()

When the TextBox is shown on the screen

hide()

When the TextBox is removed from the screen

focus()

When the TextBox gets focus

lost_focus()

When the TextBox loses focus


Timer

Create a new ‘Timer’ object


Base class: anvil.Component

Constructor

Timer([interval=])

Timer Properties

interval - number

The number of seconds between each tick. 0 switches the timer off.

parent


Timer Events

tick()

Every [interval] seconds. Does not trigger if [interval] is 0.

show()

When this timer’s form is shown on the screen (or it is added to a visible form)

hide()

When this timer’s form is hidden from the screen (or it is removed from a visible form)


URLMedia

Create a Media object representing the data at a specific URL. Caution: Getting data from URLs directly in your code will often fail for security reasons, or fail to handle binary data.


Base class: anvil.Media

Constructor

URLMedia(url)

XYPanel

Create a new ‘XYPanel’ object


Base class: anvil.Container

Constructor

XYPanel([width=], [spacing_above=], [spacing_below=], [height=], [background=], [foreground=], [border=], [visible=], [role=], [align=], [tooltip=], [tag=])

XYPanel Methods

add_component(component, [x=0], [y=0], [width=None])

Add a component to this XYPanel, at the specified coordinates. If the component’s width is not specified, uses the component’s default width.

get_width() → number

Get the width of this XYPanel, in pixels.


XYPanel Properties

add_component - add_component

Add a component to this XYPanel, at the specified coordinates. If the component’s width is not specified, uses the component’s default width.

align - string

Align this component’s content

background - color

The background colour of this component.

border - string

The border of this component.

foreground - color

The foreground colour of this component.

get_width - get_width

Get the width of this XYPanel, in pixels.

height - string

The height of this component.

parent

role - themeRole

Choose how this component can appear, based on your app’s visual theme.

spacing_above - string

The vertical space above this component.

spacing_below - string

The vertical space below this component.

tag - object

Use this property to store any extra information about this component

tooltip - string

Text to display when you hover the mouse over this component

visible - boolean

Should this component be displayed?

width - string

The width of this XYPanel, or “default” to have the width set by the container.


XYPanel Events

show()

When the XYPanel is shown on the screen

hide()

When the XYPanel is removed from the screen


YouTubeVideo

Create a new ‘YouTubeVideo’ object


Base class: anvil.Component

Constructor

YouTubeVideo([youtube_id=], [autoplay=], [loop=], [current_time=], [volume=], [state=], [duration=], [mute=], [width=], [spacing_above=], [spacing_below=], [height=], [background=], [foreground=], [border=], [visible=], [role=], [tag=])

YouTubeVideo Methods

pause()

Pause this YouTube video

play()

Start playing this YouTube video

stop()

Stop playing this YouTube video


YouTubeVideo Properties

autoplay - boolean

Set to true to play this video immediately

background - color

The background colour of this component.

border - string

The border of this component.

current_time - object

Get or set the current playback position, in seconds.

duration - object

Get the duration of the video in seconds.

foreground - color

The foreground colour of this component.

height - string

The height of this component.

loop - boolean

Set to true to play this video repeatedly

mute - boolean

Set whether the video is muted or not.

parent

pause - pause

Pause this YouTube video

play - play

Start playing this YouTube video

role - themeRole

Choose how this component can appear, based on your app’s visual theme.

spacing_above - string

The vertical space above this component.

spacing_below - string

The vertical space below this component.

state - object

Get the current playback state of the video as a string. E.g. PLAYING

stop - stop

Stop playing this YouTube video

tag - object

Use this property to store any extra information about this component

visible - boolean

Should this component be displayed?

volume - object

Get or set the current volume, from 0 - 100.

width - string

The width of this YouTubeVideo, or “default” to have the width set by the container.

youtube_id - string

The ID of the YouTube video to play


YouTubeVideo Events

state_change(state)

When the video changes state (eg PAUSED to PLAYING)

  • state - The new state of the video (values from the YouTube API)

show()

When this video is shown on the screen (or it is added to a visible form)

hide()

When this video is hidden from the screen (or it is removed from a visible form)


Functions

alert(content, [title=""], [buttons=], [large=False], [dismissible=True])

Pop up an alert box. By default, it will have a single “OK” button which will return True when clicked.


confirm(content, [title=""], [buttons=], [large=False], [dismissible=False])

Pop up a confirmation box. By default, it will have “Yes” and “No” buttons which will return True and False respectively when clicked.


download(media)

Download the given Media Object immediately in the user’s browser.


anvil.form([undefined=]) → form component

Create a new ‘form’ object


get_focused_component() → anvil.Component instance

Get the currently focused Anvil component, or None if focus is not in a component.


get_open_form()

Returns the form most recently opened with open_form().


get_url_hash()

Get the decoded hash (the part after the ‘#’ character) of the URL used to open this app. If the first character of the hash is a question mark (eg ‘#?a=foo&b=bar’), it will be interpreted as query-string-type parameters and returned as a dictionary (eg {‘a’: ‘foo’, ‘b’: ‘bar’}).


open_form(form, args, kwargs)

Open the specified form as a new page.

If ‘form’ is a string, a new form will be created (extra arguments will be passed to its constructor). If ‘form’ is a Form object, it will be opened directly.


set_default_error_handling(handler_fn)

Set a function to be called when an uncaught exception occurs. If set to None, a pop-up will appear letting the user know that an error has occurred.


Globals

app

Information about the current app