Skip to content

SetVar

Bases: Variable

A tkinter variable that holds a set of values.

This variable serializes a Python set into its string representation for storage and deserializes it back into a set on retrieval.

__init__

__init__(
    master=None,
    value: set | None = None,
    name: str | None = None,
)

Initialize the SetVar.

Parameters:

Name Type Description Default
master Widget

The parent widget. Defaults to None.

None
value set

The initial value. Defaults to an empty set.

None
name str

The name of the variable. Defaults to None.

None

set

set(value: set | frozenset)

Set the variable to a new value.

The value is converted to its string representation for storage.

Parameters:

Name Type Description Default
value set | frozenset

The new value. Should be a set or frozenset.

required

get

get() -> set

Return the value of the variable as a Python set.

The string representation is deserialized back into a set.

Returns:

Name Type Description
set set

The current value of the variable.