tkmilan.menu#
Create Menu elements.
See the underlying models in model.MenuElement and similar.
Module Attributes
Type-Checking variable type for |
|
Type-Checking variable for processed elements. |
Functions
|
Wrap |
|
Wrap |
|
Create several |
|
Wrap |
|
Wrap |
|
Process menu definition objects into "proper" |
Classes
|
Define the menu root element, a simple tuple of children. |
- class tkmilan.menu.Root(*children: MenuElement | None | str | SpecParsed | VSpec | Tuple[str, Boolean | None | bool | SpecParsed | VSpec])#
Bases:
tupleDefine the menu root element, a simple tuple of children.
Wraps the
processfunction.
- tkmilan.menu.Checkbox(label: str, default: bool | None = None, *, variable: Boolean | None = None, id: str | None = None) → MenuElementCheckbox#
Wrap
model.MenuElementCheckboxwith a nicer interactive API.This concerns automatic
idcalculation. Use an incrementing counter.It also supports creating a new variable with a
defaultvalue.
- tkmilan.menu.Label(label: str, *, id: str | None = None) → MenuElementLabel#
Wrap
model.MenuElementLabelwith a nicer interactive API.This concerns automatic
idcalculation. Use an incrementing counter.
- tkmilan.menu.Radio(spec: VSpec, *, prefixid: str | None = None) → Sequence[MenuElementRadio]#
Create several
model.MenuElementRadiowith a nicer interactive API.Takes a specification object and returns a series of
model.MenuElementRadio.This concerns automatic
idcalculation. Use an incrementing counter, with an optionalprefixid, also created with an incrementing counter. This always creates a new variable, based on thespec.When squashing all elements at the same level, use like this:
... 'P Label', *Radio(spec), 'N Label', ...
When putting them on a nested sub-menu, use like this:
... menu.Sub('Nested Radio', Radio(spec), wstate_single=True) ...
- tkmilan.menu.Separator(*, id: str | None = None) → MenuElementSeparator#
Wrap
model.MenuElementSeparatorwith a nicer interactive API.This concerns automatic
idcalculation. Use an incrementing counter.
- tkmilan.menu.Sub(label: str, rawchildren: Sequence[MenuElement | None | str | SpecParsed | VSpec | Tuple[str, Boolean | None | bool | SpecParsed | VSpec]], *, id: str | None = None, wstate_single: bool | None = None) → MenuElementCascade#
Wrap
model.MenuElementCascadewith a nice interactive API.This concerns automatic
idcalculation. Derive from the label.
- tkmilan.menu.process(*children: MenuElement | None | str | SpecParsed | VSpec | Tuple[str, Boolean | None | bool | SpecParsed | VSpec]) → Tuple[MenuElement, ...]#
Process menu definition objects into “proper”
MenuElementobjects.All given
model.MenuElementare used directly. The other object types are:None: Transform into amodel.MenuElementSeparator, leveragesSeparator.str: Transform into amodel.MenuElementLabel. Similar toLabel, but uses the label itself as identifier.var.SpecParsed: Transform into a squashed list ofmodel.MenuElementRadio. Similar toRadio, but uses the variable specification labels as identifiers.validation.VSpec: Transform into a squashed list ofmodel.MenuElementRadio. Similar toRadio, but uses the specification labels as identifiers.(
str,var.Boolean): Transform into amodel.MenuElementCheckboxwith that label and variable.(
str,None): Transform into amodel.MenuElementCheckbox, with that label and a new variable without setting the default value. Similar toCheckbox, but uses the label as identifier.(
str,bool): Transform into amodel.MenuElementCheckbox, with that label and a new variable with that default value. Similar toCheckbox, but uses the label as identifier.(
str,var.SpecParsed): Transform into a nested list ofmodel.MenuElementRadio, leveragesSubwith that label. Similar toRadio, but uses the variable specification labels as identifiers.(
str,validation.VSpec): Transform into a nested list ofmodel.MenuElementRadio, leveragesSubwith that label. Similar toRadio, but uses the specification labels as identifiers.
All other types are unsupported and produce an error.
Note
You should not need to use this function directly. See
Root,Sub, or define the children directly insetup_menufunction.
- tkmilan.menu.childT#
Type-Checking variable type for
processfunction.alias of
Union[MenuElement,None,str,SpecParsed,VSpec,Tuple[str,Union[Boolean,None,bool,SpecParsed,VSpec]]]
- tkmilan.menu.childrenT#
Type-Checking variable for processed elements.
alias of
Tuple[MenuElement, …]