edifice.VScrollView.set_key#

VScrollView.set_key(key)#

Set the key of an Element.

The key is used when re-rendering to match new child Elements with old child Elements. The diffing algorithm will assume that child Elements with the same key are identical.

Each key must be unique and persistent. The Edifice Rules of Keys are the same as the React Rules of Keys.

  • Keys must be unique among siblings. However, it’s okay to use the same keys for Elements of different parents.

  • Keys must not change or that defeats their purpose! Don’t generate them while rendering.

Returns the Element to allow for chaining.

Example:

with VBoxView():
    if english:
        Label("Hello").set_key("en")
    if french:
        Label("Bonjour").set_key("fr")
    if spanish:
        Label("Hola").set_key("es")
Parameters:

key (str | None) – The Element unique key string.

Return type:

Self

Returns:

The Element.