TagBox

_images/TagBoxExample.gif
class MangoUI.TagBox.TagBox(parent=None, textColor=(21, 21, 21, 255), backgroundColor=(245, 177, 66, 255), backgroundColorOnHover=(249, 205, 134, 255), fontFamily='Verdana', fontSize=10, fontWeight='normal', borderStyle='solid', borderColor=(21, 21, 21, 255), borderWidth=1, borderRadius=2)

Widget for handling tags.

Parameters
  • parent (PyQt6.QtCore.QObject, optional) – Parent object that contains this widget. Passing this ensures that destroying the parent also destroys this widget.

  • textColor (int, tuple, str or PyQt6.QtGui.QColor) – Tag text color, as a 32-bit integer representing RGBA, tuple of floats representing RGBA values, HTML RGBA string, HTML hexadecimal string, or QColor object.

  • backgroundColor (int, tuple, str or PyQt6.QtGui.QColor) – Tag background color, as a 32-bit integer representing RGBA, tuple of floats representing RGBA values, HTML RGBA string, HTML hexadecimal string, or QColor object.

  • backgroundColorOnHover (int, tuple, str or PyQt6.QtGui.QColor) – Tag background color on hover, as a 32-bit integer representing RGBA, tuple of floats representing RGBA values, HTML RGBA string, HTML hexadecimal string, or QColor object.

  • fontFamily (str) – Font family of tag text.

  • fontSize (int) – Font size of tag text in point value.

  • fontWeight (str) – Font weight of tag text.

  • borderStyle (str) – Border style of tag.

  • borderColor (int, tuple, str or PyQt6.QtGui.QColor) – Border color of tag. as a 32-bit integer representing RGBA, tuple of floats representing RGBA values, HTML RGBA string, HTML hexadecimal string, or QColor object.

  • borderWidth (int) – Border width of tag in pixels.

  • borderRadius (int) – Border radius of tag in pixels.

addTag(tagName, allowDuplicates=False, raiseErrorOnDuplicates=True)

Add new tag if it doesn’t exist.

Parameters
  • tagName (str) – Tag name.

  • allowDuplicates (bool) – Allow duplicate tags.

  • raiseErrorOnDuplicates (bool) – Raise ValueError if duplicate tag added. This has no affect if allowDuplicates = True.

clearTags()

Clear all tags.

displayTag(tagName)

Display tag on widget.

Parameters

tagName (str) – Tag name.

getTags()

Get tag names.

Returns

list of tag names.

Return type

list

initTagBox()

Clear and re-display all tags.

removeTag(i, returnTag=True)

Remove tag by index.

Parameters
  • i (int) – Index position of tag to remove.

  • returnTag (bool) – Return tag name.

Returns

Tag name. Setting returnTag = False, returns None.

Return type

str or None

renderStyleSheet(tagWidget)

Set QSS style sheet for tag using defined attributes.

Parameters

tagWidget (QWidget) – Tag widget.