Skip to content

TextCharFormatMixin

Sub classes

Name Children Inherits
TextCharFormat
prettyqt.gui.textcharformat
    TextImageFormat
    prettyqt.gui.textimageformat
      TextTableCellFormat
      prettyqt.gui.texttablecellformat

        Base classes

        Name Children Inherits
        TextFormatMixin
        prettyqt.gui.textformat
        object
        builtins
        The base class of the class hierarchy.
        • type
        • async_generator
        • bytearray_iterator
        • bytearray
        • bytes_iterator
        • bytes
        • builtin_function_or_method
        • callable_iterator
        • PyCapsule
        • cell
        • classmethod_descriptor
        • ...

          â‹” Inheritance diagram

          graph TD
            1115109788["gui.TextCharFormatMixin"]
            1171567019["gui.TextFormatMixin"]
            2751680898["builtins.object"]
            1171567019 --> 1115109788
            2751680898 --> 1171567019
            2751680898 --> 1115109788

          🛈 DocStrings

          Bases: TextFormatMixin, _TextCharFormatBase

          Source code in prettyqt/gui/textcharformat.py
          class TextCharFormatMixin(gui.TextFormatMixin, _TextCharFormatBase):
              def __init__(
                  self,
                  text_color: datatypes.ColorType | gui.QBrush | gui.QTextCharFormat = None,
                  bold: bool = False,
                  italic: bool = False,
              ):
                  if isinstance(text_color, gui.QTextCharFormat):  # copy constructor
                      super().__init__(text_color)
                      return
                  super().__init__()
                  if text_color is not None:
                      self.set_foreground_color(text_color)
                  if bold:
                      self.set_font_weight("bold")
                  self.setFontItalic(italic)
          
              def set_foreground_color(self, color: datatypes.ColorType | gui.QBrush):
                  if not isinstance(color, gui.QBrush):
                      color = colors.get_color(color)
                  self.setForeground(color)
          
              def set_background_color(self, color: datatypes.ColorType | gui.QBrush):
                  if not isinstance(color, gui.QBrush):
                      color = colors.get_color(color)
                  self.setBackground(color)
          
              def set_font_weight(self, weight: gui.font.WeightStr | gui.Font.Weight):
                  """Set the font weight.
          
                  Args:
                      weight: font weight
                  """
                  self.setFontWeight(gui.font.WEIGHT.get_enum_value(weight))
          
              def get_font_weight(self) -> gui.font.WeightStr:
                  """Get current font weight.
          
                  Returns:
                      current font weight
                  """
                  return gui.font.WEIGHT.inverse[self.fontWeight()]
          
              def set_underline_style(self, style: UnderlineStyleStr | mod.UnderlineStyle):
                  """Set the underline style.
          
                  Args:
                      style: underline style
                  """
                  self.setUnderlineStyle(UNDERLINE_STYLE.get_enum_value(style))
          
              def get_underline_style(self) -> UnderlineStyleStr:
                  """Get current underline style.
          
                  Returns:
                      current underline style
                  """
                  return UNDERLINE_STYLE.inverse[self.underlineStyle()]
          
              def set_vertical_alignment(
                  self, alignment: VerticalAlignmentStr | gui.QTextCharFormat.VerticalAlignment
              ):
                  """Set the vertical alignment.
          
                  Args:
                      alignment: vertical alignment
                  """
                  self.setVerticalAlignment(VERTICAL_ALIGNMENT.get_enum_value(alignment))
          
              def get_vertical_alignment(self) -> VerticalAlignmentStr:
                  """Get current vertical alignment.
          
                  Returns:
                      current vertical alignment
                  """
                  return VERTICAL_ALIGNMENT.inverse[self.verticalAlignment()]
          
              def set_font_style_hint(self, hint: gui.font.StyleHintStr | gui.Font.StyleHint):
                  """Set the font style hint.
          
                  Args:
                      hint: font style hint
                  """
                  self.setFontStyleHint(gui.font.STYLE_HINTS.get_enum_value(hint))
          
              def get_font(self) -> gui.Font:
                  return gui.Font(self.font())
          

          get_font_weight() -> gui.font.WeightStr

          Get current font weight.

          Source code in prettyqt/gui/textcharformat.py
          def get_font_weight(self) -> gui.font.WeightStr:
              """Get current font weight.
          
              Returns:
                  current font weight
              """
              return gui.font.WEIGHT.inverse[self.fontWeight()]
          

          get_underline_style() -> UnderlineStyleStr

          Get current underline style.

          Source code in prettyqt/gui/textcharformat.py
          def get_underline_style(self) -> UnderlineStyleStr:
              """Get current underline style.
          
              Returns:
                  current underline style
              """
              return UNDERLINE_STYLE.inverse[self.underlineStyle()]
          

          get_vertical_alignment() -> VerticalAlignmentStr

          Get current vertical alignment.

          Source code in prettyqt/gui/textcharformat.py
          def get_vertical_alignment(self) -> VerticalAlignmentStr:
              """Get current vertical alignment.
          
              Returns:
                  current vertical alignment
              """
              return VERTICAL_ALIGNMENT.inverse[self.verticalAlignment()]
          

          set_font_style_hint(hint: gui.font.StyleHintStr | gui.Font.StyleHint)

          Set the font style hint.

          Parameters:

          Name Type Description Default
          hint StyleHintStr | StyleHint

          font style hint

          required
          Source code in prettyqt/gui/textcharformat.py
          def set_font_style_hint(self, hint: gui.font.StyleHintStr | gui.Font.StyleHint):
              """Set the font style hint.
          
              Args:
                  hint: font style hint
              """
              self.setFontStyleHint(gui.font.STYLE_HINTS.get_enum_value(hint))
          

          set_font_weight(weight: gui.font.WeightStr | gui.Font.Weight)

          Set the font weight.

          Parameters:

          Name Type Description Default
          weight WeightStr | Weight

          font weight

          required
          Source code in prettyqt/gui/textcharformat.py
          def set_font_weight(self, weight: gui.font.WeightStr | gui.Font.Weight):
              """Set the font weight.
          
              Args:
                  weight: font weight
              """
              self.setFontWeight(gui.font.WEIGHT.get_enum_value(weight))
          

          set_underline_style(style: UnderlineStyleStr | mod.UnderlineStyle)

          Set the underline style.

          Parameters:

          Name Type Description Default
          style UnderlineStyleStr | UnderlineStyle

          underline style

          required
          Source code in prettyqt/gui/textcharformat.py
          def set_underline_style(self, style: UnderlineStyleStr | mod.UnderlineStyle):
              """Set the underline style.
          
              Args:
                  style: underline style
              """
              self.setUnderlineStyle(UNDERLINE_STYLE.get_enum_value(style))
          

          set_vertical_alignment(alignment: VerticalAlignmentStr | gui.QTextCharFormat.VerticalAlignment)

          Set the vertical alignment.

          Parameters:

          Name Type Description Default
          alignment VerticalAlignmentStr | VerticalAlignment

          vertical alignment

          required
          Source code in prettyqt/gui/textcharformat.py
          def set_vertical_alignment(
              self, alignment: VerticalAlignmentStr | gui.QTextCharFormat.VerticalAlignment
          ):
              """Set the vertical alignment.
          
              Args:
                  alignment: vertical alignment
              """
              self.setVerticalAlignment(VERTICAL_ALIGNMENT.get_enum_value(alignment))
          

          :fa-brands-github: Show source on GitHub