Skip to content

Legend

Base classes

Name Children Inherits
GraphicsWidgetMixin
prettyqt.widgets.graphicswidget

⋔ Inheritance diagram

graph TD
  1473367687856["charts.Legend"]
  1473296164144["widgets.GraphicsWidgetMixin"]
  1473293697024["widgets.GraphicsObjectMixin"]
  1473299815024["core.ObjectMixin"]
  140713234304496["builtins.object"]
  1473293706784["widgets.GraphicsItemMixin"]
  1473293712640["widgets.GraphicsLayoutItemMixin"]
  1473296164144 --> 1473367687856
  1473293697024 --> 1473296164144
  1473299815024 --> 1473293697024
  140713234304496 --> 1473299815024
  1473293706784 --> 1473293697024
  140713234304496 --> 1473293706784
  1473293712640 --> 1473296164144
  140713234304496 --> 1473293712640

🛈 DocStrings

Bases: GraphicsWidgetMixin

Source code in prettyqt\charts\legend.py
class Legend(widgets.GraphicsWidgetMixin):
    def __init__(self, item: QtCharts.QLegend):
        self.item = item

    def __getattr__(self, val):
        return getattr(self.item, val)

    def set_alignment(self, alignment: constants.SideStr | QtCharts.QLegend.MarkerShape):
        """Set the alignment of the legend.

        Args:
            alignment: alignment for the legend
        """
        self.setAlignment(constants.SIDES.get_enum_value(alignment))

    def get_alignment(self) -> constants.SideStr:
        """Return current alignment.

        Returns:
            alignment
        """
        return constants.SIDES.inverse[self.alignment()]

    def set_marker_shape(self, shape: MarkerShapeStr):
        """Set the marker shape.

        Args:
            shape: marker shape
        """
        self.setMarkerShape(MARKER_SHAPES.get_enum_value(shape))

    def get_marker_shape(self) -> MarkerShapeStr:
        """Return current marker shape.

        Returns:
            Marker shape
        """
        return MARKER_SHAPES.inverse[self.markerShape()]

    def get_border_color(self) -> gui.Color:
        return gui.Color(self.borderColor())

    def get_color(self) -> gui.Color:
        return gui.Color(self.color())

    def get_label_color(self) -> gui.Color:
        return gui.Color(self.labelColor())

    def get_font(self) -> gui.Font:
        return gui.Font(self.font())

get_alignment() -> constants.SideStr

Return current alignment.

Source code in prettyqt\charts\legend.py
def get_alignment(self) -> constants.SideStr:
    """Return current alignment.

    Returns:
        alignment
    """
    return constants.SIDES.inverse[self.alignment()]

get_marker_shape() -> MarkerShapeStr

Return current marker shape.

Source code in prettyqt\charts\legend.py
def get_marker_shape(self) -> MarkerShapeStr:
    """Return current marker shape.

    Returns:
        Marker shape
    """
    return MARKER_SHAPES.inverse[self.markerShape()]

set_alignment(alignment: constants.SideStr | QtCharts.QLegend.MarkerShape)

Set the alignment of the legend.

Parameters:

Name Type Description Default
alignment SideStr | MarkerShape

alignment for the legend

required
Source code in prettyqt\charts\legend.py
def set_alignment(self, alignment: constants.SideStr | QtCharts.QLegend.MarkerShape):
    """Set the alignment of the legend.

    Args:
        alignment: alignment for the legend
    """
    self.setAlignment(constants.SIDES.get_enum_value(alignment))

set_marker_shape(shape: MarkerShapeStr)

Set the marker shape.

Parameters:

Name Type Description Default
shape MarkerShapeStr

marker shape

required
Source code in prettyqt\charts\legend.py
def set_marker_shape(self, shape: MarkerShapeStr):
    """Set the marker shape.

    Args:
        shape: marker shape
    """
    self.setMarkerShape(MARKER_SHAPES.get_enum_value(shape))