anvil
Module
Classes
AppEnvironment
AppInfo
BlobMedia
Button
Canvas
CheckBox
ColumnPanel
Component
Container
DataGrid
DataRowPanel
DatePicker
DropDown
FileLoader
FlowPanel
GoogleMap
GridPanel
HtmlTemplate
Image
Label
LinearPanel
Link
Media
Notification
Plot
RadioButton
RepeatingPanel
RichText
Slot
Spacer
TextArea
TextBox
Timer
URLMedia
WithLayout
XYPanel
YouTubeVideo
Functions
alert
confirm
download
get_focused_component
get_open_form
get_url_hash
is_server_side
open_form
set_default_error_handling
set_url_hash
Globals
app
Classes
AppEnvironment
AppEnvironment Attributes
name - string
The name of the current environment
tags - list
tags associated with the current environment
AppInfo
AppInfo Attributes
branch - string
The Git branch from which the current app is being run. This is ‘master’ for development apps or apps without a published version, and ‘published’ if this app is being run from its published version.
environment - anvil.AppEnvironment instance
The environment in which the current app is being run.
id - string
A unique identifier for the current app
theme_colors - mapping
Theme colors for this app as a readonly dict.
BlobMedia
Create a Media object with the specified content_type (a string such as ’text/plain’) and content (a binary string). Optionally specify a filename as well.
Base class: anvil.Media
Constructor
BlobMedia(content_type, content, [name=None])
Button
(more info)
Create a new ‘Button’ object
Base class: anvil.Component
Constructor
Button([spacing_above=], [spacing_below=], [spacing=], [enabled=], [text=], [align=], [font_size=], [font=], [bold=], [italic=], [underline=], [background=], [foreground=], [border=], [visible=], [role=], [icon=], [icon_align=], [tag=], [tooltip=])
Button Methods
add_event_handler(event_name, handler_func)
Add an event handler function to be called when the event happens on this component. Event handlers will be called in the order they are added. Adding the same event handler multiple times will mean it gets called multiple times.
remove_event_handler(event_name, [handler_func])
Remove a specific event handler function for a given event. Calling remove_event_handler with just the event name will remove all the handlers for this event
set_event_handler(event_name, handler_func)
Set a function to call when the ’event_name’ event happens on this component. Using set_event_handler removes all other handlers. Setting the handler function to None removes all handlers.
Button Properties
align
- enum: "left"
, "center"
, "right"
, "full"
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. Can take any valid CSS border value.
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
- enum: "left_edge"
, "left"
, "top"
, "right"
, "right_edge"
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 - spacing
Margin and padding for this container. Only available in apps that have been migrated to use Layouts.
spacing_above
- enum: "none"
, "small"
, "medium"
, "large"
The vertical space above this component.
spacing_below
- enum: "none"
, "small"
, "medium"
, "large"
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?
Button Events
click(keys)
When the button is clicked
keys
- A dictionary of keys including 'shift', 'alt', 'ctrl', 'meta'. Each key's value is a boolean indicating if it was pressed during the click event. The meta key on a mac is the Command key
show()
When the Button is shown on the screen
hide()
When the Button is removed from the screen
Canvas
(more info)
Create a new ‘Canvas’ object
Base class: anvil.Component
Constructor
Canvas([spacing_above=], [spacing_below=], [margin=], [height=], [background=], [foreground=], [border=], [visible=], [role=], [tag=], [tooltip=])
Canvas Methods
add_color_stop(offset, color)
Creates a new color stop on the gradient object. The offset argument is a number between 0 and 1, and defines the relative position of the color in the gradient. The color argument must be a string representing a CSS color.
add_event_handler(event_name, handler_func)
Add an event handler function to be called when the event happens on this component. Event handlers will be called in the order they are added. Adding the same event handler multiple times will mean it gets called multiple times.
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).
remove_event_handler(event_name, [handler_func])
Remove a specific event handler function for a given event. Calling remove_event_handler with just the event name will remove all the handlers for this event
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_event_handler(event_name, handler_func)
Set a function to call when the ’event_name’ event happens on this component. Using set_event_handler removes all other handlers. Setting the handler function to None removes all handlers.
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
background - color
The background colour of this component.
border - string
The border of this component. Can take any valid CSS border value.
fill_style - string
The color or gradient to use when filling shapes and paths.
font - string
The font to use when drawing text on this canvas.
foreground - color
The foreground colour of this component.
global_alpha - number
The global opacity to draw with, in the range 0-1.
global_composite_operation - string
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_width - number
The width of lines drawn on this canvas.
margin - margin
Margin for this component. Only available in apps that have been migrated to use Layouts.
miter_limit - number
The limit of line join miters, in pixels.
parent
role - themeRole
Choose how this component can appear, based on your app’s visual theme.
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
- enum: "none"
, "small"
, "medium"
, "large"
The vertical space above this component.
spacing_below
- enum: "none"
, "small"
, "medium"
, "large"
The vertical space below this component.
stroke_style - string
The color or gradient to use when drawing outlines.
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
visible - boolean
Should this component be displayed?
Canvas Events
reset()
When the canvas is reset and cleared, such as when the window resizes, or the canvas is added to a form.
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 componenty
- 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 componenty
- 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 componenty
- The y coordinate of the mouse pointer within this component
mouse_down(x, y, button, keys)
When a mouse button is pressed on this component
x
- The x coordinate of the mouse pointer within this componenty
- The y coordinate of the mouse pointer within this componentbutton
- The button that was pressed (1 = left, 2 = middle, 3 = right)keys
- A dictionary of keys including 'shift', 'alt', 'ctrl', 'meta'. Each key's value is a boolean indicating if it was pressed during the click event. The meta key on a mac is the Command key
mouse_up(x, y, button, keys)
When a mouse button is released on this component
x
- The x coordinate of the mouse pointer within this componenty
- The y coordinate of the mouse pointer within this componentbutton
- The button that was released (1 = left, 2 = middle, 3 = right)keys
- A dictionary of keys including 'shift', 'alt', 'ctrl', 'meta'. Each key's value is a boolean indicating if it was pressed during the click event. The meta key on a mac is the Command key
CheckBox
(more info)
Create a new ‘CheckBox’ object
Base class: anvil.Component
Constructor
CheckBox([checked=], [allow_indeterminate=], [enabled=], [spacing_above=], [spacing_below=], [spacing=], [text=], [align=], [font_size=], [font=], [bold=], [italic=], [underline=], [background=], [foreground=], [border=], [visible=], [role=], [tooltip=], [tag=])
CheckBox Methods
add_event_handler(event_name, handler_func)
Add an event handler function to be called when the event happens on this component. Event handlers will be called in the order they are added. Adding the same event handler multiple times will mean it gets called multiple times.
focus()
Set the keyboard focus to this component
remove_event_handler(event_name, [handler_func])
Remove a specific event handler function for a given event. Calling remove_event_handler with just the event name will remove all the handlers for this event
set_event_handler(event_name, handler_func)
Set a function to call when the ’event_name’ event happens on this component. Using set_event_handler removes all other handlers. Setting the handler function to None removes all handlers.
CheckBox Properties
align
- enum: "left"
, "center"
, "right"
Align this component’s text
allow_indeterminate - boolean
Support an indeterminate state. The indeterminate state can only be set in code by setting checked=None.
background - color
The background colour of this component.
bold - boolean
Display this component’s text in bold
border - string
The border of this component. Can take any valid CSS border value.
checked - boolean
The status of the checkbox
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.
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 - spacing
Margin and padding for this container. Only available in apps that have been migrated to use Layouts.
spacing_above
- enum: "none"
, "small"
, "medium"
, "large"
The vertical space above this component.
spacing_below
- enum: "none"
, "small"
, "medium"
, "large"
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?
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
(more info)
Create a new ‘ColumnPanel’ object
Base class: anvil.Container
Constructor
ColumnPanel([col_widths=], [wrap_on=], [col_spacing=], [spacing_above=], [spacing_below=], [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]
add_event_handler(event_name, handler_func)
Add an event handler function to be called when the event happens on this component. Event handlers will be called in the order they are added. Adding the same event handler multiple times will mean it gets called multiple times.
remove_event_handler(event_name, [handler_func])
Remove a specific event handler function for a given event. Calling remove_event_handler with just the event name will remove all the handlers for this event
set_event_handler(event_name, handler_func)
Set a function to call when the ’event_name’ event happens on this component. Using set_event_handler removes all other handlers. Setting the handler function to None removes all handlers.
ColumnPanel Properties
background - color
The background colour of this component.
border - string
The border of this component. Can take any valid CSS border value.
col_spacing
- enum: "none"
, "tiny"
, "small"
, "medium"
, "large"
, "huge"
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.
spacing - spacing
Margin and padding for this container. Only available in apps that have been migrated to use Layouts.
spacing_above
- enum: "none"
, "small"
, "medium"
, "large"
The vertical space above this component.
spacing_below
- enum: "none"
, "small"
, "medium"
, "large"
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?
wrap_on
- enum: "never"
, "mobile"
, "tablet"
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
Create a new ‘Component’ object
Constructor
Component()
Instance Methods
add_event_handler(event_name, handler_func)
Add an event handler function to be called when the event happens on this component. Event handlers will be called in the order they are added. Adding the same event handler multiple times will mean it gets called multiple times.
get_event_handlers(event_name) → tuple_of_event_handlers
Get the current event_handlers for a given event_name
raise_event(event_name, **event_args)
Trigger the event on this component. Any keyword arguments are passed to the handler function.
remove_event_handler(event_name, [handler_func])
Remove a specific event handler function for a given event. Calling remove_event_handler with just the event name will remove all the handlers for this event
remove_from_parent()
Remove this component from its parent container.
scroll_into_view(smooth=False)
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. Using set_event_handler removes all other handlers. Setting the handler function to None removes all handlers.
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.
DataGrid
(more info)
Create a new ‘DataGrid’ object
Base class: anvil.Container
Constructor
DataGrid([columns=], [auto_header=], [show_page_controls=], [rows_per_page=], [wrap_on=], [spacing_above=], [spacing_below=], [margin=], [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.
add_event_handler(event_name, handler_func)
Add an event handler function to be called when the event happens on this component. Event handlers will be called in the order they are added. Adding the same event handler multiple times will mean it gets called multiple times.
get_page()
Get the current page number of this DataGrid
jump_to_first_page()
Jump to the first page of this DataGrid
jump_to_last_page()
Jump to the last page of this DataGrid
next_page()
Jump to the next page of this DataGrid
previous_page()
Jump to the previous page of this DataGrid
remove_event_handler(event_name, [handler_func])
Remove a specific event handler function for a given event. Calling remove_event_handler with just the event name will remove all the handlers for this event
set_event_handler(event_name, handler_func)
Set a function to call when the ’event_name’ event happens on this component. Using set_event_handler removes all other handlers. Setting the handler function to None removes all handlers.
set_page(page)
Set the page number of this DataGrid. The page number must be positive.
DataGrid Properties
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. Can take any valid CSS border value.
columns - dataGridColumns
A list of columns to display in this Data Grid.
foreground - color
The foreground colour of this component.
margin - margin
Margin for this component. Only available in apps that have been migrated to use Layouts.
parent
role - themeRole
Choose how this component can appear, based on your app’s visual theme.
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
- enum: "none"
, "small"
, "medium"
, "large"
The vertical space above this component.
spacing_below
- enum: "none"
, "small"
, "medium"
, "large"
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?
wrap_on
- enum: "never"
, "mobile"
, "tablet"
The largest display on which to wrap columns in this DataGrid
DataGrid Events
show()
When the DataGrid is shown on the screen
hide()
When the DataGrid is removed from the screen
DataRowPanel
(more info)
Create a new ‘DataRowPanel’ object
Base class: anvil.Container
Constructor
DataRowPanel([item=], [auto_display_data=], [align=], [font_size=], [font=], [bold=], [italic=], [underline=], [spacing_above=], [spacing_below=], [margin=], [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.
add_event_handler(event_name, handler_func)
Add an event handler function to be called when the event happens on this component. Event handlers will be called in the order they are added. Adding the same event handler multiple times will mean it gets called multiple times.
remove_event_handler(event_name, [handler_func])
Remove a specific event handler function for a given event. Calling remove_event_handler with just the event name will remove all the handlers for this event
set_event_handler(event_name, handler_func)
Set a function to call when the ’event_name’ event happens on this component. Using set_event_handler removes all other handlers. Setting the handler function to None removes all handlers.
DataRowPanel Properties
align
- enum: "left"
, "center"
, "right"
Align this component’s text
auto_display_data - boolean
Whether to automatically display data in this row.
background - color
The background colour of this component.
bold - boolean
Display this component’s text in bold
border - string
The border of this component. Can take any valid CSS border value.
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.
margin - margin
Margin for this component. Only available in apps that have been migrated to use Layouts.
parent
role - themeRole
Choose how this component can appear, based on your app’s visual theme.
spacing_above
- enum: "none"
, "small"
, "medium"
, "large"
The vertical space above this component.
spacing_below
- enum: "none"
, "small"
, "medium"
, "large"
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?
DataRowPanel Events
show()
When the DataRowPanel is shown on the screen
hide()
When the DataRowPanel is removed from the screen
DatePicker
(more info)
Create a new ‘DatePicker’ object
Base class: anvil.Component
Constructor
DatePicker([date=], [format=], [pick_time=], [min_date=], [max_date=], [placeholder=], [align=], [font_size=], [font=], [bold=], [italic=], [underline=], [spacing_above=], [spacing_below=], [margin=], [enabled=], [background=], [foreground=], [border=], [visible=], [role=], [tooltip=], [tag=])
DatePicker Methods
add_event_handler(event_name, handler_func)
Add an event handler function to be called when the event happens on this component. Event handlers will be called in the order they are added. Adding the same event handler multiple times will mean it gets called multiple times.
focus()
Set the keyboard focus to this DatePicker
remove_event_handler(event_name, [handler_func])
Remove a specific event handler function for a given event. Calling remove_event_handler with just the event name will remove all the handlers for this event
set_event_handler(event_name, handler_func)
Set a function to call when the ’event_name’ event happens on this component. Using set_event_handler removes all other handlers. Setting the handler function to None removes all handlers.
DatePicker Properties
align
- enum: "left"
, "center"
, "right"
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. Can take any valid CSS border value.
date - string
The date selected on 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.
format - string
The format in which to display the selected date.
italic - boolean
Display this component’s text in italics
margin - margin
Margin for this component. Only available in apps that have been migrated to use Layouts.
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
- enum: "none"
, "small"
, "medium"
, "large"
The vertical space above this component.
spacing_below
- enum: "none"
, "small"
, "medium"
, "large"
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?
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
DropDown
(more info)
Create a new ‘DropDown’ object
Base class: anvil.Component
Constructor
DropDown([items=], [selected_value=], [include_placeholder=], [placeholder=], [spacing_above=], [spacing_below=], [margin=], [enabled=], [align=], [font_size=], [font=], [bold=], [italic=], [underline=], [background=], [foreground=], [border=], [visible=], [role=], [tag=], [tooltip=])
DropDown Methods
add_event_handler(event_name, handler_func)
Add an event handler function to be called when the event happens on this component. Event handlers will be called in the order they are added. Adding the same event handler multiple times will mean it gets called multiple times.
focus()
Set the keyboard focus to this component
remove_event_handler(event_name, [handler_func])
Remove a specific event handler function for a given event. Calling remove_event_handler with just the event name will remove all the handlers for this event
set_event_handler(event_name, handler_func)
Set a function to call when the ’event_name’ event happens on this component. Using set_event_handler removes all other handlers. Setting the handler function to None removes all handlers.
DropDown Properties
align
- enum: "left"
, "center"
, "right"
, "full"
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. Can take any valid CSS border value.
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.
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.
margin - margin
Margin for this component. Only available in apps that have been migrated to use Layouts.
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
- enum: "none"
, "small"
, "medium"
, "large"
The vertical space above this component.
spacing_below
- enum: "none"
, "small"
, "medium"
, "large"
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?
DropDown Events
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
(more info)
Create a new ‘FileLoader’ object
Base class: anvil.Component
Constructor
FileLoader([multiple=], [show_state=], [file=], [files=], [file_types=], [spacing_above=], [spacing_below=], [spacing=], [text=], [align=], [font_size=], [font=], [bold=], [italic=], [underline=], [background=], [foreground=], [border=], [visible=], [role=], [icon=], [icon_align=], [enabled=], [tag=], [tooltip=])
FileLoader Methods
add_event_handler(event_name, handler_func)
Add an event handler function to be called when the event happens on this component. Event handlers will be called in the order they are added. Adding the same event handler multiple times will mean it gets called multiple times.
clear()
Clear any selected files from this FileLoader
focus()
Set the keyboard focus to this FileLoader
open_file_selector()
Open the file selector from code, this should be called within a click event handler for another component
remove_event_handler(event_name, [handler_func])
Remove a specific event handler function for a given event. Calling remove_event_handler with just the event name will remove all the handlers for this event
set_event_handler(event_name, handler_func)
Set a function to call when the ’event_name’ event happens on this component. Using set_event_handler removes all other handlers. Setting the handler function to None removes all handlers.
FileLoader Properties
align
- enum: "left"
, "center"
, "right"
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. Can take any valid CSS border value.
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.
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
- enum: "left_edge"
, "left"
, "top"
, "right"
, "right_edge"
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 - spacing
Margin and padding for this container. Only available in apps that have been migrated to use Layouts.
spacing_above
- enum: "none"
, "small"
, "medium"
, "large"
The vertical space above this component.
spacing_below
- enum: "none"
, "small"
, "medium"
, "large"
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?
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
(more info)
Create a new ‘FlowPanel’ object
Base class: anvil.Container
Constructor
FlowPanel([align=], [vertical_align=], [gap=], [background=], [foreground=], [border=], [visible=], [role=], [tag=], [spacing_above=], [spacing_below=], [spacing=], [tooltip=])
FlowPanel Methods
add_component(component, [index=], [width=], [expand=])
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.
add_event_handler(event_name, handler_func)
Add an event handler function to be called when the event happens on this component. Event handlers will be called in the order they are added. Adding the same event handler multiple times will mean it gets called multiple times.
remove_event_handler(event_name, [handler_func])
Remove a specific event handler function for a given event. Calling remove_event_handler with just the event name will remove all the handlers for this event
set_event_handler(event_name, handler_func)
Set a function to call when the ’event_name’ event happens on this component. Using set_event_handler removes all other handlers. Setting the handler function to None removes all handlers.
FlowPanel Properties
align
- enum: "left"
, "center"
, "right"
, "justify"
Align this component’s content
background - color
The background colour of this component.
border - string
The border of this component. Can take any valid CSS border value.
foreground - color
The foreground colour of this component.
gap
- enum: "none"
, "tiny"
, "small"
, "medium"
, "large"
, "huge"
Gap between components
parent
role - themeRole
Choose how this component can appear, based on your app’s visual theme.
spacing - spacing
Margin and padding for this container. Only available in apps that have been migrated to use Layouts.
spacing_above
- enum: "none"
, "small"
, "medium"
, "large"
The vertical space above this component.
spacing_below
- enum: "none"
, "small"
, "medium"
, "large"
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
- enum: "top"
, "middle"
, "bottom"
, "full"
Align this component’s content
visible - boolean
Should this component be displayed?
FlowPanel Events
show()
When the FlowPanel is shown on the screen
hide()
When the FlowPanel is removed from the screen
GoogleMap
(more info)
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=], [spacing_above=], [spacing_below=], [margin=], [height=], [visible=], [tag=])
GoogleMap Methods
add_event_handler(event_name, handler_func)
Add an event handler function to be called when the event happens on this component. Event handlers will be called in the order they are added. Adding the same event handler multiple times will mean it gets called multiple times.
compute_area()
Returns the area of a closed path in square meters.
compute_length()
Returns the length of a path in meters.
remove_event_handler(event_name, [handler_func])
Remove a specific event handler function for a given event. Calling remove_event_handler with just the event name will remove all the handlers for this event
set_event_handler(event_name, handler_func)
Set a function to call when the ’event_name’ event happens on this component. Using set_event_handler removes all other handlers. Setting the handler function to None removes all handlers.
GoogleMap Properties
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.
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.
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
margin - margin
Margin for this component. Only available in apps that have been migrated to use Layouts.
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.
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
- enum: "none"
, "small"
, "medium"
, "large"
The vertical space above this component.
spacing_below
- enum: "none"
, "small"
, "medium"
, "large"
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?
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
(more info)
Create a new ‘GridPanel’ object
Base class: anvil.Container
Constructor
GridPanel([spacing_above=], [spacing_below=], [spacing=], [background=], [foreground=], [border=], [visible=], [role=], [tag=], [tooltip=])
GridPanel Methods
add_component(component, [row=], [col_xs=], [width_xs=])
Add a component to this GridPanel
add_event_handler(event_name, handler_func)
Add an event handler function to be called when the event happens on this component. Event handlers will be called in the order they are added. Adding the same event handler multiple times will mean it gets called multiple times.
remove_event_handler(event_name, [handler_func])
Remove a specific event handler function for a given event. Calling remove_event_handler with just the event name will remove all the handlers for this event
set_event_handler(event_name, handler_func)
Set a function to call when the ’event_name’ event happens on this component. Using set_event_handler removes all other handlers. Setting the handler function to None removes all handlers.
GridPanel Properties
background - color
The background colour of this component.
border - string
The border of this component. Can take any valid CSS border value.
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 - spacing
Margin and padding for this container. Only available in apps that have been migrated to use Layouts.
spacing_above
- enum: "none"
, "small"
, "medium"
, "large"
The vertical space above this component.
spacing_below
- enum: "none"
, "small"
, "medium"
, "large"
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?
GridPanel Events
show()
When the GridPanel is shown on the screen
hide()
When the GridPanel is removed from the screen
HtmlTemplate
(more info)
Create a new ‘HtmlTemplate’ object
Base class: anvil.Container
Constructor
HtmlTemplate([html=], [tag=], [tooltip=], [background=], [foreground=], [border=], [visible=], [role=])
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.
add_event_handler(event_name, handler_func)
Add an event handler function to be called when the event happens on this component. Event handlers will be called in the order they are added. Adding the same event handler multiple times will mean it gets called multiple times.
call_js(js_function_name, *args)
Call a Javascript function
clear([slot="default"])
clear the HTML template of all components or clear a specific slot of components.
remove_event_handler(event_name, [handler_func])
Remove a specific event handler function for a given event. Calling remove_event_handler with just the event name will remove all the handlers for this event
set_event_handler(event_name, handler_func)
Set a function to call when the ’event_name’ event happens on this component. Using set_event_handler removes all other handlers. Setting the handler function to None removes all handlers.
HtmlTemplate Properties
background - color
The background colour of this component.
border - string
The border of this component. Can take any valid CSS border value.
dom_nodes - dict
A read-only dictionary allowing you to look up the DOM node by name for any HTML tag in this component’s HTML that has an anvil-name= attribute.
foreground - color
The foreground colour of this component.
html - html
The HTML from which this panel is defined
parent
role - themeRole
Choose how this component can appear, based on your app’s visual theme.
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?
HtmlTemplate Events
show()
When the HtmlTemplate is shown on the screen
hide()
When the HtmlTemplate is removed from the screen
Image
(more info)
Create a new ‘Image’ object
Base class: anvil.Component
Constructor
Image([alt_text=], [display_mode=], [border_radius=], [horizontal_align=], [vertical_align=], [source=], [spacing_above=], [spacing_below=], [margin=], [height=], [background=], [foreground=], [border=], [visible=], [role=], [tooltip=], [tag=])
Image Methods
add_event_handler(event_name, handler_func)
Add an event handler function to be called when the event happens on this component. Event handlers will be called in the order they are added. Adding the same event handler multiple times will mean it gets called multiple times.
remove_event_handler(event_name, [handler_func])
Remove a specific event handler function for a given event. Calling remove_event_handler with just the event name will remove all the handlers for this event
set_event_handler(event_name, handler_func)
Set a function to call when the ’event_name’ event happens on this component. Using set_event_handler removes all other handlers. Setting the handler function to None removes all handlers.
Image Properties
alt_text - string
Textual replacement for the image used by screen readers and displayed on the page if the image can’t be loaded
background - color
The background colour of this component.
border - string
The border of this component. Can take any valid CSS border value.
border_radius - string
The border radius of this component
display_mode
- enum: "shrink_to_fit"
, "zoom_to_fill"
, "fill_width"
, "original_size"
Determines how the image’s size should be adjusted to fit the size of this Image component.
shrink_to_fit
scales the image to fit while maintaining its aspect ratio.zoom_to_fill
scales the image to fill the entire container while maintaining its aspect ratio. If the image is too large, it will be cropped to fit.fill_width
shrinks or grows the image so the width fits the container.original_size
- displays the image at whatever the browser thinks the original size is. If that would cause the image to be wider than the Image component, it shrinks the image to ensure it fits within the width of the Image component.
foreground - color
The foreground colour of this component.
height - string
The height of this component.
horizontal_align
- enum: "left"
, "center"
, "right"
Position the image horizontally within this component
margin - margin
Margin for this component. Only available in apps that have been migrated to use Layouts.
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
- enum: "none"
, "small"
, "medium"
, "large"
The vertical space above this component.
spacing_below
- enum: "none"
, "small"
, "medium"
, "large"
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
- enum: "top"
, "center"
, "bottom"
Position the image vertically within this component
visible - boolean
Should this component be displayed?
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 componenty
- 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 componenty
- 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 componenty
- The y coordinate of the mouse pointer within this component
mouse_down(x, y, button, keys)
When a mouse button is pressed on this component
x
- The x coordinate of the mouse pointer within this componenty
- The y coordinate of the mouse pointer within this componentbutton
- The button that was pressed (1 = left, 2 = middle, 3 = right)keys
- A dictionary of keys including 'shift', 'alt', 'ctrl', 'meta'. Each key's value is a boolean indicating if it was pressed during the click event. The meta key on a mac is the Command key
mouse_up(x, y, button, keys)
When a mouse button is released on this component
x
- The x coordinate of the mouse pointer within this componenty
- The y coordinate of the mouse pointer within this componentbutton
- The button that was released (1 = left, 2 = middle, 3 = right)keys
- A dictionary of keys including 'shift', 'alt', 'ctrl', 'meta'. Each key's value is a boolean indicating if it was pressed during the click event. The meta key on a mac is the Command key
Label
(more info)
Create a new ‘Label’ object
Base class: anvil.Component
Constructor
Label([spacing_above=], [spacing_below=], [spacing=], [text=], [align=], [font_size=], [font=], [bold=], [italic=], [underline=], [background=], [foreground=], [border=], [visible=], [role=], [icon=], [icon_align=], [tooltip=], [tag=])
Label Methods
add_event_handler(event_name, handler_func)
Add an event handler function to be called when the event happens on this component. Event handlers will be called in the order they are added. Adding the same event handler multiple times will mean it gets called multiple times.
remove_event_handler(event_name, [handler_func])
Remove a specific event handler function for a given event. Calling remove_event_handler with just the event name will remove all the handlers for this event
set_event_handler(event_name, handler_func)
Set a function to call when the ’event_name’ event happens on this component. Using set_event_handler removes all other handlers. Setting the handler function to None removes all handlers.
Label Properties
align
- enum: "left"
, "center"
, "right"
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. Can take any valid CSS border value.
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
- enum: "left_edge"
, "left"
, "top"
, "right"
, "right_edge"
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 - spacing
Margin and padding for this container. Only available in apps that have been migrated to use Layouts.
spacing_above
- enum: "none"
, "small"
, "medium"
, "large"
The vertical space above this component.
spacing_below
- enum: "none"
, "small"
, "medium"
, "large"
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?
Label Events
show()
When the Label is shown on the screen
hide()
When the Label is removed from the screen
LinearPanel
(more info)
Create a new ‘LinearPanel’ object
Base class: anvil.Container
Constructor
LinearPanel([spacing_above=], [spacing_below=], [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.
add_event_handler(event_name, handler_func)
Add an event handler function to be called when the event happens on this component. Event handlers will be called in the order they are added. Adding the same event handler multiple times will mean it gets called multiple times.
remove_event_handler(event_name, [handler_func])
Remove a specific event handler function for a given event. Calling remove_event_handler with just the event name will remove all the handlers for this event
set_event_handler(event_name, handler_func)
Set a function to call when the ’event_name’ event happens on this component. Using set_event_handler removes all other handlers. Setting the handler function to None removes all handlers.
LinearPanel Properties
background - color
The background colour of this component.
border - string
The border of this component. Can take any valid CSS border value.
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 - spacing
Margin and padding for this container. Only available in apps that have been migrated to use Layouts.
spacing_above
- enum: "none"
, "small"
, "medium"
, "large"
The vertical space above this component.
spacing_below
- enum: "none"
, "small"
, "medium"
, "large"
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?
LinearPanel Events
show()
When the LinearPanel is shown on the screen
hide()
When the LinearPanel is removed from the screen
Link
(more info)
Create a new ‘Link’ object
Base class: anvil.ColumnPanel
Constructor
Link([url=], [text_padding=], [text=], [align=], [font_size=], [font=], [bold=], [italic=], [underline=], [icon=], [icon_align=], [tooltip=], [tag=], [col_widths=], [wrap_on=], [col_spacing=], [spacing_above=], [spacing_below=], [spacing=], [background=], [foreground=], [border=], [visible=], [role=])
Link Methods
add_event_handler(event_name, handler_func)
Add an event handler function to be called when the event happens on this component. Event handlers will be called in the order they are added. Adding the same event handler multiple times will mean it gets called multiple times.
remove_event_handler(event_name, [handler_func])
Remove a specific event handler function for a given event. Calling remove_event_handler with just the event name will remove all the handlers for this event
set_event_handler(event_name, handler_func)
Set a function to call when the ’event_name’ event happens on this component. Using set_event_handler removes all other handlers. Setting the handler function to None removes all handlers.
Link Properties
align
- enum: "left"
, "center"
, "right"
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
- enum: "left_edge"
, "left"
, "top"
, "right"
, "right_edge"
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
text_padding - padding
Padding for the link text. Only available in apps that have been migrated to use Layouts.
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.
Link Events
click(keys)
When the link is clicked
keys
- A dictionary of keys including 'shift', 'alt', 'ctrl', 'meta'. Each key's value is a boolean indicating if it was pressed during the click event. The meta key on a mac is the Command key
Media
Create a new ‘Media’ object
Constructor
Media()
Instance Methods
get_bytes()
Get a binary string of the data represented by this Media object
get_url()
Get a Media object’s URL, or None if there isn’t one associated with it.
Media Attributes
content_type - string
The MIME type of this Media
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
Plot
(more info)
Create a new ‘Plot’ object
Base class: anvil.Component
Constructor
Plot([data=], [layout=], [config=], [figure=], [interactive=], [spacing_above=], [spacing_below=], [margin=], [height=], [visible=], [tooltip=], [tag=])
Plot Methods
add_event_handler(event_name, handler_func)
Add an event handler function to be called when the event happens on this component. Event handlers will be called in the order they are added. Adding the same event handler multiple times will mean it gets called multiple times.
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.
remove_event_handler(event_name, [handler_func])
Remove a specific event handler function for a given event. Calling remove_event_handler with just the event name will remove all the handlers for this event
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.
set_event_handler(event_name, handler_func)
Set a function to call when the ’event_name’ event happens on this component. Using set_event_handler removes all other handlers. Setting the handler function to None removes all handlers.
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
config - dict
Plot config
data - object
Plot traces
figure - dict
The Plotly figure to display. Specifies layout and data.
height - string
The height of this component.
interactive - boolean
Whether this plot should be interactive
layout - plotly.graph_objs.Layout instance
Plot layout
margin - margin
Margin for this component. Only available in apps that have been migrated to use Layouts.
parent
spacing_above
- enum: "none"
, "small"
, "medium"
, "large"
The vertical space above this component.
spacing_below
- enum: "none"
, "small"
, "medium"
, "large"
The vertical space below this component.
tag - object
Use this property to store any extra information about this component
templates - mapping
plotly templates, see plotly docs for valid template names. Set the default template using Plot.templates.default = ‘seaborn’.
tooltip - string
Text to display when you hover the mouse over this component
visible - boolean
Should this component be displayed?
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.
afterplot()
after then plot is redrawn.
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
(more info)
Create a new ‘RadioButton’ object
Base class: anvil.Component
Constructor
RadioButton([selected=], [value=], [group_name=], [text=], [align=], [font_size=], [font=], [bold=], [italic=], [underline=], [spacing_above=], [spacing_below=], [spacing=], [enabled=], [background=], [foreground=], [border=], [visible=], [role=], [tooltip=], [tag=])
RadioButton Methods
add_event_handler(event_name, handler_func)
Add an event handler function to be called when the event happens on this component. Event handlers will be called in the order they are added. Adding the same event handler multiple times will mean it gets called multiple times.
get_group_value() → str
returns the value of the button in the group which is pressed.
remove_event_handler(event_name, [handler_func])
Remove a specific event handler function for a given event. Calling remove_event_handler with just the event name will remove all the handlers for this event
set_event_handler(event_name, handler_func)
Set a function to call when the ’event_name’ event happens on this component. Using set_event_handler removes all other handlers. Setting the handler function to None removes all handlers.
RadioButton Properties
align
- enum: "left"
, "center"
, "right"
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. Can take any valid CSS border value.
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 - spacing
Margin and padding for this container. Only available in apps that have been migrated to use Layouts.
spacing_above
- enum: "none"
, "small"
, "medium"
, "large"
The vertical space above this component.
spacing_below
- enum: "none"
, "small"
, "medium"
, "large"
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?
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
(more info)
Create a new ‘RepeatingPanel’ object
Base class: anvil.Component
Constructor
RepeatingPanel([item_template=], [items=], [background=], [foreground=], [border=], [visible=], [role=], [spacing_above=], [spacing_below=], [margin=], [tooltip=], [tag=])
RepeatingPanel Methods
add_event_handler(event_name, handler_func)
Add an event handler function to be called when the event happens on this component. Event handlers will be called in the order they are added. Adding the same event handler multiple times will mean it gets called multiple times.
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.
remove_event_handler(event_name, [handler_func])
Remove a specific event handler function for a given event. Calling remove_event_handler with just the event name will remove all the handlers for this event
set_event_handler(event_name, handler_func)
Set a function to call when the ’event_name’ event happens on this component. Using set_event_handler removes all other handlers. Setting the handler function to None removes all handlers.
RepeatingPanel Properties
background - color
The background colour of this component.
border - string
The border of this component. Can take any valid CSS border value.
foreground - color
The foreground colour of this component.
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.
margin - margin
Margin for this component. Only available in apps that have been migrated to use Layouts.
parent
role - themeRole
Choose how this component can appear, based on your app’s visual theme.
spacing_above
- enum: "none"
, "small"
, "medium"
, "large"
The vertical space above this component.
spacing_below
- enum: "none"
, "small"
, "medium"
, "large"
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?
RepeatingPanel Events
show()
When the RepeatingPanel is shown on the screen
hide()
When the RepeatingPanel is removed from the screen
RichText
(more info)
Create a new ‘RichText’ object
Base class: anvil.Container
Constructor
RichText([content=], [format=], [enable_slots=], [data=], [align=], [font_size=], [font=], [spacing_above=], [spacing_below=], [spacing=], [background=], [foreground=], [border=], [visible=], [role=], [tooltip=], [tag=])
RichText Methods
add_component(component, slot)
Add a component to this panel, in the specified slot
add_event_handler(event_name, handler_func)
Add an event handler function to be called when the event happens on this component. Event handlers will be called in the order they are added. Adding the same event handler multiple times will mean it gets called multiple times.
clear([slot="slot_name"])
clear the Rich Text Component of all components or clear a specific slot of components.
remove_event_handler(event_name, [handler_func])
Remove a specific event handler function for a given event. Calling remove_event_handler with just the event name will remove all the handlers for this event
set_event_handler(event_name, handler_func)
Set a function to call when the ’event_name’ event happens on this component. Using set_event_handler removes all other handlers. Setting the handler function to None removes all handlers.
RichText Properties
align
- enum: "left"
, "center"
, "right"
Align this component’s text
background - color
The background colour of this component.
border - string
The border of this component. Can take any valid CSS border value.
content - string
The content to render in this component, in the format specified by the ‘format’ property
data - object
A dict of data or Components to populate the named content {slots}. Can also be a dict-like object.
enable_slots - boolean
If true {braces} in content define slots. If false, braces in content display normally.
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
- enum: "markdown"
, "plain_text"
, "restricted_html"
The format of the content of this component.
parent
role - themeRole
Choose how this component can appear, based on your app’s visual theme.
spacing - spacing
Margin and padding for this container. Only available in apps that have been migrated to use Layouts.
spacing_above
- enum: "none"
, "small"
, "medium"
, "large"
The vertical space above this component.
spacing_below
- enum: "none"
, "small"
, "medium"
, "large"
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?
RichText Events
show()
When the RichText is shown on the screen
hide()
When the RichText is removed from the screen
Slot
A Slot class represents a way to add components to an underlying container. You will rarely instantiate a Slot on its own; instead your form’s layout will contain Slots to which you can add components.
Constructor
Slot(target_container, insertion_index, [layout_properties])
target_container
- The target container into which components added to this slot will be added.insertion_index
- The starting index (within the target container) at which components added to this slot will be inserted.layout_properties
- A dictionary of layout properties that will be passed as keyword arguments to the target container's add_component() call, overriding any values provided to the slot's add_component().
Instance Methods
add_component(component, [index=None], **layout_properties)
Add a component to this slot.
Calling add_component() on a Slot will add the specified component to its target container.
component
- The component to add to this slot.index
- The index, within the slot, at which the component is to be inserted. Note: This argument is index is within the Slot, not within the target container. The Slot will adjust for its own insertion_index, as well as components in any previous slots registered with offset_by_slot(), when computing the index= parameter to the target container's add_component() method.layout_properties
- Layout properties will be passed on as keyword arguments to the target container's add_component() method, unless overridden by the Slot.
offset_by_slot(offset_by_slot)
Inform this Slot of an earlier Slot with the same target container. Future calls to add_component() will take account of any components inserted into the earlier slot when calculating the insertion index for the target container, thereby preserving ordering between the two slots’ components.
Spacer
(more info)
Create a new ‘Spacer’ object
Base class: anvil.Component
Constructor
Spacer([visible=], [spacing_above=], [spacing_below=], [height=], [tooltip=], [tag=])
Spacer Methods
add_event_handler(event_name, handler_func)
Add an event handler function to be called when the event happens on this component. Event handlers will be called in the order they are added. Adding the same event handler multiple times will mean it gets called multiple times.
remove_event_handler(event_name, [handler_func])
Remove a specific event handler function for a given event. Calling remove_event_handler with just the event name will remove all the handlers for this event
set_event_handler(event_name, handler_func)
Set a function to call when the ’event_name’ event happens on this component. Using set_event_handler removes all other handlers. Setting the handler function to None removes all handlers.
Spacer Properties
height - string
The height of this component.
parent
spacing_above
- enum: "none"
, "small"
, "medium"
, "large"
The vertical space above this component.
spacing_below
- enum: "none"
, "small"
, "medium"
, "large"
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?
Spacer Events
show()
When the Spacer is shown on the screen
hide()
When the Spacer is removed from the screen
TextArea
(more info)
Create a new ‘TextArea’ object
Base class: anvil.Component
Constructor
TextArea([placeholder=], [auto_expand=], [spacing_above=], [spacing_below=], [margin=], [height=], [text=], [align=], [font_size=], [font=], [bold=], [italic=], [underline=], [enabled=], [background=], [foreground=], [border=], [visible=], [role=], [tooltip=], [tag=])
TextArea Methods
add_event_handler(event_name, handler_func)
Add an event handler function to be called when the event happens on this component. Event handlers will be called in the order they are added. Adding the same event handler multiple times will mean it gets called multiple times.
focus()
Set the keyboard focus to this TextArea
remove_event_handler(event_name, [handler_func])
Remove a specific event handler function for a given event. Calling remove_event_handler with just the event name will remove all the handlers for this event
select()
Select all the text in this TextArea
set_event_handler(event_name, handler_func)
Set a function to call when the ’event_name’ event happens on this component. Using set_event_handler removes all other handlers. Setting the handler function to None removes all handlers.
TextArea Properties
align
- enum: "left"
, "center"
, "right"
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. Can take any valid CSS border value.
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.
height - string
The height of this component.
italic - boolean
Display this component’s text in italics
margin - margin
Margin for this component. Only available in apps that have been migrated to use Layouts.
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.
spacing_above
- enum: "none"
, "small"
, "medium"
, "large"
The vertical space above this component.
spacing_below
- enum: "none"
, "small"
, "medium"
, "large"
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?
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
(more info)
Create a new ‘TextBox’ object
Base class: anvil.Component
Constructor
TextBox([placeholder=], [hide_text=], [type=], [spacing_above=], [spacing_below=], [margin=], [text=], [align=], [font_size=], [font=], [bold=], [italic=], [underline=], [enabled=], [background=], [foreground=], [border=], [visible=], [role=], [tooltip=], [tag=])
TextBox Methods
add_event_handler(event_name, handler_func)
Add an event handler function to be called when the event happens on this component. Event handlers will be called in the order they are added. Adding the same event handler multiple times will mean it gets called multiple times.
focus()
Set the keyboard focus to this TextBox
remove_event_handler(event_name, [handler_func])
Remove a specific event handler function for a given event. Calling remove_event_handler with just the event name will remove all the handlers for this event
select()
Select the text in this TextBox
set_event_handler(event_name, handler_func)
Set a function to call when the ’event_name’ event happens on this component. Using set_event_handler removes all other handlers. Setting the handler function to None removes all handlers.
TextBox Properties
align
- enum: "left"
, "center"
, "right"
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. Can take any valid CSS border value.
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.
hide_text - boolean
Display stars instead of the text in this box
italic - boolean
Display this component’s text in italics
margin - margin
Margin for this component. Only available in apps that have been migrated to use Layouts.
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.
spacing_above
- enum: "none"
, "small"
, "medium"
, "large"
The vertical space above this component.
spacing_below
- enum: "none"
, "small"
, "medium"
, "large"
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
- enum: "text"
, "number"
, "email"
, "tel"
, "url"
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?
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
(more info)
Create a new ‘Timer’ object
Base class: anvil.Component
Constructor
Timer([interval=])
Timer Methods
add_event_handler(event_name, handler_func)
Add an event handler function to be called when the event happens on this component. Event handlers will be called in the order they are added. Adding the same event handler multiple times will mean it gets called multiple times.
remove_event_handler(event_name, [handler_func])
Remove a specific event handler function for a given event. Calling remove_event_handler with just the event name will remove all the handlers for this event
set_event_handler(event_name, handler_func)
Set a function to call when the ’event_name’ event happens on this component. Using set_event_handler removes all other handlers. Setting the handler function to None removes all handlers.
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)
WithLayout
Parent class of any form with a layout.
Base class: anvil.Component
Constructor
WithLayout()
WithLayout Attributes
layout - anvil.Component instance
This form’s layout.
XYPanel
(more info)
Create a new ‘XYPanel’ object
Base class: anvil.Container
Constructor
XYPanel([spacing_above=], [spacing_below=], [margin=], [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.
add_event_handler(event_name, handler_func)
Add an event handler function to be called when the event happens on this component. Event handlers will be called in the order they are added. Adding the same event handler multiple times will mean it gets called multiple times.
get_width() → number
Get the width of this XYPanel, in pixels.
remove_event_handler(event_name, [handler_func])
Remove a specific event handler function for a given event. Calling remove_event_handler with just the event name will remove all the handlers for this event
set_event_handler(event_name, handler_func)
Set a function to call when the ’event_name’ event happens on this component. Using set_event_handler removes all other handlers. Setting the handler function to None removes all handlers.
XYPanel Properties
align
- enum: "left"
, "center"
, "right"
Align this component’s content
background - color
The background colour of this component.
border - string
The border of this component. Can take any valid CSS border value.
foreground - color
The foreground colour of this component.
height - string
The height of this component.
margin - margin
Margin for this component. Only available in apps that have been migrated to use Layouts.
parent
role - themeRole
Choose how this component can appear, based on your app’s visual theme.
spacing_above
- enum: "none"
, "small"
, "medium"
, "large"
The vertical space above this component.
spacing_below
- enum: "none"
, "small"
, "medium"
, "large"
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?
XYPanel Events
show()
When the XYPanel is shown on the screen
hide()
When the XYPanel is removed from the screen
YouTubeVideo
(more info)
Create a new ‘YouTubeVideo’ object
Base class: anvil.Component
Constructor
YouTubeVideo([youtube_id=], [autoplay=], [loop=], [current_time=], [volume=], [state=], [duration=], [mute=], [spacing_above=], [spacing_below=], [margin=], [height=], [background=], [foreground=], [border=], [visible=], [role=], [tag=])
YouTubeVideo Methods
add_event_handler(event_name, handler_func)
Add an event handler function to be called when the event happens on this component. Event handlers will be called in the order they are added. Adding the same event handler multiple times will mean it gets called multiple times.
pause()
Pause this YouTube video
play()
Start playing this YouTube video
remove_event_handler(event_name, [handler_func])
Remove a specific event handler function for a given event. Calling remove_event_handler with just the event name will remove all the handlers for this event
set_event_handler(event_name, handler_func)
Set a function to call when the ’event_name’ event happens on this component. Using set_event_handler removes all other handlers. Setting the handler function to None removes all handlers.
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. Can take any valid CSS border value.
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
margin - margin
Margin for this component. Only available in apps that have been migrated to use Layouts.
mute - boolean
Set whether the video is muted or not.
parent
role - themeRole
Choose how this component can appear, based on your app’s visual theme.
spacing_above
- enum: "none"
, "small"
, "medium"
, "large"
The vertical space above this component.
spacing_below
- enum: "none"
, "small"
, "medium"
, "large"
The vertical space below this component.
state - object
Get the current playback state of the video as a string. E.g. PLAYING
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.
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], [role=])
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], [role=])
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.
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’}).
is_server_side() → boolean
Check whether Anvil is running server side or not.
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.
set_url_hash(val)
Sets the hash of the currently open URL. If val is a string, it is added to the URL after a #. If val is a dictionary, it will be interpreted as query-string-type parameters and added to the URL after a hash and question mark (eg ‘#?a=foo&b=bar’).
Globals
app
Information about the current app, as an instance of anvil.AppInfo
Do you still have questions?
Our Community Forum is full of helpful information and Anvil experts.