Skip to content

GraphicsWidgetMixin

Sub classes

Name Children Inherits
GraphicsWidget
prettyqt.widgets.graphicswidget
The base class for all widget items in a QGraphicsScene.
    GraphicsProxyWidget
    prettyqt.widgets.graphicsproxywidget
    Proxy layer for embedding a QWidget in a QGraphicsScene.
      Legend
      prettyqt.charts.legend
        ChartMixin
        prettyqt.charts.chart

        Base classes

        Name Children Inherits
        GraphicsObjectMixin
        prettyqt.widgets.graphicsobject
        GraphicsLayoutItemMixin
        prettyqt.widgets.graphicslayoutitem
        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
            1217014474["widgets.GraphicsWidgetMixin"]
            1453500865["widgets.GraphicsObjectMixin"]
            3227531497["core.ObjectMixin"]
            2751680898["builtins.object"]
            1638127052["widgets.GraphicsItemMixin"]
            1752462451["widgets.GraphicsLayoutItemMixin"]
            1453500865 --> 1217014474
            3227531497 --> 1453500865
            2751680898 --> 3227531497
            1638127052 --> 1453500865
            2751680898 --> 1638127052
            2751680898 --> 1453500865
            1752462451 --> 1217014474
            2751680898 --> 1752462451
            2751680898 --> 1217014474

          🛈 DocStrings

          Bases: GraphicsObjectMixin, GraphicsLayoutItemMixin, _GraphicsWidgetBase

          Source code in prettyqt/widgets/graphicswidget.py
          class GraphicsWidgetMixin(
              widgets.GraphicsObjectMixin, widgets.GraphicsLayoutItemMixin, _GraphicsWidgetBase
          ):
              @property
              def box(self):
                  return self.layout()
          
              @box.setter
              def box(self, layout):
                  self.set_layout(layout)
          
              def set_layout(
                  self, layout: LayoutStr | widgets.QGraphicsLayout
              ) -> widgets.QGraphicsLayout:
                  match layout:
                      case widgets.QGraphicsLayout():
                          layout = layout
                      case "grid":
                          layout = widgets.GraphicsGridLayout()
                      case "anchor":
                          layout = widgets.GraphicsAnchorLayout()
                      case "horizontal" | "vertical":
                          layout = widgets.GraphicsLinearLayout(layout)
                      case _:
                          msg = f"Invalid Layout {layout}"
                          raise ValueError(msg)
                  self.setLayout(layout)
                  return layout
          
              def set_focus_policy(self, policy: constants.FocusPolicyStr | constants.FocusPolicy):
                  """Set the way the widget accepts keyboard focus.
          
                  Args:
                      policy: Focus policy
                  """
                  self.setFocusPolicy(constants.FOCUS_POLICY.get_enum_value(policy))
          
              def get_focus_policy(self) -> constants.FocusPolicyStr:
                  """Return way the widget accepts keyboard focus.
          
                  Returns:
                      str: Focus policy
                  """
                  return constants.FOCUS_POLICY.inverse[self.focusPolicy()]
          
              def window_frame_section_at(
                  self, point: datatypes.PointType
              ) -> constants.WindowFrameSectionStr:
                  """Return the window frame section at given position.
          
                  Returns:
                      str: Window frame section
                  """
                  section = self.windowFrameSectionAt(datatypes.to_point(point))
                  return constants.WINDOW_FRAME_SECTION.inverse[section]
          
              def get_font(self) -> gui.Font:
                  return gui.Font(self.font())
          
              def get_palette(self) -> gui.Palette:
                  return gui.Palette(self.palette())
          

          get_focus_policy() -> constants.FocusPolicyStr

          Return way the widget accepts keyboard focus.

          Source code in prettyqt/widgets/graphicswidget.py
          def get_focus_policy(self) -> constants.FocusPolicyStr:
              """Return way the widget accepts keyboard focus.
          
              Returns:
                  str: Focus policy
              """
              return constants.FOCUS_POLICY.inverse[self.focusPolicy()]
          

          set_focus_policy(policy: constants.FocusPolicyStr | constants.FocusPolicy)

          Set the way the widget accepts keyboard focus.

          Parameters:

          Name Type Description Default
          policy FocusPolicyStr | FocusPolicy

          Focus policy

          required
          Source code in prettyqt/widgets/graphicswidget.py
          def set_focus_policy(self, policy: constants.FocusPolicyStr | constants.FocusPolicy):
              """Set the way the widget accepts keyboard focus.
          
              Args:
                  policy: Focus policy
              """
              self.setFocusPolicy(constants.FOCUS_POLICY.get_enum_value(policy))
          

          window_frame_section_at(point: datatypes.PointType) -> constants.WindowFrameSectionStr

          Return the window frame section at given position.

          Source code in prettyqt/widgets/graphicswidget.py
          def window_frame_section_at(
              self, point: datatypes.PointType
          ) -> constants.WindowFrameSectionStr:
              """Return the window frame section at given position.
          
              Returns:
                  str: Window frame section
              """
              section = self.windowFrameSectionAt(datatypes.to_point(point))
              return constants.WINDOW_FRAME_SECTION.inverse[section]
          

          :fa-brands-github: Show source on GitHub