Bindtags
This capability documents one focused aspect of the widget interface (Tk/Tcl-style behavior + bootstack extensions).
Note: You typically won’t use
bootstack.core.capabilities.bindtagsdirectly. This page describes the behavior that widgets expose.
Bindtags helpers (bindtags).
Bindtags control the order in which Tk processes bindings for an event.
Every widget has a list of bindtags. When an event occurs on a widget, Tk processes bindings in tag order. Each tag may have bindings associated with it.
Typical default bindtags for a widget look like:
(widget_pathname, widget_class, toplevel_pathname, "all")
Practical uses
- Insert a custom tag (e.g. "MyApp") to apply shared behaviors across widgets.
- Reorder tags to change precedence (e.g. run class bindings before widget bindings).
- Remove a tag to disable a layer of default behavior (use with care).
Notes
- Bindtags affect event dispatch only; they do not change focus or grab behavior.
- Misordering tags can break default widget behaviors (Tab traversal, selection, text editing, etc.), so keep changes minimal and well-scoped.
bindtags
bindtags(
tags: Sequence[str] | None = None,
) -> tuple[str, ...]
Get or set the bindtags for this widget.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tags
|
Sequence[str] | None
|
The bindtags to set. If None, returns the current bindtags. Tags are processed in order when dispatching events. |
None
|
Returns:
| Type | Description |
|---|---|
tuple[str, ...]
|
The current bindtags as a tuple. |
bindtags_prepend
bindtags_prepend(tag: str) -> tuple[str, ...]
Prepend a tag to the bindtags list.
This increases the tag's priority (it will be processed earlier).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tag
|
str
|
Tag name to prepend. |
required |
Returns:
| Type | Description |
|---|---|
tuple[str, ...]
|
The updated bindtags tuple. |
bindtags_append
bindtags_append(tag: str) -> tuple[str, ...]
Append a tag to the bindtags list.
This decreases the tag's priority (it will be processed later).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tag
|
str
|
Tag name to append. |
required |
Returns:
| Type | Description |
|---|---|
tuple[str, ...]
|
The updated bindtags tuple. |
bindtags_remove
bindtags_remove(tag: str) -> tuple[str, ...]
Remove a tag from the bindtags list.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tag
|
str
|
Tag name to remove. |
required |
Returns:
| Type | Description |
|---|---|
tuple[str, ...]
|
The updated bindtags tuple. |
bindtags_replace
bindtags_replace(old: str, new: str) -> tuple[str, ...]
Replace a bindtag with another tag.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
old
|
str
|
Existing tag name. |
required |
new
|
str
|
Replacement tag name. |
required |
Returns:
| Type | Description |
|---|---|
tuple[str, ...]
|
The updated bindtags tuple. |