Skip to content

image class

A control that can display an image.

Methods

__init__()

__init__(
    content=None,
    label=None,
    on_action=None,
    width="300px",
    height=None,
    active=True,
    id=None,
    properties=None,
    class_name=None,
    hover_text=None,
) -> None

Create a new image element.

Parameters:

Name Type Description Default

content

Union[path,URL,file,ReadableBuffer]
dynamic

The image source.
If a buffer is provided (string, array of bytes...), and in order to prevent the bandwidth to be consumed too much, the way the image data is transferred depends on the data_url_max_size parameter of the application configuration (which is set to 50kB by default):

  • If the size of the buffer is smaller than this setting, then the raw content is generated as a data URL, encoded using base64 (i.e. "data:<mimetype>;base64,<data>").
  • If the size of the buffer is greater than this setting, then it is transferred through a temporary file.
None

label

str
dynamic

The label for this image.

None

on_action

Union[str, Callable]

A function or the name of a function that is triggered when the user clicks on the image.
This function is invoked with the following parameters:

  • state (State): the state instance.
  • id (str): the identifier of the button if it has one.
  • payload (dict): a dictionary that contains the key "action" set to the name of the action that triggered this callback.
None

width

Union[str, int, float]

The width of this image control, in CSS units.

300px

height

Union[str, int, float]

The height of this image control, in CSS units.

None

active

bool
dynamic

Indicates if this component is active.
An inactive component allows no user interaction.

True

id

str

The identifier that is assigned to the rendered HTML component.

None

properties

dict[str, Any]

Bound to a dictionary that contains additional properties for this element.

None

class_name

str
dynamic

The list of CSS class names that are associated with the generated HTML Element.
These class names are added to the default taipy-image class name.

None

hover_text

str
dynamic

The information that is displayed when the user hovers over this element.

None