Skip to content

tag_input

_tag_input

Tag/chip input widget.

Classes:

Name Description
FXTagChip

A single removable tag chip.

FXTagInput

A styled input widget that displays tags as removable chips.

Classes

FXTagChip

FXTagChip(text: str, parent: Optional[QWidget] = None, removable: bool = True)

Bases: FXThemeAware, QFrame


              flowchart TD
              fxgui.fxwidgets._tag_input.FXTagChip[FXTagChip]
              fxgui.fxstyle.FXThemeAware[FXThemeAware]

                              fxgui.fxstyle.FXThemeAware --> fxgui.fxwidgets._tag_input.FXTagChip
                


              click fxgui.fxwidgets._tag_input.FXTagChip href "" "fxgui.fxwidgets._tag_input.FXTagChip"
              click fxgui.fxstyle.FXThemeAware href "" "fxgui.fxstyle.FXThemeAware"
            

A single removable tag chip.

Parameters:

Name Type Description Default
text
str

The tag text.

required
parent
Optional[QWidget]

Parent widget.

None
removable
bool

Whether the chip can be removed.

True
Signals

removed: Emitted when the remove button is clicked.

Attributes:

Name Type Description
text str

Return the tag text.

Attributes
text property
text: str

Return the tag text.

FXTagInput

FXTagInput(
    parent: Optional[QWidget] = None,
    placeholder: str = "Add tag and press Enter...",
    max_tags: int = 0,
    allow_duplicates: bool = False,
)

Bases: FXThemeAware, QWidget


              flowchart TD
              fxgui.fxwidgets._tag_input.FXTagInput[FXTagInput]
              fxgui.fxstyle.FXThemeAware[FXThemeAware]

                              fxgui.fxstyle.FXThemeAware --> fxgui.fxwidgets._tag_input.FXTagInput
                


              click fxgui.fxwidgets._tag_input.FXTagInput href "" "fxgui.fxwidgets._tag_input.FXTagInput"
              click fxgui.fxstyle.FXThemeAware href "" "fxgui.fxstyle.FXThemeAware"
            

A styled input widget that displays tags as removable chips.

This widget provides an input field where users can type and press Enter to add tags. Tags are displayed as styled chips that can be removed by clicking the × button.

Parameters:

Name Type Description Default
parent
Optional[QWidget]

Parent widget.

None
placeholder
str

Placeholder text for the input field.

'Add tag and press Enter...'
max_tags
int

Maximum number of tags allowed (0 = unlimited).

0
allow_duplicates
bool

Whether duplicate tags are allowed.

False
Signals

tags_changed: Emitted when tags are added or removed. tag_added: Emitted when a single tag is added. tag_removed: Emitted when a single tag is removed.

Examples:

>>> tag_input = FXTagInput(placeholder="Add tags...")
>>> tag_input.tags_changed.connect(lambda tags: print(f"Tags: {tags}"))
>>> tag_input.add_tag("python")
>>> tag_input.add_tag("qt")

Methods:

Name Description
add_tag

Add a tag to the input.

clear_tags

Remove all tags.

remove_tag

Remove a tag from the input.

set_tags

Set the tags, replacing any existing tags.

Attributes:

Name Type Description
tags List[str]

Return the list of current tags.

Attributes
tags property
tags: List[str]

Return the list of current tags.

Functions
add_tag
add_tag(tag: str) -> bool

Add a tag to the input.

Parameters:

Name Type Description Default
tag str

The tag text to add.

required

Returns:

Type Description
bool

True if the tag was added, False otherwise.

clear_tags
clear_tags() -> None

Remove all tags.

remove_tag
remove_tag(tag: str) -> bool

Remove a tag from the input.

Parameters:

Name Type Description Default
tag str

The tag text to remove.

required

Returns:

Type Description
bool

True if the tag was removed, False otherwise.

set_tags
set_tags(tags: List[str]) -> None

Set the tags, replacing any existing tags.

Parameters:

Name Type Description Default
tags List[str]

List of tag strings to set.

required