Skip to content

gui

Class info

Classes

Name Children Inherits
AbstractFileIconProvider
prettyqt.gui.abstractfileiconprovider
File icons for the QFileSystemModel class.
    AbstractFileIconProviderMixin
    prettyqt.gui.abstractfileiconprovider
    AbstractTextDocumentLayout
    prettyqt.gui.abstracttextdocumentlayout
    Abstract base class used to implement custom layouts for QTextDocuments.
      AbstractTextDocumentLayoutMixin
      prettyqt.gui.abstracttextdocumentlayout
      AccessibilityHints
      prettyqt.gui.accessibilityhints
      Contains platform accessibility hints and settings.
        AccessibilityHintsMixin
        prettyqt.gui.accessibilityhints
        Action
        prettyqt.gui.action
        Abstraction for user commands that can be added to different GUI components.
        • PopupMenuAction
        • FullScreenAction
        ActionGroup
        prettyqt.gui.actiongroup
        Groups actions together.
          ActionMixin
          prettyqt.gui.action
          BackingStore
          prettyqt.gui.backingstore
          Drawing area for QWindow.
            Bitmap
            prettyqt.gui.bitmap
            Monochrome (1-bit depth) pixmaps.
              Brush
              prettyqt.gui.brush
              Defines the fill pattern of shapes drawn by QPainter.
                Clipboard
                prettyqt.gui.clipboard
                Access to the window system clipboard.
                  Color
                  prettyqt.gui.color
                  Colors based on RGB, HSV or CMYK values.
                    ColorSpace
                    prettyqt.gui.colorspace
                    Color space abstraction.
                      ColorTransform
                      prettyqt.gui.colortransform
                      Transformation between color spaces.
                        ConicalGradient
                        prettyqt.gui.conicalgradient
                        Used in combination with QBrush to specify a conical gradient brush.
                          Cursor
                          prettyqt.gui.cursor
                          Provides a mouse cursor with an arbitrary shape.
                            DesktopServices
                            prettyqt.gui.desktopservices
                            Methods for accessing common desktop services.
                              DoubleValidator
                              prettyqt.gui.doublevalidator
                              Range checking of floating-point numbers.
                                Drag
                                prettyqt.gui.drag
                                Support for MIME-based drag and drop data transfer.
                                  Font
                                  prettyqt.gui.font
                                  Specifies a query for a font used for drawing text.
                                    FontDatabase
                                    prettyqt.gui.fontdatabase
                                    Information about the fonts available in the underlying window system.
                                      FontInfo
                                      prettyqt.gui.fontinfo
                                      General information about fonts.
                                        FontMetrics
                                        prettyqt.gui.fontmetrics
                                        Font metrics information.
                                          FontMetricsF
                                          prettyqt.gui.fontmetricsf
                                          Font metrics information.
                                            FontVariableAxis
                                            prettyqt.gui.fontvariableaxis
                                            Represents a variable axis in a font.
                                              Gradient
                                              prettyqt.gui.gradient
                                              Used in combination with QBrush to specify gradient fills.
                                                GradientMixin
                                                prettyqt.gui.gradient
                                                GuiApplication
                                                prettyqt.gui.guiapplication
                                                Manages the GUI application's control flow and main settings.
                                                  GuiApplicationMixin
                                                  prettyqt.gui.guiapplication
                                                  Icon
                                                  prettyqt.gui.icon
                                                  Scalable icons in different modes and states.
                                                    IconEngine
                                                    prettyqt.gui.iconengine
                                                    Abstract base class for QIcon renderers.
                                                    • CharIconEngine
                                                    Image
                                                    prettyqt.gui.image
                                                    Hardware-independent image representation with direct access to the pixel data.
                                                      ImageIOHandler
                                                      prettyqt.gui.imageiohandler
                                                      Defines the common image I/O interface for all image formats in Qt.
                                                        ImageReader
                                                        prettyqt.gui.imagereader
                                                        Format independent interface for reading images from files or other devices.
                                                          ImageWriter
                                                          prettyqt.gui.imagewriter
                                                          Format independent interface for writing images to files or other devices.
                                                            InputMethod
                                                            prettyqt.gui.inputmethod
                                                              IntValidator
                                                              prettyqt.gui.intvalidator
                                                              Validator that ensures a string contains a integer within a specified range.
                                                                KeySequence
                                                                prettyqt.gui.keysequence
                                                                Encapsulates a key sequence as used by shortcuts.
                                                                  LinearGradient
                                                                  prettyqt.gui.lineargradient
                                                                  Used in combination with QBrush to specify a linear gradient brush.
                                                                    Matrix4x4
                                                                    prettyqt.gui.matrix4x4
                                                                    Represents a 4x4 transformation matrix in 3D space.
                                                                      Movie
                                                                      prettyqt.gui.movie
                                                                      Convenience class for playing movies with QImageReader.
                                                                        PageLayout
                                                                        prettyqt.gui.pagelayout
                                                                        Describes the size, orientation and margins of a page.
                                                                          PageRanges
                                                                          prettyqt.gui.pageranges
                                                                          Represents a collection of page ranges.
                                                                            PageSize
                                                                            prettyqt.gui.pagesize
                                                                            Describes the size and name of a defined page size.
                                                                              PagedPaintDevice
                                                                              prettyqt.gui.pagedpaintdevice
                                                                                PagedPaintDeviceMixin
                                                                                prettyqt.gui.pagedpaintdevice
                                                                                PaintDevice
                                                                                prettyqt.gui.paintdevice
                                                                                The base class of objects that can be painted on with QPainter.
                                                                                  PaintDeviceMixin
                                                                                  prettyqt.gui.paintdevice
                                                                                  PaintDeviceWindow
                                                                                  prettyqt.gui.paintdevicewindow
                                                                                    PaintDeviceWindowMixin
                                                                                    prettyqt.gui.paintdevicewindow
                                                                                    Painter
                                                                                    prettyqt.gui.painter
                                                                                    Performs low-level painting on widgets and other paint devices.
                                                                                      PainterMixin
                                                                                      prettyqt.gui.painter
                                                                                      PainterPath
                                                                                      prettyqt.gui.painterpath
                                                                                        PainterPathStroker
                                                                                        prettyqt.gui.painterpathstroker
                                                                                          Palette
                                                                                          prettyqt.gui.palette
                                                                                          Contains color groups for each widget state.
                                                                                            PdfOutputIntent
                                                                                            prettyqt.gui.pdfoutputintent
                                                                                            Metadata describing the color reproduction characteristics of a PDF document.
                                                                                              PdfWriter
                                                                                              prettyqt.gui.pdfwriter
                                                                                              Class to generate PDFs that can be used as a paint device.
                                                                                                Pen
                                                                                                prettyqt.gui.pen
                                                                                                Defines how a QPainter should draw lines and outlines of shapes.
                                                                                                  Picture
                                                                                                  prettyqt.gui.picture
                                                                                                  Paint device that records and replays QPainter commands.
                                                                                                    Pixmap
                                                                                                    prettyqt.gui.pixmap
                                                                                                      PixmapCache
                                                                                                      prettyqt.gui.pixmapcache
                                                                                                      Application-wide cache for pixmaps.
                                                                                                        PixmapMixin
                                                                                                        prettyqt.gui.pixmap
                                                                                                        Off-screen image representation that can be used as a paint device.
                                                                                                        Polygon
                                                                                                        prettyqt.gui.polygon
                                                                                                        List of points using integer precision.
                                                                                                          PolygonF
                                                                                                          prettyqt.gui.polygonf
                                                                                                          List of points using floating point precision.
                                                                                                            Quaternion
                                                                                                            prettyqt.gui.quaternion
                                                                                                            Represents a quaternion consisting of a vector and scalar.
                                                                                                              RadialGradient
                                                                                                              prettyqt.gui.radialgradient
                                                                                                              Used in combination with QBrush to specify a radial gradient brush.
                                                                                                                RasterWindow
                                                                                                                prettyqt.gui.rasterwindow
                                                                                                                Convenience class for using QPainter on a QWindow.
                                                                                                                  Region
                                                                                                                  prettyqt.gui.region
                                                                                                                    RegularExpressionValidator
                                                                                                                    prettyqt.gui.regularexpressionvalidator
                                                                                                                    Used to check a string against a regular expression.
                                                                                                                      Screen
                                                                                                                      prettyqt.gui.screen
                                                                                                                      Used to query screen properties.
                                                                                                                        SessionManager
                                                                                                                        prettyqt.gui.sessionmanager
                                                                                                                          Shortcut
                                                                                                                          prettyqt.gui.shortcut
                                                                                                                            StandardItem
                                                                                                                            prettyqt.gui.standarditem
                                                                                                                              StandardItemModel
                                                                                                                              prettyqt.gui.standarditemmodel
                                                                                                                                StaticText
                                                                                                                                prettyqt.gui.statictext
                                                                                                                                  StyleHints
                                                                                                                                  prettyqt.gui.stylehints
                                                                                                                                    StyleHintsMixin
                                                                                                                                    prettyqt.gui.stylehints
                                                                                                                                    Surface
                                                                                                                                    prettyqt.gui.surface
                                                                                                                                      SurfaceFormat
                                                                                                                                      prettyqt.gui.surfaceformat
                                                                                                                                        SurfaceMixin
                                                                                                                                        prettyqt.gui.surface
                                                                                                                                        SyntaxHighlighter
                                                                                                                                        prettyqt.gui.syntaxhighlighter
                                                                                                                                        TextBlock
                                                                                                                                        prettyqt.gui.textblock
                                                                                                                                          TextBlockFormat
                                                                                                                                          prettyqt.gui.textblockformat
                                                                                                                                            TextBlockGroup
                                                                                                                                            prettyqt.gui.textblockgroup
                                                                                                                                              TextBlockUserData
                                                                                                                                              prettyqt.gui.textblockuserdata
                                                                                                                                              Storage for the user data associated with each line.
                                                                                                                                                TextCharFormat
                                                                                                                                                prettyqt.gui.textcharformat
                                                                                                                                                  TextCharFormatMixin
                                                                                                                                                  prettyqt.gui.textcharformat
                                                                                                                                                  TextCursor
                                                                                                                                                  prettyqt.gui.textcursor
                                                                                                                                                    TextDocument
                                                                                                                                                    prettyqt.gui.textdocument
                                                                                                                                                      TextDocumentFragment
                                                                                                                                                      prettyqt.gui.textdocumentfragment
                                                                                                                                                        TextDocumentWriter
                                                                                                                                                        prettyqt.gui.textdocumentwriter
                                                                                                                                                          TextFormat
                                                                                                                                                          prettyqt.gui.textformat
                                                                                                                                                            TextFormatMixin
                                                                                                                                                            prettyqt.gui.textformat
                                                                                                                                                            TextFrame
                                                                                                                                                            prettyqt.gui.textframe
                                                                                                                                                              TextFrameFormat
                                                                                                                                                              prettyqt.gui.textframeformat
                                                                                                                                                                TextImageFormat
                                                                                                                                                                prettyqt.gui.textimageformat
                                                                                                                                                                  TextLayout
                                                                                                                                                                  prettyqt.gui.textlayout
                                                                                                                                                                    TextLength
                                                                                                                                                                    prettyqt.gui.textlength
                                                                                                                                                                      TextLine
                                                                                                                                                                      prettyqt.gui.textline
                                                                                                                                                                        TextListFormat
                                                                                                                                                                        prettyqt.gui.textlistformat
                                                                                                                                                                          TextObject
                                                                                                                                                                          prettyqt.gui.textobject
                                                                                                                                                                            TextObjectInterface
                                                                                                                                                                            prettyqt.gui.textobjectinterface
                                                                                                                                                                              TextObjectMixin
                                                                                                                                                                              prettyqt.gui.textobject
                                                                                                                                                                              TextOption
                                                                                                                                                                              prettyqt.gui.textoption
                                                                                                                                                                                TextTable
                                                                                                                                                                                prettyqt.gui.texttable
                                                                                                                                                                                  TextTableCell
                                                                                                                                                                                  prettyqt.gui.texttablecell
                                                                                                                                                                                    TextTableCellFormat
                                                                                                                                                                                    prettyqt.gui.texttablecellformat
                                                                                                                                                                                      TextTableFormat
                                                                                                                                                                                      prettyqt.gui.texttableformat
                                                                                                                                                                                        Transform
                                                                                                                                                                                        prettyqt.gui.transform
                                                                                                                                                                                          UndoCommand
                                                                                                                                                                                          prettyqt.gui.undocommand
                                                                                                                                                                                            UndoGroup
                                                                                                                                                                                            prettyqt.gui.undogroup
                                                                                                                                                                                              UndoStack
                                                                                                                                                                                              prettyqt.gui.undostack
                                                                                                                                                                                                Validator
                                                                                                                                                                                                prettyqt.gui.validator
                                                                                                                                                                                                ValidatorMixin
                                                                                                                                                                                                prettyqt.gui.validator
                                                                                                                                                                                                Vector2D
                                                                                                                                                                                                prettyqt.gui.vector2d
                                                                                                                                                                                                Represents a vector or vertex in 2D space.
                                                                                                                                                                                                  Vector3D
                                                                                                                                                                                                  prettyqt.gui.vector3d
                                                                                                                                                                                                    Vector4D
                                                                                                                                                                                                    prettyqt.gui.vector4d
                                                                                                                                                                                                      Window
                                                                                                                                                                                                      prettyqt.gui.window
                                                                                                                                                                                                        WindowMixin
                                                                                                                                                                                                        prettyqt.gui.window

                                                                                                                                                                                                        🛈 DocStrings

                                                                                                                                                                                                        Base classes for graphical user interface (GUI) components.

                                                                                                                                                                                                        AbstractFileIconProvider

                                                                                                                                                                                                        Bases: AbstractFileIconProviderMixin, QAbstractFileIconProvider

                                                                                                                                                                                                        File icons for the QFileSystemModel class.

                                                                                                                                                                                                        Source code in prettyqt/gui/abstractfileiconprovider.py
                                                                                                                                                                                                        class AbstractFileIconProvider(
                                                                                                                                                                                                            AbstractFileIconProviderMixin, QtGui.QAbstractFileIconProvider
                                                                                                                                                                                                        ):
                                                                                                                                                                                                            """File icons for the QFileSystemModel class."""
                                                                                                                                                                                                        

                                                                                                                                                                                                        AbstractTextDocumentLayout

                                                                                                                                                                                                        Bases: AbstractTextDocumentLayoutMixin, QAbstractTextDocumentLayout

                                                                                                                                                                                                        Abstract base class used to implement custom layouts for QTextDocuments.

                                                                                                                                                                                                        Source code in prettyqt/gui/abstracttextdocumentlayout.py
                                                                                                                                                                                                        class AbstractTextDocumentLayout(
                                                                                                                                                                                                            AbstractTextDocumentLayoutMixin, QtGui.QAbstractTextDocumentLayout
                                                                                                                                                                                                        ):
                                                                                                                                                                                                            """Abstract base class used to implement custom layouts for QTextDocuments."""
                                                                                                                                                                                                        

                                                                                                                                                                                                        AccessibilityHints

                                                                                                                                                                                                        Bases: AccessibilityHintsMixin

                                                                                                                                                                                                        Contains platform accessibility hints and settings.

                                                                                                                                                                                                        Source code in prettyqt/gui/accessibilityhints.py
                                                                                                                                                                                                        class AccessibilityHints(AccessibilityHintsMixin, metaclass=AccessibilityHintsType):
                                                                                                                                                                                                            """Contains platform accessibility hints and settings."""
                                                                                                                                                                                                        
                                                                                                                                                                                                            def __init__(self, item: QtGui.QAccessibilityHints):
                                                                                                                                                                                                                self.item = item
                                                                                                                                                                                                        
                                                                                                                                                                                                            def __getattr__(self, val):
                                                                                                                                                                                                                return getattr(self.item, val)
                                                                                                                                                                                                        

                                                                                                                                                                                                        AccessibilityHintsMixin

                                                                                                                                                                                                        Bases: ObjectMixin, _AccessibilityHintsBase

                                                                                                                                                                                                        Source code in prettyqt/gui/accessibilityhints.py
                                                                                                                                                                                                        class AccessibilityHintsMixin(core.ObjectMixin, _AccessibilityHintsBase):
                                                                                                                                                                                                            def get_contrast_preference(self) -> ContrastPreferenceStr:
                                                                                                                                                                                                                """Return current contrast preference.
                                                                                                                                                                                                        
                                                                                                                                                                                                                Returns:
                                                                                                                                                                                                                    contrast preference
                                                                                                                                                                                                                """
                                                                                                                                                                                                                return CONTRAST_PREFERENCE.inverse[self.contrastPreference()]
                                                                                                                                                                                                        
                                                                                                                                                                                                            def get_motion_preference(self) -> MotionPreferenceStr:
                                                                                                                                                                                                                """Return current motion preference.
                                                                                                                                                                                                        
                                                                                                                                                                                                                Returns:
                                                                                                                                                                                                                    motion preference
                                                                                                                                                                                                                """
                                                                                                                                                                                                                return MOTION_PREFERENCE.inverse[self.motionPreference()]
                                                                                                                                                                                                        

                                                                                                                                                                                                        get_contrast_preference() -> ContrastPreferenceStr

                                                                                                                                                                                                        Return current contrast preference.

                                                                                                                                                                                                        Source code in prettyqt/gui/accessibilityhints.py
                                                                                                                                                                                                        def get_contrast_preference(self) -> ContrastPreferenceStr:
                                                                                                                                                                                                            """Return current contrast preference.
                                                                                                                                                                                                        
                                                                                                                                                                                                            Returns:
                                                                                                                                                                                                                contrast preference
                                                                                                                                                                                                            """
                                                                                                                                                                                                            return CONTRAST_PREFERENCE.inverse[self.contrastPreference()]
                                                                                                                                                                                                        

                                                                                                                                                                                                        get_motion_preference() -> MotionPreferenceStr

                                                                                                                                                                                                        Return current motion preference.

                                                                                                                                                                                                        Source code in prettyqt/gui/accessibilityhints.py
                                                                                                                                                                                                        def get_motion_preference(self) -> MotionPreferenceStr:
                                                                                                                                                                                                            """Return current motion preference.
                                                                                                                                                                                                        
                                                                                                                                                                                                            Returns:
                                                                                                                                                                                                                motion preference
                                                                                                                                                                                                            """
                                                                                                                                                                                                            return MOTION_PREFERENCE.inverse[self.motionPreference()]
                                                                                                                                                                                                        

                                                                                                                                                                                                        Action

                                                                                                                                                                                                        Bases: ActionMixin, QAction

                                                                                                                                                                                                        Abstraction for user commands that can be added to different GUI components.

                                                                                                                                                                                                        Source code in prettyqt/gui/action.py
                                                                                                                                                                                                        class Action(ActionMixin, gui.QAction):
                                                                                                                                                                                                            """Abstraction for user commands that can be added to different GUI components."""
                                                                                                                                                                                                        

                                                                                                                                                                                                        ActionGroup

                                                                                                                                                                                                        Bases: ObjectMixin, QActionGroup

                                                                                                                                                                                                        Groups actions together.

                                                                                                                                                                                                        Source code in prettyqt/gui/actiongroup.py
                                                                                                                                                                                                        class ActionGroup(core.ObjectMixin, QtGui.QActionGroup):
                                                                                                                                                                                                            """Groups actions together."""
                                                                                                                                                                                                        
                                                                                                                                                                                                            def __init__(self, parent: core.QObject | None = None, **kwargs):
                                                                                                                                                                                                                super().__init__(parent, **kwargs)
                                                                                                                                                                                                        
                                                                                                                                                                                                            def _get_map(self):
                                                                                                                                                                                                                maps = super()._get_map()
                                                                                                                                                                                                                maps |= {"exclusionPolicy": EXCLUSION_POLICY}
                                                                                                                                                                                                                return maps
                                                                                                                                                                                                        
                                                                                                                                                                                                            def __len__(self) -> int:
                                                                                                                                                                                                                return len(self.actions())
                                                                                                                                                                                                        
                                                                                                                                                                                                            def __getitem__(self, item: int) -> QtGui.QAction:
                                                                                                                                                                                                                return self.actions()[item]
                                                                                                                                                                                                        
                                                                                                                                                                                                            def set_exclusion_policy(
                                                                                                                                                                                                                self, policy: ExclusionPolicyStr | QtGui.QActionGroup.ExclusionPolicy | None
                                                                                                                                                                                                            ):
                                                                                                                                                                                                                """Set exclusion policy to use.
                                                                                                                                                                                                        
                                                                                                                                                                                                                Args:
                                                                                                                                                                                                                    policy: exclusion policy to use
                                                                                                                                                                                                                """
                                                                                                                                                                                                                if policy is None:
                                                                                                                                                                                                                    policy = "none"
                                                                                                                                                                                                                self.setExclusionPolicy(EXCLUSION_POLICY.get_enum_value(policy))
                                                                                                                                                                                                        
                                                                                                                                                                                                            def get_exclusion_policy(self) -> ExclusionPolicyStr:
                                                                                                                                                                                                                """Return current exclusion policy.
                                                                                                                                                                                                        
                                                                                                                                                                                                                Returns:
                                                                                                                                                                                                                    exclusion policy
                                                                                                                                                                                                                """
                                                                                                                                                                                                                return EXCLUSION_POLICY.inverse[self.exclusionPolicy()]
                                                                                                                                                                                                        

                                                                                                                                                                                                        get_exclusion_policy() -> ExclusionPolicyStr

                                                                                                                                                                                                        Return current exclusion policy.

                                                                                                                                                                                                        Source code in prettyqt/gui/actiongroup.py
                                                                                                                                                                                                        def get_exclusion_policy(self) -> ExclusionPolicyStr:
                                                                                                                                                                                                            """Return current exclusion policy.
                                                                                                                                                                                                        
                                                                                                                                                                                                            Returns:
                                                                                                                                                                                                                exclusion policy
                                                                                                                                                                                                            """
                                                                                                                                                                                                            return EXCLUSION_POLICY.inverse[self.exclusionPolicy()]
                                                                                                                                                                                                        

                                                                                                                                                                                                        set_exclusion_policy(policy: ExclusionPolicyStr | QtGui.QActionGroup.ExclusionPolicy | None)

                                                                                                                                                                                                        Set exclusion policy to use.

                                                                                                                                                                                                        Parameters:

                                                                                                                                                                                                        Name Type Description Default
                                                                                                                                                                                                        policy ExclusionPolicyStr | ExclusionPolicy | None

                                                                                                                                                                                                        exclusion policy to use

                                                                                                                                                                                                        required
                                                                                                                                                                                                        Source code in prettyqt/gui/actiongroup.py
                                                                                                                                                                                                        def set_exclusion_policy(
                                                                                                                                                                                                            self, policy: ExclusionPolicyStr | QtGui.QActionGroup.ExclusionPolicy | None
                                                                                                                                                                                                        ):
                                                                                                                                                                                                            """Set exclusion policy to use.
                                                                                                                                                                                                        
                                                                                                                                                                                                            Args:
                                                                                                                                                                                                                policy: exclusion policy to use
                                                                                                                                                                                                            """
                                                                                                                                                                                                            if policy is None:
                                                                                                                                                                                                                policy = "none"
                                                                                                                                                                                                            self.setExclusionPolicy(EXCLUSION_POLICY.get_enum_value(policy))
                                                                                                                                                                                                        

                                                                                                                                                                                                        ActionMixin

                                                                                                                                                                                                        Bases: ObjectMixin, _ActionBase

                                                                                                                                                                                                        Source code in prettyqt/gui/action.py
                                                                                                                                                                                                        class ActionMixin(core.ObjectMixin, _ActionBase):
                                                                                                                                                                                                            def __init__(
                                                                                                                                                                                                                self,
                                                                                                                                                                                                                *args,
                                                                                                                                                                                                                text: str | None = None,
                                                                                                                                                                                                                icon: datatypes.IconType = None,
                                                                                                                                                                                                                callback: Callable | None = None,
                                                                                                                                                                                                                **kwargs,
                                                                                                                                                                                                            ):
                                                                                                                                                                                                                super().__init__(*args, **kwargs)
                                                                                                                                                                                                                if callback is not None:
                                                                                                                                                                                                                    self.triggered.connect(callback)
                                                                                                                                                                                                                self._usage_count = 0
                                                                                                                                                                                                                if text:
                                                                                                                                                                                                                    self.setText(text)
                                                                                                                                                                                                                if icon:
                                                                                                                                                                                                                    self.set_icon(icon)
                                                                                                                                                                                                                self.triggered.connect(self._increase_usage_counter)
                                                                                                                                                                                                        
                                                                                                                                                                                                            def __repr__(self) -> str:
                                                                                                                                                                                                                return get_repr(self, self.text())
                                                                                                                                                                                                        
                                                                                                                                                                                                            def _get_map(self):
                                                                                                                                                                                                                maps = super()._get_map()
                                                                                                                                                                                                                maps |= {
                                                                                                                                                                                                                    "priority": PRIORITIES,
                                                                                                                                                                                                                    "shortcutContext": constants.SHORTCUT_CONTEXT,
                                                                                                                                                                                                                    "menuRole": MENU_ROLE,
                                                                                                                                                                                                                }
                                                                                                                                                                                                                return maps
                                                                                                                                                                                                        
                                                                                                                                                                                                            def _increase_usage_counter(self):
                                                                                                                                                                                                                self._usage_count += 1
                                                                                                                                                                                                        
                                                                                                                                                                                                            def get_usage_count(self) -> int:
                                                                                                                                                                                                                return self._usage_count
                                                                                                                                                                                                        
                                                                                                                                                                                                            def get_type(self) -> Literal["menu", "separator", "widget", "regular"]:
                                                                                                                                                                                                                if self.menu() is not None:
                                                                                                                                                                                                                    return "menu"
                                                                                                                                                                                                                if self.isSeparator():
                                                                                                                                                                                                                    return "separator"
                                                                                                                                                                                                                if hasattr(self, "defaultWidget"):
                                                                                                                                                                                                                    return "widget"
                                                                                                                                                                                                                return "regular"
                                                                                                                                                                                                        
                                                                                                                                                                                                            def set_disabled(self):
                                                                                                                                                                                                                self.setEnabled(False)
                                                                                                                                                                                                        
                                                                                                                                                                                                            def set_enabled(self, enabled: bool = True):
                                                                                                                                                                                                                self.setEnabled(enabled)
                                                                                                                                                                                                        
                                                                                                                                                                                                            def set_tooltip(
                                                                                                                                                                                                                self,
                                                                                                                                                                                                                tooltip: str | datatypes.PathType,
                                                                                                                                                                                                                size: datatypes.SizeType | None = None,
                                                                                                                                                                                                                rich_text: bool = False,
                                                                                                                                                                                                            ):
                                                                                                                                                                                                                if isinstance(tooltip, os.PathLike):
                                                                                                                                                                                                                    path = os.fspath(tooltip)
                                                                                                                                                                                                                    if size is None:
                                                                                                                                                                                                                        tooltip = f"<img src={path!r}>"
                                                                                                                                                                                                                    else:
                                                                                                                                                                                                                        qsize = datatypes.to_size(size)
                                                                                                                                                                                                                        w, h = qsize.width(), qsize.height()
                                                                                                                                                                                                                        tooltip = f'<img src={path!r} width="{w}" height="{h}">'
                                                                                                                                                                                                                if rich_text:
                                                                                                                                                                                                                    tooltip = html.escape(tooltip).replace("\n", "<br/>")
                                                                                                                                                                                                                    tooltip = f"<html>{tooltip}</html>"
                                                                                                                                                                                                                else:
                                                                                                                                                                                                                    tooltip = tooltip.replace("\n", "<br/>")
                                                                                                                                                                                                                super().setToolTip(tooltip)
                                                                                                                                                                                                        
                                                                                                                                                                                                            setToolTip = set_tooltip  # noqa: N815
                                                                                                                                                                                                        
                                                                                                                                                                                                            def set_icon(self, icon: datatypes.IconType):
                                                                                                                                                                                                                """Set the icon for the action.
                                                                                                                                                                                                        
                                                                                                                                                                                                                Args:
                                                                                                                                                                                                                    icon: icon to use
                                                                                                                                                                                                                """
                                                                                                                                                                                                                icon = iconprovider.get_icon(icon)
                                                                                                                                                                                                                super().setIcon(icon)
                                                                                                                                                                                                        
                                                                                                                                                                                                            setIcon = set_icon  # noqa: N815
                                                                                                                                                                                                        
                                                                                                                                                                                                            def set_shortcut(self, shortcut: gui.QKeySequence | str | None):
                                                                                                                                                                                                                if shortcut is None:
                                                                                                                                                                                                                    shortcut = ""
                                                                                                                                                                                                                if isinstance(shortcut, str):
                                                                                                                                                                                                                    if shortcut in gui.keysequence.STANDARD_KEYS:
                                                                                                                                                                                                                        shortcut = gui.KeySequence(shortcut)
                                                                                                                                                                                                                    else:
                                                                                                                                                                                                                        shortcut = gui.KeySequence(
                                                                                                                                                                                                                            shortcut, gui.KeySequence.SequenceFormat.PortableText
                                                                                                                                                                                                                        )
                                                                                                                                                                                                                super().setShortcut(shortcut)
                                                                                                                                                                                                        
                                                                                                                                                                                                            setShortcut = set_shortcut  # noqa: N815
                                                                                                                                                                                                        
                                                                                                                                                                                                            def setText(self, text: str | None):
                                                                                                                                                                                                                super().setText(text or "")
                                                                                                                                                                                                        
                                                                                                                                                                                                            set_text = setText
                                                                                                                                                                                                        
                                                                                                                                                                                                            def get_icon(self) -> gui.Icon | None:
                                                                                                                                                                                                                icon = self.icon()
                                                                                                                                                                                                                return None if icon.isNull() else gui.Icon(icon)
                                                                                                                                                                                                        
                                                                                                                                                                                                            def get_shortcut(self) -> gui.KeySequence | None:
                                                                                                                                                                                                                shortcut = self.shortcut()
                                                                                                                                                                                                                return (
                                                                                                                                                                                                                    gui.KeySequence(
                                                                                                                                                                                                                        shortcut.toString(), gui.KeySequence.SequenceFormat.PortableText
                                                                                                                                                                                                                    )
                                                                                                                                                                                                                    if not shortcut.isEmpty()
                                                                                                                                                                                                                    else None
                                                                                                                                                                                                                )
                                                                                                                                                                                                        
                                                                                                                                                                                                            def get_font(self) -> gui.Font:
                                                                                                                                                                                                                return gui.Font(self.font())
                                                                                                                                                                                                        
                                                                                                                                                                                                            def set_menu(self, menu):
                                                                                                                                                                                                                self.setMenu(menu)
                                                                                                                                                                                                        
                                                                                                                                                                                                            def set_priority(self, priority: PriorityStr | gui.QAction.Priority):
                                                                                                                                                                                                                """Set priority of the action.
                                                                                                                                                                                                        
                                                                                                                                                                                                                Args:
                                                                                                                                                                                                                    priority: priority for the action
                                                                                                                                                                                                                """
                                                                                                                                                                                                                super().setPriority(PRIORITIES.get_enum_value(priority))
                                                                                                                                                                                                        
                                                                                                                                                                                                            setPriority = set_priority  # noqa: N815
                                                                                                                                                                                                        
                                                                                                                                                                                                            def get_priority(self) -> PriorityStr:
                                                                                                                                                                                                                """Return current priority.
                                                                                                                                                                                                        
                                                                                                                                                                                                                Returns:
                                                                                                                                                                                                                    priority
                                                                                                                                                                                                                """
                                                                                                                                                                                                                return PRIORITIES.inverse[self.priority()]
                                                                                                                                                                                                        
                                                                                                                                                                                                            def set_shortcut_context(
                                                                                                                                                                                                                self, context: constants.ShortcutContextStr | constants.ShortcutContext
                                                                                                                                                                                                            ):
                                                                                                                                                                                                                """Set shortcut context.
                                                                                                                                                                                                        
                                                                                                                                                                                                                Args:
                                                                                                                                                                                                                    context: shortcut context
                                                                                                                                                                                                                """
                                                                                                                                                                                                                super().setShortcutContext(constants.SHORTCUT_CONTEXT.get_enum_value(context))
                                                                                                                                                                                                        
                                                                                                                                                                                                            setShortcutContext = set_shortcut_context  # noqa: N815
                                                                                                                                                                                                        
                                                                                                                                                                                                            def get_shortcut_context(self) -> constants.ShortcutContextStr:
                                                                                                                                                                                                                """Return shortcut context.
                                                                                                                                                                                                        
                                                                                                                                                                                                                Returns:
                                                                                                                                                                                                                    shortcut context
                                                                                                                                                                                                                """
                                                                                                                                                                                                                return constants.SHORTCUT_CONTEXT.inverse[super().shortcutContext()]
                                                                                                                                                                                                        
                                                                                                                                                                                                            def set_menu_role(self, role: MenuRoleStr | gui.QAction.MenuRole):
                                                                                                                                                                                                                """Set menu role.
                                                                                                                                                                                                        
                                                                                                                                                                                                                Args:
                                                                                                                                                                                                                    role: menu role
                                                                                                                                                                                                                """
                                                                                                                                                                                                                super().setMenuRole(MENU_ROLE.get_enum_value(role))
                                                                                                                                                                                                        
                                                                                                                                                                                                            setMenuRole = set_menu_role  # noqa: N815
                                                                                                                                                                                                        
                                                                                                                                                                                                            def get_menu_role(self) -> MenuRoleStr:
                                                                                                                                                                                                                """Return menu role.
                                                                                                                                                                                                        
                                                                                                                                                                                                                Returns:
                                                                                                                                                                                                                    menu role
                                                                                                                                                                                                                """
                                                                                                                                                                                                                return MENU_ROLE.inverse[super().menuRole()]
                                                                                                                                                                                                        
                                                                                                                                                                                                            def show_shortcut_in_contextmenu(self, state: bool = True):
                                                                                                                                                                                                                self.setShortcutVisibleInContextMenu(state)
                                                                                                                                                                                                        
                                                                                                                                                                                                            usage_count = core.Property(
                                                                                                                                                                                                                int,
                                                                                                                                                                                                                get_usage_count,
                                                                                                                                                                                                                doc="How often the action was triggered",
                                                                                                                                                                                                            )
                                                                                                                                                                                                        

                                                                                                                                                                                                        get_menu_role() -> MenuRoleStr

                                                                                                                                                                                                        Return menu role.

                                                                                                                                                                                                        Source code in prettyqt/gui/action.py
                                                                                                                                                                                                        def get_menu_role(self) -> MenuRoleStr:
                                                                                                                                                                                                            """Return menu role.
                                                                                                                                                                                                        
                                                                                                                                                                                                            Returns:
                                                                                                                                                                                                                menu role
                                                                                                                                                                                                            """
                                                                                                                                                                                                            return MENU_ROLE.inverse[super().menuRole()]
                                                                                                                                                                                                        

                                                                                                                                                                                                        get_priority() -> PriorityStr

                                                                                                                                                                                                        Return current priority.

                                                                                                                                                                                                        Source code in prettyqt/gui/action.py
                                                                                                                                                                                                        def get_priority(self) -> PriorityStr:
                                                                                                                                                                                                            """Return current priority.
                                                                                                                                                                                                        
                                                                                                                                                                                                            Returns:
                                                                                                                                                                                                                priority
                                                                                                                                                                                                            """
                                                                                                                                                                                                            return PRIORITIES.inverse[self.priority()]
                                                                                                                                                                                                        

                                                                                                                                                                                                        get_shortcut_context() -> constants.ShortcutContextStr

                                                                                                                                                                                                        Return shortcut context.

                                                                                                                                                                                                        Source code in prettyqt/gui/action.py
                                                                                                                                                                                                        def get_shortcut_context(self) -> constants.ShortcutContextStr:
                                                                                                                                                                                                            """Return shortcut context.
                                                                                                                                                                                                        
                                                                                                                                                                                                            Returns:
                                                                                                                                                                                                                shortcut context
                                                                                                                                                                                                            """
                                                                                                                                                                                                            return constants.SHORTCUT_CONTEXT.inverse[super().shortcutContext()]
                                                                                                                                                                                                        

                                                                                                                                                                                                        set_icon(icon: datatypes.IconType)

                                                                                                                                                                                                        Set the icon for the action.

                                                                                                                                                                                                        Parameters:

                                                                                                                                                                                                        Name Type Description Default
                                                                                                                                                                                                        icon IconType

                                                                                                                                                                                                        icon to use

                                                                                                                                                                                                        required
                                                                                                                                                                                                        Source code in prettyqt/gui/action.py
                                                                                                                                                                                                        def set_icon(self, icon: datatypes.IconType):
                                                                                                                                                                                                            """Set the icon for the action.
                                                                                                                                                                                                        
                                                                                                                                                                                                            Args:
                                                                                                                                                                                                                icon: icon to use
                                                                                                                                                                                                            """
                                                                                                                                                                                                            icon = iconprovider.get_icon(icon)
                                                                                                                                                                                                            super().setIcon(icon)
                                                                                                                                                                                                        

                                                                                                                                                                                                        set_menu_role(role: MenuRoleStr | gui.QAction.MenuRole)

                                                                                                                                                                                                        Set menu role.

                                                                                                                                                                                                        Parameters:

                                                                                                                                                                                                        Name Type Description Default
                                                                                                                                                                                                        role MenuRoleStr | MenuRole

                                                                                                                                                                                                        menu role

                                                                                                                                                                                                        required
                                                                                                                                                                                                        Source code in prettyqt/gui/action.py
                                                                                                                                                                                                        def set_menu_role(self, role: MenuRoleStr | gui.QAction.MenuRole):
                                                                                                                                                                                                            """Set menu role.
                                                                                                                                                                                                        
                                                                                                                                                                                                            Args:
                                                                                                                                                                                                                role: menu role
                                                                                                                                                                                                            """
                                                                                                                                                                                                            super().setMenuRole(MENU_ROLE.get_enum_value(role))
                                                                                                                                                                                                        

                                                                                                                                                                                                        set_priority(priority: PriorityStr | gui.QAction.Priority)

                                                                                                                                                                                                        Set priority of the action.

                                                                                                                                                                                                        Parameters:

                                                                                                                                                                                                        Name Type Description Default
                                                                                                                                                                                                        priority PriorityStr | Priority

                                                                                                                                                                                                        priority for the action

                                                                                                                                                                                                        required
                                                                                                                                                                                                        Source code in prettyqt/gui/action.py
                                                                                                                                                                                                        def set_priority(self, priority: PriorityStr | gui.QAction.Priority):
                                                                                                                                                                                                            """Set priority of the action.
                                                                                                                                                                                                        
                                                                                                                                                                                                            Args:
                                                                                                                                                                                                                priority: priority for the action
                                                                                                                                                                                                            """
                                                                                                                                                                                                            super().setPriority(PRIORITIES.get_enum_value(priority))
                                                                                                                                                                                                        

                                                                                                                                                                                                        set_shortcut_context(context: constants.ShortcutContextStr | constants.ShortcutContext)

                                                                                                                                                                                                        Set shortcut context.

                                                                                                                                                                                                        Parameters:

                                                                                                                                                                                                        Name Type Description Default
                                                                                                                                                                                                        context ShortcutContextStr | ShortcutContext

                                                                                                                                                                                                        shortcut context

                                                                                                                                                                                                        required
                                                                                                                                                                                                        Source code in prettyqt/gui/action.py
                                                                                                                                                                                                        def set_shortcut_context(
                                                                                                                                                                                                            self, context: constants.ShortcutContextStr | constants.ShortcutContext
                                                                                                                                                                                                        ):
                                                                                                                                                                                                            """Set shortcut context.
                                                                                                                                                                                                        
                                                                                                                                                                                                            Args:
                                                                                                                                                                                                                context: shortcut context
                                                                                                                                                                                                            """
                                                                                                                                                                                                            super().setShortcutContext(constants.SHORTCUT_CONTEXT.get_enum_value(context))
                                                                                                                                                                                                        

                                                                                                                                                                                                        BackingStore

                                                                                                                                                                                                        Bases: QBackingStore

                                                                                                                                                                                                        Drawing area for QWindow.

                                                                                                                                                                                                        Source code in prettyqt/gui/backingstore.py
                                                                                                                                                                                                        class BackingStore(QtGui.QBackingStore):
                                                                                                                                                                                                            """Drawing area for QWindow."""
                                                                                                                                                                                                        
                                                                                                                                                                                                            @contextlib.contextmanager
                                                                                                                                                                                                            def paint_on_region(self, region: QtGui.QRegion):
                                                                                                                                                                                                                self.beginPaint(region)
                                                                                                                                                                                                                try:
                                                                                                                                                                                                                    yield self
                                                                                                                                                                                                                finally:
                                                                                                                                                                                                                    self.endPaint()
                                                                                                                                                                                                        

                                                                                                                                                                                                        Bitmap

                                                                                                                                                                                                        Bases: PixmapMixin, QBitmap

                                                                                                                                                                                                        Monochrome (1-bit depth) pixmaps.

                                                                                                                                                                                                        Source code in prettyqt/gui/bitmap.py
                                                                                                                                                                                                        class Bitmap(gui.PixmapMixin, gui.QBitmap):
                                                                                                                                                                                                            """Monochrome (1-bit depth) pixmaps."""
                                                                                                                                                                                                        

                                                                                                                                                                                                        Brush

                                                                                                                                                                                                        Bases: SerializeMixin, QBrush

                                                                                                                                                                                                        Defines the fill pattern of shapes drawn by QPainter.

                                                                                                                                                                                                        Source code in prettyqt/gui/brush.py
                                                                                                                                                                                                        class Brush(serializemixin.SerializeMixin, gui.QBrush):
                                                                                                                                                                                                            """Defines the fill pattern of shapes drawn by QPainter."""
                                                                                                                                                                                                        
                                                                                                                                                                                                            def __repr__(self):
                                                                                                                                                                                                                return get_repr(self, self.get_color(), self.get_style())
                                                                                                                                                                                                        
                                                                                                                                                                                                            def get_texture_image(self) -> gui.Image | None:
                                                                                                                                                                                                                img = self.textureImage()
                                                                                                                                                                                                                return None if img.isNull() else gui.Image(img)
                                                                                                                                                                                                        
                                                                                                                                                                                                            def get_color(self) -> gui.Color:
                                                                                                                                                                                                                return gui.Color(self.color())
                                                                                                                                                                                                        
                                                                                                                                                                                                            def get_style(self) -> constants.BrushStyleStr:
                                                                                                                                                                                                                return constants.BRUSH_STYLE.inverse[self.style()]
                                                                                                                                                                                                        
                                                                                                                                                                                                            def set_style(self, style: constants.BrushStyleStr | constants.BrushStyle):
                                                                                                                                                                                                                self.setStyle(constants.BRUSH_STYLE.get_enum_value(style))
                                                                                                                                                                                                        
                                                                                                                                                                                                            def set_transform(self, transform: datatypes.TransformType):
                                                                                                                                                                                                                if isinstance(transform, tuple):
                                                                                                                                                                                                                    transform = gui.Transform(*transform)
                                                                                                                                                                                                                self.setTransform(transform)
                                                                                                                                                                                                        

                                                                                                                                                                                                        Clipboard

                                                                                                                                                                                                        Bases: ObjectMixin

                                                                                                                                                                                                        Access to the window system clipboard.

                                                                                                                                                                                                        Source code in prettyqt/gui/clipboard.py
                                                                                                                                                                                                        class Clipboard(core.ObjectMixin):
                                                                                                                                                                                                            """Access to the window system clipboard."""
                                                                                                                                                                                                        
                                                                                                                                                                                                            def __init__(self, item: gui.QClipboard):
                                                                                                                                                                                                                self.item = item
                                                                                                                                                                                                        
                                                                                                                                                                                                            def __getattr__(self, val):
                                                                                                                                                                                                                return getattr(self.item, val)
                                                                                                                                                                                                        
                                                                                                                                                                                                            def set_pixmap(
                                                                                                                                                                                                                self,
                                                                                                                                                                                                                pixmap: gui.QPixmap | None,
                                                                                                                                                                                                                mode: ModeStr | gui.QClipboard.Mode = "clipboard",
                                                                                                                                                                                                            ):
                                                                                                                                                                                                                if pixmap is None:
                                                                                                                                                                                                                    pixmap = gui.QPixmap()
                                                                                                                                                                                                                self.item.setPixmap(pixmap, MODES.get_enum_value(mode))
                                                                                                                                                                                                        
                                                                                                                                                                                                            def get_pixmap(
                                                                                                                                                                                                                self, mode: ModeStr | gui.QClipboard.Mode = "clipboard"
                                                                                                                                                                                                            ) -> gui.Pixmap | None:
                                                                                                                                                                                                                val = MODES.get_enum_value(mode)
                                                                                                                                                                                                                pix = gui.Pixmap(self.item.pixmap(val))
                                                                                                                                                                                                                return None if pix.isNull() else pix
                                                                                                                                                                                                        
                                                                                                                                                                                                            def set_image(
                                                                                                                                                                                                                self,
                                                                                                                                                                                                                image: gui.QImage | None,
                                                                                                                                                                                                                mode: ModeStr | gui.QClipboard.Mode = "clipboard",
                                                                                                                                                                                                            ):
                                                                                                                                                                                                                if image is None:
                                                                                                                                                                                                                    image = gui.QImage()
                                                                                                                                                                                                                self.item.setImage(image, MODES.get_enum_value(mode))
                                                                                                                                                                                                        
                                                                                                                                                                                                            def get_image(
                                                                                                                                                                                                                self, mode: ModeStr | gui.QClipboard.Mode = "clipboard"
                                                                                                                                                                                                            ) -> gui.Image | None:
                                                                                                                                                                                                                img = gui.Image(self.item.image(MODES.get_enum_value(mode)))
                                                                                                                                                                                                                return None if img.isNull() else img
                                                                                                                                                                                                        
                                                                                                                                                                                                            def set_mimedata(
                                                                                                                                                                                                                self,
                                                                                                                                                                                                                mimedata: core.QMimeData,
                                                                                                                                                                                                                mode: ModeStr | gui.QClipboard.Mode = "clipboard",
                                                                                                                                                                                                            ):
                                                                                                                                                                                                                self.item.setMimeData(mimedata, MODES.get_enum_value(mode))
                                                                                                                                                                                                        
                                                                                                                                                                                                            def get_mimedata(
                                                                                                                                                                                                                self, mode: ModeStr | gui.QClipboard.Mode = "clipboard"
                                                                                                                                                                                                            ) -> core.QMimeData:
                                                                                                                                                                                                                return self.item.mimeData(MODES.get_enum_value(mode))
                                                                                                                                                                                                        
                                                                                                                                                                                                            def set_text(self, text: str, mode: ModeStr | gui.QClipboard.Mode = "clipboard"):
                                                                                                                                                                                                                self.item.setText(text, MODES.get_enum_value(mode))
                                                                                                                                                                                                        
                                                                                                                                                                                                            def get_text(self, mode: ModeStr | gui.QClipboard.Mode = "clipboard") -> str:
                                                                                                                                                                                                                return self.item.text(MODES.get_enum_value(mode))
                                                                                                                                                                                                        

                                                                                                                                                                                                        Color

                                                                                                                                                                                                        Bases: QColor

                                                                                                                                                                                                        Colors based on RGB, HSV or CMYK values.

                                                                                                                                                                                                        Source code in prettyqt/gui/color.py
                                                                                                                                                                                                        class Color(QtGui.QColor):
                                                                                                                                                                                                            """Colors based on RGB, HSV or CMYK values."""
                                                                                                                                                                                                        
                                                                                                                                                                                                            def __init__(self, *args):
                                                                                                                                                                                                                match args:
                                                                                                                                                                                                                    case (QtGui.QColor() as color,):
                                                                                                                                                                                                                        if not color.isValid():
                                                                                                                                                                                                                            super().__init__()
                                                                                                                                                                                                                        else:
                                                                                                                                                                                                                            super().__init__(color.convertTo(color.spec()))
                                                                                                                                                                                                                    case (str(),):
                                                                                                                                                                                                                        if not is_valid_color(args[0]):
                                                                                                                                                                                                                            raise ValueError(args[0])
                                                                                                                                                                                                                        super().__init__(args[0])
                                                                                                                                                                                                                    case _:
                                                                                                                                                                                                                        super().__init__(*args)
                                                                                                                                                                                                        
                                                                                                                                                                                                            def __repr__(self):
                                                                                                                                                                                                                return get_repr(self, self.red(), self.green(), self.blue(), self.alpha())
                                                                                                                                                                                                        
                                                                                                                                                                                                            def __str__(self):
                                                                                                                                                                                                                return self.name() if self.alpha() == 255 else self.name(self.NameFormat.HexArgb)  # noqa: PLR2004
                                                                                                                                                                                                        
                                                                                                                                                                                                            def __reduce__(self):
                                                                                                                                                                                                                return type(self), (self.red(), self.green(), self.blue(), self.alpha())
                                                                                                                                                                                                        
                                                                                                                                                                                                            def __format__(self, format_spec: NameStr):
                                                                                                                                                                                                                try:
                                                                                                                                                                                                                    return self.get_name(format_spec)
                                                                                                                                                                                                                except ValueError:
                                                                                                                                                                                                                    return super().__format__(format_spec)
                                                                                                                                                                                                        
                                                                                                                                                                                                            @property
                                                                                                                                                                                                            def _red(self) -> int:
                                                                                                                                                                                                                return self.red()
                                                                                                                                                                                                        
                                                                                                                                                                                                            @property
                                                                                                                                                                                                            def _green(self) -> int:
                                                                                                                                                                                                                return self.green()
                                                                                                                                                                                                        
                                                                                                                                                                                                            @property
                                                                                                                                                                                                            def _blue(self) -> int:
                                                                                                                                                                                                                return self.blue()
                                                                                                                                                                                                        
                                                                                                                                                                                                            @property
                                                                                                                                                                                                            def _alpha(self) -> int:
                                                                                                                                                                                                                return self.alpha()
                                                                                                                                                                                                        
                                                                                                                                                                                                            __match_args__ = ("_red", "_green", "_blue", "_alpha")
                                                                                                                                                                                                        
                                                                                                                                                                                                            def serialize(self) -> dict[str, Any]:
                                                                                                                                                                                                                return dict(color=self.name())
                                                                                                                                                                                                        
                                                                                                                                                                                                            def set_color(self, color: str | tuple):
                                                                                                                                                                                                                if isinstance(color, str):
                                                                                                                                                                                                                    parsed = QtGui.QColor.fromString(color)
                                                                                                                                                                                                                    if not parsed.isValid():
                                                                                                                                                                                                                        raise ValueError(color)
                                                                                                                                                                                                                    self.setRgba(parsed.rgba())
                                                                                                                                                                                                                else:
                                                                                                                                                                                                                    self.setRgb(*color)
                                                                                                                                                                                                        
                                                                                                                                                                                                            @classmethod
                                                                                                                                                                                                            def from_cmyk(cls, c: float, m: float, y: float, k: float, a: float = 1.0) -> Self:
                                                                                                                                                                                                                return cls(cls.fromCmykF(c, m, y, k, a))
                                                                                                                                                                                                        
                                                                                                                                                                                                            @classmethod
                                                                                                                                                                                                            def from_hsv(cls, h: float, s: float, v: float, a: float = 1.0) -> Self:
                                                                                                                                                                                                                return cls(cls.fromHsvF(h, s, v, a))
                                                                                                                                                                                                        
                                                                                                                                                                                                            # @classmethod
                                                                                                                                                                                                            # def interpolate_color(
                                                                                                                                                                                                            #     cls,
                                                                                                                                                                                                            #     start: QtGui.QColor,
                                                                                                                                                                                                            #     end: QtGui.QColor,
                                                                                                                                                                                                            #     percent: int,
                                                                                                                                                                                                            #     colorspace: SpecStr | QtGui.QColor.Spec = "rgb",
                                                                                                                                                                                                            # ) -> Self:
                                                                                                                                                                                                            #     """Get an interpolated color value.
                                                                                                                                                                                                        
                                                                                                                                                                                                            #     Args:
                                                                                                                                                                                                            #         start: The start color.
                                                                                                                                                                                                            #         end: The end color.
                                                                                                                                                                                                            #         percent: Which value to get (0 - 100)
                                                                                                                                                                                                            #         colorspace: The desired interpolation color system. If None, take
                                                                                                                                                                                                            #                     system from start color.
                                                                                                                                                                                                            #     Return:
                                                                                                                                                                                                            #         The interpolated QColor, with the same spec as the given start color.
                                                                                                                                                                                                            #     """
                                                                                                                                                                                                            #     def _get_color(colorspace, start, end):
                                                                                                                                                                                                            #         out = cls()
                                                                                                                                                                                                            #         match colorspace:
                                                                                                                                                                                                            #             case "rgb":
                                                                                                                                                                                                            #                 components = helpers.get_color_percentage(
                                                                                                                                                                                                            #                     _components(start.getRgb()), _components(end.getRgb()), percent
                                                                                                                                                                                                            #                 )
                                                                                                                                                                                                            #                 out.setRgb(*components)
                                                                                                                                                                                                            #             case "hsv":
                                                                                                                                                                                                            #                 components = helpers.get_color_percentage(
                                                                                                                                                                                                            #                     _components(start.getHsv()), _components(end.getHsv()), percent
                                                                                                                                                                                                            #                 )
                                                                                                                                                                                                            #                 out.setHsv(*components)
                                                                                                                                                                                                            #             case "hsl":
                                                                                                                                                                                                            #                 components = helpers.get_color_percentage(
                                                                                                                                                                                                            #                     _components(start.getHsl()), _components(end.getHsl()), percent
                                                                                                                                                                                                            #                 )
                                                                                                                                                                                                            #                 out.setHsl(*components)
                                                                                                                                                                                                            #         return out
                                                                                                                                                                                                        
                                                                                                                                                                                                            #     match colorspace:
                                                                                                                                                                                                            #         case None:
                                                                                                                                                                                                            #             colorspace = SPEC.inverse[start.spec()]
                                                                                                                                                                                                            #             color = _get_color(colorspace, start, end)
                                                                                                                                                                                                            #         case str() | QtGui.QColor.Spec():
                                                                                                                                                                                                            #             colorspace = SPEC.get_str_value(colorspace)
                                                                                                                                                                                                            #             color = _get_color(colorspace, start, end)
                                                                                                                                                                                                            #         case _:
                                                                                                                                                                                                            #             raise ValueError("Invalid colorspace!")
                                                                                                                                                                                                            #     return cls(color.convert_to(colorspace))
                                                                                                                                                                                                        
                                                                                                                                                                                                            @classmethod
                                                                                                                                                                                                            def interpolate_color(
                                                                                                                                                                                                                cls,
                                                                                                                                                                                                                start: QtGui.QColor,
                                                                                                                                                                                                                end: QtGui.QColor,
                                                                                                                                                                                                                percent: int,
                                                                                                                                                                                                                colorspace: SpecStr | None = "rgb",
                                                                                                                                                                                                            ) -> Self:
                                                                                                                                                                                                                """Get an interpolated color value.
                                                                                                                                                                                                        
                                                                                                                                                                                                                Args:
                                                                                                                                                                                                                    start: The start color.
                                                                                                                                                                                                                    end: The end color.
                                                                                                                                                                                                                    percent: Which value to get (0 - 100)
                                                                                                                                                                                                                    colorspace: The desired interpolation color system,
                                                                                                                                                                                                                                QColor::{Rgb,Hsv,Hsl} (from QColor::Spec enum)
                                                                                                                                                                                                                                If None, start is used except when percent is 100.
                                                                                                                                                                                                        
                                                                                                                                                                                                                Return:
                                                                                                                                                                                                                    The interpolated QColor, with the same spec as the given start color.
                                                                                                                                                                                                                """
                                                                                                                                                                                                                if colorspace is None:
                                                                                                                                                                                                                    return (
                                                                                                                                                                                                                        cls(*_components(end.getRgb()))
                                                                                                                                                                                                                        if percent == 100  # noqa: PLR2004
                                                                                                                                                                                                                        else cls(*_components(start.getRgb()))
                                                                                                                                                                                                                    )
                                                                                                                                                                                                                out = cls()
                                                                                                                                                                                                                match colorspace:
                                                                                                                                                                                                                    case "rgb":
                                                                                                                                                                                                                        components = helpers.get_color_percentage(
                                                                                                                                                                                                                            _components(start.getRgb()),
                                                                                                                                                                                                                            _components(end.getRgb()),
                                                                                                                                                                                                                            percent,
                                                                                                                                                                                                                        )
                                                                                                                                                                                                                        out.setRgb(*components)
                                                                                                                                                                                                                    case "hsv":
                                                                                                                                                                                                                        components = helpers.get_color_percentage(
                                                                                                                                                                                                                            _components(start.getHsv()),
                                                                                                                                                                                                                            _components(end.getHsv()),
                                                                                                                                                                                                                            percent,
                                                                                                                                                                                                                        )
                                                                                                                                                                                                                        out.setHsv(*components)
                                                                                                                                                                                                                    case "hsl":
                                                                                                                                                                                                                        components = helpers.get_color_percentage(
                                                                                                                                                                                                                            _components(start.getHsl()),
                                                                                                                                                                                                                            _components(end.getHsl()),
                                                                                                                                                                                                                            percent,
                                                                                                                                                                                                                        )
                                                                                                                                                                                                                        out.setHsl(*components)
                                                                                                                                                                                                                    case _:
                                                                                                                                                                                                                        msg = "Invalid colorspace!"
                                                                                                                                                                                                                        raise ValueError(msg)
                                                                                                                                                                                                                return cls(out.convertTo(start.spec()))
                                                                                                                                                                                                        
                                                                                                                                                                                                            def is_dark(self) -> bool:
                                                                                                                                                                                                                """Check whether a color is 'dark'."""
                                                                                                                                                                                                                return self.lightness() < 128  # noqa: PLR2004
                                                                                                                                                                                                        
                                                                                                                                                                                                            def get_spec(self) -> SpecStr:
                                                                                                                                                                                                                return SPEC.inverse[self.spec()]
                                                                                                                                                                                                        
                                                                                                                                                                                                            def convert_to(self, spec: SpecStr) -> Self:
                                                                                                                                                                                                                # return Color(self.convertTo(SPEC[spec]))
                                                                                                                                                                                                                color = type(self)()
                                                                                                                                                                                                                match spec:
                                                                                                                                                                                                                    case "rgb":
                                                                                                                                                                                                                        rgb = _components(self.getRgb())
                                                                                                                                                                                                                        color.setRgb(*rgb)
                                                                                                                                                                                                                    case "hsv":
                                                                                                                                                                                                                        hsv = _components(self.getHsv())
                                                                                                                                                                                                                        color.setHsv(*hsv)
                                                                                                                                                                                                                    case "cmyk":
                                                                                                                                                                                                                        cmyk = _components(self.getCmyk())
                                                                                                                                                                                                                        color.setCmyk(*cmyk)
                                                                                                                                                                                                                    case "hsl":
                                                                                                                                                                                                                        hsl = _components(self.getHsl())
                                                                                                                                                                                                                        color.setHsl(*hsl)
                                                                                                                                                                                                                    case "extended_rgb":
                                                                                                                                                                                                                        ergb = _components(self.getRgbF())
                                                                                                                                                                                                                        color.setRgbF(*ergb)
                                                                                                                                                                                                                return color
                                                                                                                                                                                                        
                                                                                                                                                                                                            def get_name(self, name_format: NameStr = "hex_argb") -> str:
                                                                                                                                                                                                                match name_format:
                                                                                                                                                                                                                    case "svg_rgb" | "svg_argb" if not self.isValid():
                                                                                                                                                                                                                        return 'fill=""'
                                                                                                                                                                                                                    case "svg_rgb":
                                                                                                                                                                                                                        return f'fill="rgb({self.red()}, {self.green()}, {self.blue()})"'
                                                                                                                                                                                                                    case "svg_argb":
                                                                                                                                                                                                                        fill_str = f"rgb({self.red()}, {self.green()}, {self.blue()})"
                                                                                                                                                                                                                        return f'fill="{fill_str}" fill-opacity="{self.alphaF()}"'
                                                                                                                                                                                                                    case "qcss_argb" | "qcss_rgb":
                                                                                                                                                                                                                        return self.get_css(fmt="rgba" if name_format == "qcss_argb" else "rgb")
                                                                                                                                                                                                                    case _ if name_format in NAME_FORMAT:
                                                                                                                                                                                                                        return self.name(NAME_FORMAT[name_format])
                                                                                                                                                                                                                    case _:
                                                                                                                                                                                                                        raise ValueError(name_format)
                                                                                                                                                                                                        
                                                                                                                                                                                                            def get_css(self, fmt: Literal["rgb", "rgba", "hsva", "hsla"] | None = None) -> str:
                                                                                                                                                                                                                css_format = fmt or self.spec()
                                                                                                                                                                                                                match css_format:
                                                                                                                                                                                                                    case self.Spec.Rgb | "rgba":
                                                                                                                                                                                                                        string = ", ".join([str(i) for i in _components(self.getRgb())])
                                                                                                                                                                                                                        return f"rgba({string})"
                                                                                                                                                                                                                    case self.Spec.Hsv | "hsva":
                                                                                                                                                                                                                        string = ", ".join([str(i) for i in _components(self.getHsv())])
                                                                                                                                                                                                                        return f"hsva({string})"
                                                                                                                                                                                                                    case self.Spec.Hsl | "hsla":
                                                                                                                                                                                                                        string = ", ".join([str(i) for i in _components(self.getHsl())])
                                                                                                                                                                                                                        return f"hsla({string})"
                                                                                                                                                                                                                    case "rgb":
                                                                                                                                                                                                                        return f"rgb({self.red()}, {self.green()}, {self.blue()})"
                                                                                                                                                                                                                    case _:
                                                                                                                                                                                                                        raise ValueError(css_format)
                                                                                                                                                                                                        
                                                                                                                                                                                                            def as_qt(self) -> QtGui.QColor:
                                                                                                                                                                                                                return self.convertTo(self.spec())
                                                                                                                                                                                                        
                                                                                                                                                                                                            def inverted(self, invert_alpha: bool = False) -> Self:
                                                                                                                                                                                                                return type(self)(
                                                                                                                                                                                                                    255 - self.red(),
                                                                                                                                                                                                                    255 - self.green(),
                                                                                                                                                                                                                    255 - self.blue(),
                                                                                                                                                                                                                    255 - self.alpha() if invert_alpha else self.alpha(),
                                                                                                                                                                                                                )
                                                                                                                                                                                                        
                                                                                                                                                                                                            def drift(self, factor: float = 1.0) -> Self:
                                                                                                                                                                                                                """Return color that is lighter or darker than the base color."""
                                                                                                                                                                                                                kls = type(self)
                                                                                                                                                                                                                if self == Color("#000000"):
                                                                                                                                                                                                                    return kls(Color("#050505").lighter(int(factor * 100)))
                                                                                                                                                                                                                if self.lightness() > 128:  # noqa: PLR2004
                                                                                                                                                                                                                    return kls(self.darker(int(factor * 100)))
                                                                                                                                                                                                                return kls(self.lighter(int(factor * 100)))
                                                                                                                                                                                                        

                                                                                                                                                                                                        drift(factor: float = 1.0) -> Self

                                                                                                                                                                                                        Return color that is lighter or darker than the base color.

                                                                                                                                                                                                        Source code in prettyqt/gui/color.py
                                                                                                                                                                                                        def drift(self, factor: float = 1.0) -> Self:
                                                                                                                                                                                                            """Return color that is lighter or darker than the base color."""
                                                                                                                                                                                                            kls = type(self)
                                                                                                                                                                                                            if self == Color("#000000"):
                                                                                                                                                                                                                return kls(Color("#050505").lighter(int(factor * 100)))
                                                                                                                                                                                                            if self.lightness() > 128:  # noqa: PLR2004
                                                                                                                                                                                                                return kls(self.darker(int(factor * 100)))
                                                                                                                                                                                                            return kls(self.lighter(int(factor * 100)))
                                                                                                                                                                                                        

                                                                                                                                                                                                        interpolate_color(start: QtGui.QColor, end: QtGui.QColor, percent: int, colorspace: SpecStr | None = 'rgb') -> Self classmethod

                                                                                                                                                                                                        Get an interpolated color value.

                                                                                                                                                                                                        Parameters:

                                                                                                                                                                                                        Name Type Description Default
                                                                                                                                                                                                        start QColor

                                                                                                                                                                                                        The start color.

                                                                                                                                                                                                        required
                                                                                                                                                                                                        end QColor

                                                                                                                                                                                                        The end color.

                                                                                                                                                                                                        required
                                                                                                                                                                                                        percent int

                                                                                                                                                                                                        Which value to get (0 - 100)

                                                                                                                                                                                                        required
                                                                                                                                                                                                        colorspace SpecStr | None

                                                                                                                                                                                                        The desired interpolation color system, QColor::{Rgb,Hsv,Hsl} (from QColor::Spec enum) If None, start is used except when percent is 100.

                                                                                                                                                                                                        'rgb'
                                                                                                                                                                                                        Return

                                                                                                                                                                                                        The interpolated QColor, with the same spec as the given start color.

                                                                                                                                                                                                        Source code in prettyqt/gui/color.py
                                                                                                                                                                                                        @classmethod
                                                                                                                                                                                                        def interpolate_color(
                                                                                                                                                                                                            cls,
                                                                                                                                                                                                            start: QtGui.QColor,
                                                                                                                                                                                                            end: QtGui.QColor,
                                                                                                                                                                                                            percent: int,
                                                                                                                                                                                                            colorspace: SpecStr | None = "rgb",
                                                                                                                                                                                                        ) -> Self:
                                                                                                                                                                                                            """Get an interpolated color value.
                                                                                                                                                                                                        
                                                                                                                                                                                                            Args:
                                                                                                                                                                                                                start: The start color.
                                                                                                                                                                                                                end: The end color.
                                                                                                                                                                                                                percent: Which value to get (0 - 100)
                                                                                                                                                                                                                colorspace: The desired interpolation color system,
                                                                                                                                                                                                                            QColor::{Rgb,Hsv,Hsl} (from QColor::Spec enum)
                                                                                                                                                                                                                            If None, start is used except when percent is 100.
                                                                                                                                                                                                        
                                                                                                                                                                                                            Return:
                                                                                                                                                                                                                The interpolated QColor, with the same spec as the given start color.
                                                                                                                                                                                                            """
                                                                                                                                                                                                            if colorspace is None:
                                                                                                                                                                                                                return (
                                                                                                                                                                                                                    cls(*_components(end.getRgb()))
                                                                                                                                                                                                                    if percent == 100  # noqa: PLR2004
                                                                                                                                                                                                                    else cls(*_components(start.getRgb()))
                                                                                                                                                                                                                )
                                                                                                                                                                                                            out = cls()
                                                                                                                                                                                                            match colorspace:
                                                                                                                                                                                                                case "rgb":
                                                                                                                                                                                                                    components = helpers.get_color_percentage(
                                                                                                                                                                                                                        _components(start.getRgb()),
                                                                                                                                                                                                                        _components(end.getRgb()),
                                                                                                                                                                                                                        percent,
                                                                                                                                                                                                                    )
                                                                                                                                                                                                                    out.setRgb(*components)
                                                                                                                                                                                                                case "hsv":
                                                                                                                                                                                                                    components = helpers.get_color_percentage(
                                                                                                                                                                                                                        _components(start.getHsv()),
                                                                                                                                                                                                                        _components(end.getHsv()),
                                                                                                                                                                                                                        percent,
                                                                                                                                                                                                                    )
                                                                                                                                                                                                                    out.setHsv(*components)
                                                                                                                                                                                                                case "hsl":
                                                                                                                                                                                                                    components = helpers.get_color_percentage(
                                                                                                                                                                                                                        _components(start.getHsl()),
                                                                                                                                                                                                                        _components(end.getHsl()),
                                                                                                                                                                                                                        percent,
                                                                                                                                                                                                                    )
                                                                                                                                                                                                                    out.setHsl(*components)
                                                                                                                                                                                                                case _:
                                                                                                                                                                                                                    msg = "Invalid colorspace!"
                                                                                                                                                                                                                    raise ValueError(msg)
                                                                                                                                                                                                            return cls(out.convertTo(start.spec()))
                                                                                                                                                                                                        

                                                                                                                                                                                                        is_dark() -> bool

                                                                                                                                                                                                        Check whether a color is 'dark'.

                                                                                                                                                                                                        Source code in prettyqt/gui/color.py
                                                                                                                                                                                                        def is_dark(self) -> bool:
                                                                                                                                                                                                            """Check whether a color is 'dark'."""
                                                                                                                                                                                                            return self.lightness() < 128  # noqa: PLR2004
                                                                                                                                                                                                        

                                                                                                                                                                                                        ColorSpace

                                                                                                                                                                                                        Bases: SerializeMixin, QColorSpace

                                                                                                                                                                                                        Color space abstraction.

                                                                                                                                                                                                        Source code in prettyqt/gui/colorspace.py
                                                                                                                                                                                                        class ColorSpace(serializemixin.SerializeMixin, QtGui.QColorSpace):
                                                                                                                                                                                                            """Color space abstraction."""
                                                                                                                                                                                                        
                                                                                                                                                                                                            def __bool__(self):
                                                                                                                                                                                                                return self.isValid()
                                                                                                                                                                                                        
                                                                                                                                                                                                            def set_primaries(self, primaries: PrimariesStr | QtGui.QColorSpace.Primaries):
                                                                                                                                                                                                                """Set primaries.
                                                                                                                                                                                                        
                                                                                                                                                                                                                Args:
                                                                                                                                                                                                                    primaries: primaries to use
                                                                                                                                                                                                                """
                                                                                                                                                                                                                self.setPrimaries(PRIMARIES.get_enum_value(primaries))
                                                                                                                                                                                                        
                                                                                                                                                                                                            def get_primaries(self) -> PrimariesStr:
                                                                                                                                                                                                                """Return current primaries.
                                                                                                                                                                                                        
                                                                                                                                                                                                                Returns:
                                                                                                                                                                                                                    primaries
                                                                                                                                                                                                                """
                                                                                                                                                                                                                return PRIMARIES.inverse[self.primaries()]
                                                                                                                                                                                                        
                                                                                                                                                                                                            def set_transfer_function(
                                                                                                                                                                                                                self,
                                                                                                                                                                                                                fn: TransformFunctionStr | QtGui.QColorSpace.TransferFunction,
                                                                                                                                                                                                                gamma: float = 0.0,
                                                                                                                                                                                                            ):
                                                                                                                                                                                                                """Set transfer function.
                                                                                                                                                                                                        
                                                                                                                                                                                                                Args:
                                                                                                                                                                                                                    fn: transfer function to use
                                                                                                                                                                                                                    gamma: gamma value
                                                                                                                                                                                                                """
                                                                                                                                                                                                                self.setTransferFunction(TRANSFER_FUNCTION.get_enum_value(fn), gamma)
                                                                                                                                                                                                        
                                                                                                                                                                                                            def get_transfer_function(self) -> TransformFunctionStr:
                                                                                                                                                                                                                """Return current transfer function.
                                                                                                                                                                                                        
                                                                                                                                                                                                                Returns:
                                                                                                                                                                                                                    transfer function
                                                                                                                                                                                                                """
                                                                                                                                                                                                                return TRANSFER_FUNCTION.inverse[self.transferFunction()]
                                                                                                                                                                                                        

                                                                                                                                                                                                        get_primaries() -> PrimariesStr

                                                                                                                                                                                                        Return current primaries.

                                                                                                                                                                                                        Source code in prettyqt/gui/colorspace.py
                                                                                                                                                                                                        def get_primaries(self) -> PrimariesStr:
                                                                                                                                                                                                            """Return current primaries.
                                                                                                                                                                                                        
                                                                                                                                                                                                            Returns:
                                                                                                                                                                                                                primaries
                                                                                                                                                                                                            """
                                                                                                                                                                                                            return PRIMARIES.inverse[self.primaries()]
                                                                                                                                                                                                        

                                                                                                                                                                                                        get_transfer_function() -> TransformFunctionStr

                                                                                                                                                                                                        Return current transfer function.

                                                                                                                                                                                                        Source code in prettyqt/gui/colorspace.py
                                                                                                                                                                                                        def get_transfer_function(self) -> TransformFunctionStr:
                                                                                                                                                                                                            """Return current transfer function.
                                                                                                                                                                                                        
                                                                                                                                                                                                            Returns:
                                                                                                                                                                                                                transfer function
                                                                                                                                                                                                            """
                                                                                                                                                                                                            return TRANSFER_FUNCTION.inverse[self.transferFunction()]
                                                                                                                                                                                                        

                                                                                                                                                                                                        set_primaries(primaries: PrimariesStr | QtGui.QColorSpace.Primaries)

                                                                                                                                                                                                        Set primaries.

                                                                                                                                                                                                        Parameters:

                                                                                                                                                                                                        Name Type Description Default
                                                                                                                                                                                                        primaries PrimariesStr | Primaries

                                                                                                                                                                                                        primaries to use

                                                                                                                                                                                                        required
                                                                                                                                                                                                        Source code in prettyqt/gui/colorspace.py
                                                                                                                                                                                                        def set_primaries(self, primaries: PrimariesStr | QtGui.QColorSpace.Primaries):
                                                                                                                                                                                                            """Set primaries.
                                                                                                                                                                                                        
                                                                                                                                                                                                            Args:
                                                                                                                                                                                                                primaries: primaries to use
                                                                                                                                                                                                            """
                                                                                                                                                                                                            self.setPrimaries(PRIMARIES.get_enum_value(primaries))
                                                                                                                                                                                                        

                                                                                                                                                                                                        set_transfer_function(fn: TransformFunctionStr | QtGui.QColorSpace.TransferFunction, gamma: float = 0.0)

                                                                                                                                                                                                        Set transfer function.

                                                                                                                                                                                                        Parameters:

                                                                                                                                                                                                        Name Type Description Default
                                                                                                                                                                                                        fn TransformFunctionStr | TransferFunction

                                                                                                                                                                                                        transfer function to use

                                                                                                                                                                                                        required
                                                                                                                                                                                                        gamma float

                                                                                                                                                                                                        gamma value

                                                                                                                                                                                                        0.0
                                                                                                                                                                                                        Source code in prettyqt/gui/colorspace.py
                                                                                                                                                                                                        def set_transfer_function(
                                                                                                                                                                                                            self,
                                                                                                                                                                                                            fn: TransformFunctionStr | QtGui.QColorSpace.TransferFunction,
                                                                                                                                                                                                            gamma: float = 0.0,
                                                                                                                                                                                                        ):
                                                                                                                                                                                                            """Set transfer function.
                                                                                                                                                                                                        
                                                                                                                                                                                                            Args:
                                                                                                                                                                                                                fn: transfer function to use
                                                                                                                                                                                                                gamma: gamma value
                                                                                                                                                                                                            """
                                                                                                                                                                                                            self.setTransferFunction(TRANSFER_FUNCTION.get_enum_value(fn), gamma)
                                                                                                                                                                                                        

                                                                                                                                                                                                        ColorTransform

                                                                                                                                                                                                        Bases: QColorTransform

                                                                                                                                                                                                        Transformation between color spaces.

                                                                                                                                                                                                        Source code in prettyqt/gui/colortransform.py
                                                                                                                                                                                                        class ColorTransform(QtGui.QColorTransform):
                                                                                                                                                                                                            """Transformation between color spaces."""
                                                                                                                                                                                                        
                                                                                                                                                                                                            def __repr__(self):
                                                                                                                                                                                                                return get_repr(self)
                                                                                                                                                                                                        
                                                                                                                                                                                                            def map_color(self, color: datatypes.ColorType) -> gui.Color:
                                                                                                                                                                                                                """Apply the color transformation to a color."""
                                                                                                                                                                                                                return gui.Color(self.map(colors.get_color(color)))
                                                                                                                                                                                                        

                                                                                                                                                                                                        map_color(color: datatypes.ColorType) -> gui.Color

                                                                                                                                                                                                        Apply the color transformation to a color.

                                                                                                                                                                                                        Source code in prettyqt/gui/colortransform.py
                                                                                                                                                                                                        def map_color(self, color: datatypes.ColorType) -> gui.Color:
                                                                                                                                                                                                            """Apply the color transformation to a color."""
                                                                                                                                                                                                            return gui.Color(self.map(colors.get_color(color)))
                                                                                                                                                                                                        

                                                                                                                                                                                                        ConicalGradient

                                                                                                                                                                                                        Bases: GradientMixin, QConicalGradient

                                                                                                                                                                                                        Used in combination with QBrush to specify a conical gradient brush.

                                                                                                                                                                                                        Source code in prettyqt/gui/conicalgradient.py
                                                                                                                                                                                                        class ConicalGradient(gui.GradientMixin, gui.QConicalGradient):
                                                                                                                                                                                                            """Used in combination with QBrush to specify a conical gradient brush."""
                                                                                                                                                                                                        
                                                                                                                                                                                                            def __repr__(self):
                                                                                                                                                                                                                return get_repr(self, self.get_center(), self.angle())
                                                                                                                                                                                                        
                                                                                                                                                                                                            def get_center(self) -> core.PointF:
                                                                                                                                                                                                                return core.PointF(self.center())
                                                                                                                                                                                                        
                                                                                                                                                                                                            def get_css(self) -> str:
                                                                                                                                                                                                                """Convert gradient to a CSS string. Can be used for stylesheets."""
                                                                                                                                                                                                                center = self.center()
                                                                                                                                                                                                                cx, cy = center.x(), center.y()
                                                                                                                                                                                                                stops = self.stops()
                                                                                                                                                                                                                stops = "\n".join(f"    stop: {stop:f} {color.name()}" for stop, color in stops)
                                                                                                                                                                                                                spread = self.get_spread()
                                                                                                                                                                                                                return (
                                                                                                                                                                                                                    "qconicalgradient(\n"
                                                                                                                                                                                                                    f"    cx: {cx}, cy: {cy}, angle: {self.angle()}, spread:{spread},\n"
                                                                                                                                                                                                                    f"{stops})"
                                                                                                                                                                                                                )
                                                                                                                                                                                                        

                                                                                                                                                                                                        get_css() -> str

                                                                                                                                                                                                        Convert gradient to a CSS string. Can be used for stylesheets.

                                                                                                                                                                                                        Source code in prettyqt/gui/conicalgradient.py
                                                                                                                                                                                                        def get_css(self) -> str:
                                                                                                                                                                                                            """Convert gradient to a CSS string. Can be used for stylesheets."""
                                                                                                                                                                                                            center = self.center()
                                                                                                                                                                                                            cx, cy = center.x(), center.y()
                                                                                                                                                                                                            stops = self.stops()
                                                                                                                                                                                                            stops = "\n".join(f"    stop: {stop:f} {color.name()}" for stop, color in stops)
                                                                                                                                                                                                            spread = self.get_spread()
                                                                                                                                                                                                            return (
                                                                                                                                                                                                                "qconicalgradient(\n"
                                                                                                                                                                                                                f"    cx: {cx}, cy: {cy}, angle: {self.angle()}, spread:{spread},\n"
                                                                                                                                                                                                                f"{stops})"
                                                                                                                                                                                                            )
                                                                                                                                                                                                        

                                                                                                                                                                                                        Cursor

                                                                                                                                                                                                        Bases: SerializeMixin, QCursor

                                                                                                                                                                                                        Provides a mouse cursor with an arbitrary shape.

                                                                                                                                                                                                        This class is mainly used to create mouse cursors that are associated with particular widgets and to get and set the position of the mouse cursor. Qt has a number of standard cursor shapes, but you can also make custom cursor shapes based on a QBitmap, a mask and a hotspot. To associate a cursor with a widget, use widget.set_cursor(). To associate a cursor with all widgets (normally for a short period of time), use GuiApplication.set_override_cursor(). To set a cursor shape use QCursor.setShape() or use the QCursor constructor which takes the shape as argument, or you can use one of the predefined cursors defined in the Qt.CursorShape enum. If you want to create a cursor with your own bitmap, either use the QCursor constructor which takes a bitmap and a mask or the constructor which takes a pixmap as arguments. To set or get the position of the mouse cursor use the static methods QCursor.pos() and QCursor.setPos().

                                                                                                                                                                                                        !!! note: It is possible to create a QCursor before QGuiApplication, but it is not useful except as a place-holder for a real QCursor created after QGuiApplication. Attempting to use a QCursor that was created before QGuiApplication will result in a crash.

                                                                                                                                                                                                        Source code in prettyqt/gui/cursor.py
                                                                                                                                                                                                        class Cursor(serializemixin.SerializeMixin, gui.QCursor):
                                                                                                                                                                                                            """Provides a mouse cursor with an arbitrary shape.
                                                                                                                                                                                                        
                                                                                                                                                                                                            This class is mainly used to create mouse cursors that are associated
                                                                                                                                                                                                            with particular widgets and to get and set the position of the mouse cursor.
                                                                                                                                                                                                            Qt has a number of standard cursor shapes, but you can also make custom cursor
                                                                                                                                                                                                            shapes based on a QBitmap, a mask and a hotspot.
                                                                                                                                                                                                            To associate a cursor with a widget, use `widget.set_cursor()`.
                                                                                                                                                                                                            To associate a cursor with all widgets (normally for a short period of time),
                                                                                                                                                                                                            use `GuiApplication.set_override_cursor()`.
                                                                                                                                                                                                            To set a cursor shape use `QCursor.setShape()` or use the QCursor
                                                                                                                                                                                                            constructor which takes the shape as argument, or you can use one of the
                                                                                                                                                                                                            predefined cursors defined in the `Qt.CursorShape` enum.
                                                                                                                                                                                                            If you want to create a cursor with your own bitmap,
                                                                                                                                                                                                            either use the QCursor constructor which takes a bitmap and a mask
                                                                                                                                                                                                            or the constructor which takes a pixmap as arguments.
                                                                                                                                                                                                            To set or get the position of the mouse cursor use the
                                                                                                                                                                                                            static methods `QCursor.pos()` and `QCursor.setPos()`.
                                                                                                                                                                                                        
                                                                                                                                                                                                            !!! note:
                                                                                                                                                                                                                It is possible to create a QCursor before QGuiApplication,
                                                                                                                                                                                                                but it is not useful except as a place-holder for a real QCursor
                                                                                                                                                                                                                created after QGuiApplication.
                                                                                                                                                                                                                Attempting to use a QCursor that was created before QGuiApplication will
                                                                                                                                                                                                                result in a crash.
                                                                                                                                                                                                        
                                                                                                                                                                                                            """
                                                                                                                                                                                                        
                                                                                                                                                                                                            @classmethod
                                                                                                                                                                                                            def fake_mouse_move(cls):
                                                                                                                                                                                                                cls.setPos(cls.pos() + core.Point(0, 1))
                                                                                                                                                                                                                gui.GuiApplication.processEvents()
                                                                                                                                                                                                                cls.setPos(cls.pos() - core.Point(0, 1))
                                                                                                                                                                                                        
                                                                                                                                                                                                            @classmethod
                                                                                                                                                                                                            def click(cls, key=constants.MouseButton.LeftButton):
                                                                                                                                                                                                                from prettyqt import widgets
                                                                                                                                                                                                        
                                                                                                                                                                                                                app = widgets.app()
                                                                                                                                                                                                                widget = app.widgetAt(cls.pos())
                                                                                                                                                                                                                if widget is None:
                                                                                                                                                                                                                    return
                                                                                                                                                                                                                pos = cls.pos().toPointF()
                                                                                                                                                                                                                local = pos - widget.mapToGlobal(core.PointF(0, 0))
                                                                                                                                                                                                                logger.info("sending MouseClick events to %s at %s", widget, local)
                                                                                                                                                                                                                event = gui.QMouseEvent(
                                                                                                                                                                                                                    core.QEvent.Type.MouseButtonPress,
                                                                                                                                                                                                                    local,
                                                                                                                                                                                                                    pos,
                                                                                                                                                                                                                    key,
                                                                                                                                                                                                                    constants.MouseButton.NoButton,
                                                                                                                                                                                                                    constants.KeyboardModifier(0),
                                                                                                                                                                                                                )
                                                                                                                                                                                                        
                                                                                                                                                                                                                core.CoreApplication.sendEvent(widget, event)
                                                                                                                                                                                                                event = gui.QMouseEvent(
                                                                                                                                                                                                                    core.QEvent.Type.MouseButtonRelease,
                                                                                                                                                                                                                    local,
                                                                                                                                                                                                                    pos,
                                                                                                                                                                                                                    key,
                                                                                                                                                                                                                    constants.MouseButton.NoButton,
                                                                                                                                                                                                                    constants.KeyboardModifier(0),
                                                                                                                                                                                                                )
                                                                                                                                                                                                        
                                                                                                                                                                                                                core.CoreApplication.sendEvent(widget, event)
                                                                                                                                                                                                        
                                                                                                                                                                                                            def set_shape(self, shape: constants.CursorShapeStr):
                                                                                                                                                                                                                """Set cursor shape.
                                                                                                                                                                                                        
                                                                                                                                                                                                                Args:
                                                                                                                                                                                                                    shape: shape to use
                                                                                                                                                                                                                """
                                                                                                                                                                                                                self.setShape(constants.CURSOR_SHAPE.get_enum_value(shape))
                                                                                                                                                                                                        
                                                                                                                                                                                                            def get_shape(self) -> constants.CursorShapeStr:
                                                                                                                                                                                                                """Return current cursor shape.
                                                                                                                                                                                                        
                                                                                                                                                                                                                Returns:
                                                                                                                                                                                                                    cursor shape
                                                                                                                                                                                                                """
                                                                                                                                                                                                                return constants.CURSOR_SHAPE.inverse[self.shape()]
                                                                                                                                                                                                        
                                                                                                                                                                                                            @classmethod
                                                                                                                                                                                                            def get_pos(cls) -> core.Point:
                                                                                                                                                                                                                return core.Point(cls.pos())
                                                                                                                                                                                                        
                                                                                                                                                                                                            @classmethod
                                                                                                                                                                                                            def set_pos(
                                                                                                                                                                                                                cls,
                                                                                                                                                                                                                where: (
                                                                                                                                                                                                                    Literal["screen", "current"]
                                                                                                                                                                                                                    | gui.QScreen
                                                                                                                                                                                                                    | widgets.QWidget
                                                                                                                                                                                                                    | core.QRect
                                                                                                                                                                                                                    | core.QPoint
                                                                                                                                                                                                                    | tuple[int, int]
                                                                                                                                                                                                                    | tuple[int, int, int, int]
                                                                                                                                                                                                                ),
                                                                                                                                                                                                                how: Literal[
                                                                                                                                                                                                                    "center",
                                                                                                                                                                                                                    "top",
                                                                                                                                                                                                                    "left",
                                                                                                                                                                                                                    "bottom",
                                                                                                                                                                                                                    "right",
                                                                                                                                                                                                                    "top_left",
                                                                                                                                                                                                                    "top_right",
                                                                                                                                                                                                                    "bottom_left",
                                                                                                                                                                                                                    "bottom_right",
                                                                                                                                                                                                                ] = "center",
                                                                                                                                                                                                                x_offset: int = 0,
                                                                                                                                                                                                                y_offset: int = 0,
                                                                                                                                                                                                                duration: int = 0,
                                                                                                                                                                                                            ):
                                                                                                                                                                                                                """Position cursor onto screen position / widget / window / screen.
                                                                                                                                                                                                        
                                                                                                                                                                                                                Arguments:
                                                                                                                                                                                                                    where: where to position on
                                                                                                                                                                                                                    how: How to align
                                                                                                                                                                                                                    x_offset: additional x offset for final position
                                                                                                                                                                                                                    y_offset: additional y offset for final position
                                                                                                                                                                                                                    duration: movement time
                                                                                                                                                                                                                """
                                                                                                                                                                                                                match where:
                                                                                                                                                                                                                    case "current":
                                                                                                                                                                                                                        p = cls.pos()
                                                                                                                                                                                                                        geom = core.Rect(p, p)
                                                                                                                                                                                                                    case core.QPoint():
                                                                                                                                                                                                                        geom = core.Rect(where, where)
                                                                                                                                                                                                                    case (int(), int()):
                                                                                                                                                                                                                        p = core.Point(*where)
                                                                                                                                                                                                                        geom = core.Rect(p, p)
                                                                                                                                                                                                                    case (int(), int(), int(), int()):
                                                                                                                                                                                                                        geom = core.Rect(*where)
                                                                                                                                                                                                                    case core.QRect():
                                                                                                                                                                                                                        geom = where
                                                                                                                                                                                                                    case "screen":
                                                                                                                                                                                                                        geom = gui.GuiApplication.primaryScreen().geometry()
                                                                                                                                                                                                                    case gui.QScreen():
                                                                                                                                                                                                                        geom = where.geometry()
                                                                                                                                                                                                                    case _ if hasattr(where, "frameGeometry"):  # avoiding to import widgets here
                                                                                                                                                                                                                        geom = where.frameGeometry()
                                                                                                                                                                                                                    case _:
                                                                                                                                                                                                                        raise TypeError(where)
                                                                                                                                                                                                                match how:
                                                                                                                                                                                                                    case "center":
                                                                                                                                                                                                                        new = geom.center()
                                                                                                                                                                                                                    case "top":
                                                                                                                                                                                                                        new = core.Point(geom.center().x(), geom.top())
                                                                                                                                                                                                                    case "bottom":
                                                                                                                                                                                                                        new = core.Point(geom.center().x(), geom.bottom())
                                                                                                                                                                                                                    case "left":
                                                                                                                                                                                                                        new = core.Point(geom.left(), geom.center().y())
                                                                                                                                                                                                                    case "right":
                                                                                                                                                                                                                        new = core.Point(geom.right(), geom.center().y())
                                                                                                                                                                                                                    case "top_right":
                                                                                                                                                                                                                        new = geom.topRight()
                                                                                                                                                                                                                    case "top_left":
                                                                                                                                                                                                                        new = geom.topLeft()
                                                                                                                                                                                                                    case "bottom_right":
                                                                                                                                                                                                                        new = geom.bottomRight()
                                                                                                                                                                                                                    case "bottom_left":
                                                                                                                                                                                                                        new = geom.bottomLeft()
                                                                                                                                                                                                                    case _:
                                                                                                                                                                                                                        raise TypeError(how)
                                                                                                                                                                                                                new_pos = core.Point(new.x() + x_offset, new.y() + y_offset)
                                                                                                                                                                                                                if duration > 0:
                                                                                                                                                                                                                    from prettyqt.animations import cursormoveanimation
                                                                                                                                                                                                        
                                                                                                                                                                                                                    cls._cursor_animation = cursormoveanimation.CursorMoveAnimation(
                                                                                                                                                                                                                        duration=duration, end=new_pos
                                                                                                                                                                                                                    )
                                                                                                                                                                                                                    cls._cursor_animation.start()
                                                                                                                                                                                                                else:
                                                                                                                                                                                                                    cls.setPos(new_pos)
                                                                                                                                                                                                        

                                                                                                                                                                                                        get_shape() -> constants.CursorShapeStr

                                                                                                                                                                                                        Return current cursor shape.

                                                                                                                                                                                                        Source code in prettyqt/gui/cursor.py
                                                                                                                                                                                                        def get_shape(self) -> constants.CursorShapeStr:
                                                                                                                                                                                                            """Return current cursor shape.
                                                                                                                                                                                                        
                                                                                                                                                                                                            Returns:
                                                                                                                                                                                                                cursor shape
                                                                                                                                                                                                            """
                                                                                                                                                                                                            return constants.CURSOR_SHAPE.inverse[self.shape()]
                                                                                                                                                                                                        

                                                                                                                                                                                                        set_pos(where: Literal['screen', 'current'] | gui.QScreen | widgets.QWidget | core.QRect | core.QPoint | tuple[int, int] | tuple[int, int, int, int], how: Literal['center', 'top', 'left', 'bottom', 'right', 'top_left', 'top_right', 'bottom_left', 'bottom_right'] = 'center', x_offset: int = 0, y_offset: int = 0, duration: int = 0) classmethod

                                                                                                                                                                                                        Position cursor onto screen position / widget / window / screen.

                                                                                                                                                                                                        Parameters:

                                                                                                                                                                                                        Name Type Description Default
                                                                                                                                                                                                        where Literal['screen', 'current'] | QScreen | QWidget | QRect | QPoint | tuple[int, int] | tuple[int, int, int, int]

                                                                                                                                                                                                        where to position on

                                                                                                                                                                                                        required
                                                                                                                                                                                                        how Literal['center', 'top', 'left', 'bottom', 'right', 'top_left', 'top_right', 'bottom_left', 'bottom_right']

                                                                                                                                                                                                        How to align

                                                                                                                                                                                                        'center'
                                                                                                                                                                                                        x_offset int

                                                                                                                                                                                                        additional x offset for final position

                                                                                                                                                                                                        0
                                                                                                                                                                                                        y_offset int

                                                                                                                                                                                                        additional y offset for final position

                                                                                                                                                                                                        0
                                                                                                                                                                                                        duration int

                                                                                                                                                                                                        movement time

                                                                                                                                                                                                        0
                                                                                                                                                                                                        Source code in prettyqt/gui/cursor.py
                                                                                                                                                                                                        @classmethod
                                                                                                                                                                                                        def set_pos(
                                                                                                                                                                                                            cls,
                                                                                                                                                                                                            where: (
                                                                                                                                                                                                                Literal["screen", "current"]
                                                                                                                                                                                                                | gui.QScreen
                                                                                                                                                                                                                | widgets.QWidget
                                                                                                                                                                                                                | core.QRect
                                                                                                                                                                                                                | core.QPoint
                                                                                                                                                                                                                | tuple[int, int]
                                                                                                                                                                                                                | tuple[int, int, int, int]
                                                                                                                                                                                                            ),
                                                                                                                                                                                                            how: Literal[
                                                                                                                                                                                                                "center",
                                                                                                                                                                                                                "top",
                                                                                                                                                                                                                "left",
                                                                                                                                                                                                                "bottom",
                                                                                                                                                                                                                "right",
                                                                                                                                                                                                                "top_left",
                                                                                                                                                                                                                "top_right",
                                                                                                                                                                                                                "bottom_left",
                                                                                                                                                                                                                "bottom_right",
                                                                                                                                                                                                            ] = "center",
                                                                                                                                                                                                            x_offset: int = 0,
                                                                                                                                                                                                            y_offset: int = 0,
                                                                                                                                                                                                            duration: int = 0,
                                                                                                                                                                                                        ):
                                                                                                                                                                                                            """Position cursor onto screen position / widget / window / screen.
                                                                                                                                                                                                        
                                                                                                                                                                                                            Arguments:
                                                                                                                                                                                                                where: where to position on
                                                                                                                                                                                                                how: How to align
                                                                                                                                                                                                                x_offset: additional x offset for final position
                                                                                                                                                                                                                y_offset: additional y offset for final position
                                                                                                                                                                                                                duration: movement time
                                                                                                                                                                                                            """
                                                                                                                                                                                                            match where:
                                                                                                                                                                                                                case "current":
                                                                                                                                                                                                                    p = cls.pos()
                                                                                                                                                                                                                    geom = core.Rect(p, p)
                                                                                                                                                                                                                case core.QPoint():
                                                                                                                                                                                                                    geom = core.Rect(where, where)
                                                                                                                                                                                                                case (int(), int()):
                                                                                                                                                                                                                    p = core.Point(*where)
                                                                                                                                                                                                                    geom = core.Rect(p, p)
                                                                                                                                                                                                                case (int(), int(), int(), int()):
                                                                                                                                                                                                                    geom = core.Rect(*where)
                                                                                                                                                                                                                case core.QRect():
                                                                                                                                                                                                                    geom = where
                                                                                                                                                                                                                case "screen":
                                                                                                                                                                                                                    geom = gui.GuiApplication.primaryScreen().geometry()
                                                                                                                                                                                                                case gui.QScreen():
                                                                                                                                                                                                                    geom = where.geometry()
                                                                                                                                                                                                                case _ if hasattr(where, "frameGeometry"):  # avoiding to import widgets here
                                                                                                                                                                                                                    geom = where.frameGeometry()
                                                                                                                                                                                                                case _:
                                                                                                                                                                                                                    raise TypeError(where)
                                                                                                                                                                                                            match how:
                                                                                                                                                                                                                case "center":
                                                                                                                                                                                                                    new = geom.center()
                                                                                                                                                                                                                case "top":
                                                                                                                                                                                                                    new = core.Point(geom.center().x(), geom.top())
                                                                                                                                                                                                                case "bottom":
                                                                                                                                                                                                                    new = core.Point(geom.center().x(), geom.bottom())
                                                                                                                                                                                                                case "left":
                                                                                                                                                                                                                    new = core.Point(geom.left(), geom.center().y())
                                                                                                                                                                                                                case "right":
                                                                                                                                                                                                                    new = core.Point(geom.right(), geom.center().y())
                                                                                                                                                                                                                case "top_right":
                                                                                                                                                                                                                    new = geom.topRight()
                                                                                                                                                                                                                case "top_left":
                                                                                                                                                                                                                    new = geom.topLeft()
                                                                                                                                                                                                                case "bottom_right":
                                                                                                                                                                                                                    new = geom.bottomRight()
                                                                                                                                                                                                                case "bottom_left":
                                                                                                                                                                                                                    new = geom.bottomLeft()
                                                                                                                                                                                                                case _:
                                                                                                                                                                                                                    raise TypeError(how)
                                                                                                                                                                                                            new_pos = core.Point(new.x() + x_offset, new.y() + y_offset)
                                                                                                                                                                                                            if duration > 0:
                                                                                                                                                                                                                from prettyqt.animations import cursormoveanimation
                                                                                                                                                                                                        
                                                                                                                                                                                                                cls._cursor_animation = cursormoveanimation.CursorMoveAnimation(
                                                                                                                                                                                                                    duration=duration, end=new_pos
                                                                                                                                                                                                                )
                                                                                                                                                                                                                cls._cursor_animation.start()
                                                                                                                                                                                                            else:
                                                                                                                                                                                                                cls.setPos(new_pos)
                                                                                                                                                                                                        

                                                                                                                                                                                                        set_shape(shape: constants.CursorShapeStr)

                                                                                                                                                                                                        Set cursor shape.

                                                                                                                                                                                                        Parameters:

                                                                                                                                                                                                        Name Type Description Default
                                                                                                                                                                                                        shape CursorShapeStr

                                                                                                                                                                                                        shape to use

                                                                                                                                                                                                        required
                                                                                                                                                                                                        Source code in prettyqt/gui/cursor.py
                                                                                                                                                                                                        def set_shape(self, shape: constants.CursorShapeStr):
                                                                                                                                                                                                            """Set cursor shape.
                                                                                                                                                                                                        
                                                                                                                                                                                                            Args:
                                                                                                                                                                                                                shape: shape to use
                                                                                                                                                                                                            """
                                                                                                                                                                                                            self.setShape(constants.CURSOR_SHAPE.get_enum_value(shape))
                                                                                                                                                                                                        

                                                                                                                                                                                                        DesktopServices

                                                                                                                                                                                                        Bases: QDesktopServices

                                                                                                                                                                                                        Methods for accessing common desktop services.

                                                                                                                                                                                                        Source code in prettyqt/gui/desktopservices.py
                                                                                                                                                                                                        class DesktopServices(gui.QDesktopServices):
                                                                                                                                                                                                            """Methods for accessing common desktop services."""
                                                                                                                                                                                                        
                                                                                                                                                                                                            @classmethod
                                                                                                                                                                                                            def open_url(cls, location: datatypes.PathType | datatypes.UrlType) -> bool:
                                                                                                                                                                                                                if not isinstance(location, core.QUrl):
                                                                                                                                                                                                                    location = core.Url.from_user_input(os.fspath(location))
                                                                                                                                                                                                                return cls.openUrl(location)
                                                                                                                                                                                                        

                                                                                                                                                                                                        DoubleValidator

                                                                                                                                                                                                        Bases: ValidatorMixin, QDoubleValidator

                                                                                                                                                                                                        Range checking of floating-point numbers.

                                                                                                                                                                                                        Source code in prettyqt/gui/doublevalidator.py
                                                                                                                                                                                                        class DoubleValidator(gui.ValidatorMixin, gui.QDoubleValidator):
                                                                                                                                                                                                            """Range checking of floating-point numbers."""
                                                                                                                                                                                                        
                                                                                                                                                                                                            ID = "double"
                                                                                                                                                                                                        
                                                                                                                                                                                                            def __init__(self, *args, **kwargs):
                                                                                                                                                                                                                super().__init__(*args, **kwargs)
                                                                                                                                                                                                                self.setLocale(core.Locale("en-En"))
                                                                                                                                                                                                        
                                                                                                                                                                                                            def _get_map(self):
                                                                                                                                                                                                                maps = super()._get_map()
                                                                                                                                                                                                                maps |= {"notation": NOTATION}
                                                                                                                                                                                                                return maps
                                                                                                                                                                                                        
                                                                                                                                                                                                            def get_notation(self) -> NotationStr:
                                                                                                                                                                                                                return NOTATION.inverse[self.notation()]
                                                                                                                                                                                                        
                                                                                                                                                                                                            def set_notation(self, notation: NotationStr | gui.QDoubleValidator.Notation):
                                                                                                                                                                                                                self.setNotation(NOTATION.get_enum_value(notation))
                                                                                                                                                                                                        
                                                                                                                                                                                                            def __repr__(self):
                                                                                                                                                                                                                return get_repr(self, self.bottom(), self.top(), self.decimals())
                                                                                                                                                                                                        
                                                                                                                                                                                                            def __reduce__(self):
                                                                                                                                                                                                                return type(self), (self.bottom(), self.top(), self.decimals()), None
                                                                                                                                                                                                        
                                                                                                                                                                                                            def __eq__(self, other: object):
                                                                                                                                                                                                                return (
                                                                                                                                                                                                                    (
                                                                                                                                                                                                                        self.bottom() == other.bottom()
                                                                                                                                                                                                                        and self.top() == other.top()
                                                                                                                                                                                                                        and self.decimals() == other.decimals()
                                                                                                                                                                                                                    )
                                                                                                                                                                                                                    if isinstance(other, type(self))
                                                                                                                                                                                                                    else False
                                                                                                                                                                                                                )
                                                                                                                                                                                                        
                                                                                                                                                                                                            def set_range(
                                                                                                                                                                                                                self, start: float | None, end: float | None, decimals: int | None = None
                                                                                                                                                                                                            ):
                                                                                                                                                                                                                if decimals is None:
                                                                                                                                                                                                                    decimals = -1
                                                                                                                                                                                                                if start is None:
                                                                                                                                                                                                                    start = -float("inf")
                                                                                                                                                                                                                if end is None:
                                                                                                                                                                                                                    end = float("inf")
                                                                                                                                                                                                                self.setRange(start, end, decimals)
                                                                                                                                                                                                        

                                                                                                                                                                                                        Drag

                                                                                                                                                                                                        Bases: ObjectMixin, QDrag

                                                                                                                                                                                                        Support for MIME-based drag and drop data transfer.

                                                                                                                                                                                                        Source code in prettyqt/gui/drag.py
                                                                                                                                                                                                        class Drag(core.ObjectMixin, gui.QDrag):
                                                                                                                                                                                                            """Support for MIME-based drag and drop data transfer."""
                                                                                                                                                                                                        
                                                                                                                                                                                                            def get_pixmap(self) -> gui.Pixmap:
                                                                                                                                                                                                                return gui.Pixmap(self.pixmap())
                                                                                                                                                                                                        
                                                                                                                                                                                                            def get_default_action(self) -> constants.DropActionStr:
                                                                                                                                                                                                                return constants.DROP_ACTION.inverse[self.defaultAction()]
                                                                                                                                                                                                        
                                                                                                                                                                                                            def get_drag_cursor(
                                                                                                                                                                                                                self, action: constants.DropActionStr | constants.DropAction
                                                                                                                                                                                                            ) -> gui.Pixmap:
                                                                                                                                                                                                                px = self.dragCursor(constants.DROP_ACTION.get_enum_value(action))
                                                                                                                                                                                                                return gui.Pixmap(px)
                                                                                                                                                                                                        
                                                                                                                                                                                                            def set_drag_cursor(
                                                                                                                                                                                                                self,
                                                                                                                                                                                                                cursor: gui.QPixmap,
                                                                                                                                                                                                                action: constants.DropActionStr | constants.DropAction,
                                                                                                                                                                                                            ):
                                                                                                                                                                                                                self.setDragCursor(cursor, constants.DROP_ACTION.get_enum_value(action))
                                                                                                                                                                                                        
                                                                                                                                                                                                            def get_supported_actions(self) -> list[constants.DropActionStr]:
                                                                                                                                                                                                                return constants.DROP_ACTION.get_list(self.supportedActions())
                                                                                                                                                                                                        
                                                                                                                                                                                                            def main_loop(
                                                                                                                                                                                                                self,
                                                                                                                                                                                                                supported_actions: Iterable[constants.DropActionStr | constants.DropAction]
                                                                                                                                                                                                                | None = None,
                                                                                                                                                                                                                default_drop_action: constants.DropActionStr | constants.DropAction | None = None,
                                                                                                                                                                                                            ) -> constants.DropActionStr:
                                                                                                                                                                                                                supported_actions = supported_actions or [constants.DROP_ACTION["move"]]
                                                                                                                                                                                                                flag = constants.DropAction(0)
                                                                                                                                                                                                                for i in supported_actions:
                                                                                                                                                                                                                    flag |= constants.DROP_ACTION.get_enum_value(i)
                                                                                                                                                                                                                default_action = (
                                                                                                                                                                                                                    constants.DropAction.IgnoreAction
                                                                                                                                                                                                                    if default_drop_action is None
                                                                                                                                                                                                                    else constants.DROP_ACTION.get_enum_value(default_drop_action)
                                                                                                                                                                                                                )
                                                                                                                                                                                                                result = super().exec(flag, default_action)
                                                                                                                                                                                                                return constants.DROP_ACTION.inverse[result]
                                                                                                                                                                                                        

                                                                                                                                                                                                        Font

                                                                                                                                                                                                        Bases: QFont

                                                                                                                                                                                                        Specifies a query for a font used for drawing text.

                                                                                                                                                                                                        Source code in prettyqt/gui/font.py
                                                                                                                                                                                                        class Font(gui.QFont):
                                                                                                                                                                                                            """Specifies a query for a font used for drawing text."""
                                                                                                                                                                                                        
                                                                                                                                                                                                            def __repr__(self):
                                                                                                                                                                                                                return get_repr(
                                                                                                                                                                                                                    self, self.family(), self.pointSize(), self.weight(), self.italic()
                                                                                                                                                                                                                )
                                                                                                                                                                                                        
                                                                                                                                                                                                            def __getstate__(self):
                                                                                                                                                                                                                return dict(
                                                                                                                                                                                                                    family=self.family(),
                                                                                                                                                                                                                    pointsize=self.pointSize(),
                                                                                                                                                                                                                    weight=self.weight(),
                                                                                                                                                                                                                    italic=self.italic(),
                                                                                                                                                                                                                )
                                                                                                                                                                                                        
                                                                                                                                                                                                            def __setstate__(self, state):
                                                                                                                                                                                                                self.setFamily(state["family"])
                                                                                                                                                                                                                if state["pointsize"] > -1:
                                                                                                                                                                                                                    self.setPointSize(state["pointsize"])
                                                                                                                                                                                                                self.setWeight(state["weight"])
                                                                                                                                                                                                                self.setItalic(state["italic"])
                                                                                                                                                                                                        
                                                                                                                                                                                                            @property
                                                                                                                                                                                                            def _family(self) -> str:
                                                                                                                                                                                                                return self.family()
                                                                                                                                                                                                        
                                                                                                                                                                                                            __match_args__ = ("_family",)
                                                                                                                                                                                                        
                                                                                                                                                                                                            def __reduce__(self):
                                                                                                                                                                                                                return type(self), (), self.__getstate__()
                                                                                                                                                                                                        
                                                                                                                                                                                                            def serialize(self) -> dict[str, Any]:
                                                                                                                                                                                                                return self.__getstate__()
                                                                                                                                                                                                        
                                                                                                                                                                                                            @property
                                                                                                                                                                                                            def metrics(self) -> gui.FontMetrics:
                                                                                                                                                                                                                return gui.FontMetrics(self)
                                                                                                                                                                                                        
                                                                                                                                                                                                            def set_size(self, size: int):
                                                                                                                                                                                                                self.setPointSize(size)
                                                                                                                                                                                                        
                                                                                                                                                                                                            @classmethod
                                                                                                                                                                                                            def mono(cls, size=8, as_qt: bool = False) -> Self | gui.QFont:
                                                                                                                                                                                                                match sys.platform:
                                                                                                                                                                                                                    case "win32":
                                                                                                                                                                                                                        font = "Consolas"
                                                                                                                                                                                                                    case "darwin":
                                                                                                                                                                                                                        font = "Menlo"
                                                                                                                                                                                                                    case _:
                                                                                                                                                                                                                        font = "Monospace"
                                                                                                                                                                                                                if as_qt:
                                                                                                                                                                                                                    return gui.QFont(font, size)
                                                                                                                                                                                                                return cls(font, size)
                                                                                                                                                                                                                # font.setStyleHint()
                                                                                                                                                                                                        
                                                                                                                                                                                                            def scaled(self, factor: float) -> Self:
                                                                                                                                                                                                                scaled = type(self)(self)
                                                                                                                                                                                                                if self.pointSizeF() != -1:
                                                                                                                                                                                                                    scaled.setPointSizeF(self.pointSizeF() * factor)
                                                                                                                                                                                                                elif self.pixelSize() != -1:
                                                                                                                                                                                                                    scaled.setPixelSize(int(self.pixelSize() * factor))
                                                                                                                                                                                                                return scaled
                                                                                                                                                                                                        
                                                                                                                                                                                                            def set_style_hint(self, hint: StyleHintStr | gui.QFont.StyleHint):
                                                                                                                                                                                                                """Set the style hint.
                                                                                                                                                                                                        
                                                                                                                                                                                                                Args:
                                                                                                                                                                                                                    hint: style hint
                                                                                                                                                                                                                """
                                                                                                                                                                                                                self.setStyleHint(STYLE_HINTS.get_enum_value(hint))
                                                                                                                                                                                                        
                                                                                                                                                                                                            def set_weight(self, weight: WeightStr | gui.QFont.Weight):
                                                                                                                                                                                                                """Set the font weight.
                                                                                                                                                                                                        
                                                                                                                                                                                                                Args:
                                                                                                                                                                                                                    weight: font weight
                                                                                                                                                                                                                """
                                                                                                                                                                                                                self.setWeight(WEIGHT.get_enum_value(weight))
                                                                                                                                                                                                        
                                                                                                                                                                                                            def get_weight(self) -> WeightStr:
                                                                                                                                                                                                                """Get current font weight.
                                                                                                                                                                                                        
                                                                                                                                                                                                                Returns:
                                                                                                                                                                                                                    current font weight
                                                                                                                                                                                                                """
                                                                                                                                                                                                                return WEIGHT.inverse[self.weight()]
                                                                                                                                                                                                        
                                                                                                                                                                                                            def set_capitalization(
                                                                                                                                                                                                                self, capitalization: CapitalizationStr | gui.Font.Capitalization
                                                                                                                                                                                                            ):
                                                                                                                                                                                                                """Set the font capitalization.
                                                                                                                                                                                                        
                                                                                                                                                                                                                Args:
                                                                                                                                                                                                                    capitalization: font capitalization
                                                                                                                                                                                                                """
                                                                                                                                                                                                                self.setCapitalization(CAPITALIZATION.get_enum_value(capitalization))
                                                                                                                                                                                                        
                                                                                                                                                                                                            def get_capitalization(self) -> CapitalizationStr:
                                                                                                                                                                                                                """Get current font capitalization.
                                                                                                                                                                                                        
                                                                                                                                                                                                                Returns:
                                                                                                                                                                                                                    current font capitalization
                                                                                                                                                                                                                """
                                                                                                                                                                                                                return CAPITALIZATION.inverse[self.capitalization()]
                                                                                                                                                                                                        
                                                                                                                                                                                                            def set_hinting_preference(
                                                                                                                                                                                                                self, preference: HintingPreferenceStr | gui.Font.HintingPreference
                                                                                                                                                                                                            ):
                                                                                                                                                                                                                """Set the hinting preference.
                                                                                                                                                                                                        
                                                                                                                                                                                                                Args:
                                                                                                                                                                                                                    preference: hinting preference
                                                                                                                                                                                                                """
                                                                                                                                                                                                                self.setHintingPreference(HINTING_PREFERENCE.get_enum_value(preference))
                                                                                                                                                                                                        
                                                                                                                                                                                                            def get_hinting_preference(self) -> HintingPreferenceStr:
                                                                                                                                                                                                                """Get current hinting preference.
                                                                                                                                                                                                        
                                                                                                                                                                                                                Returns:
                                                                                                                                                                                                                    current hinting preference
                                                                                                                                                                                                                """
                                                                                                                                                                                                                return HINTING_PREFERENCE.inverse[self.hintingPreference()]
                                                                                                                                                                                                        
                                                                                                                                                                                                            def set_letter_spacing(
                                                                                                                                                                                                                self, typ: SpacingTypeStr | gui.Font.SpacingType, spacing: float
                                                                                                                                                                                                            ):
                                                                                                                                                                                                                """Set the letter spacing.
                                                                                                                                                                                                        
                                                                                                                                                                                                                Args:
                                                                                                                                                                                                                    typ: letter spacing type
                                                                                                                                                                                                                    spacing: spacing
                                                                                                                                                                                                                """
                                                                                                                                                                                                                self.setLetterSpacing(SPACING_TYPE.get_enum_value(typ), spacing)
                                                                                                                                                                                                        
                                                                                                                                                                                                            def get_letter_spacing_type(self) -> SpacingTypeStr:
                                                                                                                                                                                                                """Get current letter spacing type.
                                                                                                                                                                                                        
                                                                                                                                                                                                                Returns:
                                                                                                                                                                                                                    current letter spacing type
                                                                                                                                                                                                                """
                                                                                                                                                                                                                return SPACING_TYPE.inverse[self.letterSpacingType()]
                                                                                                                                                                                                        
                                                                                                                                                                                                            def set_style(self, style: StyleStr | gui.Font.Style):
                                                                                                                                                                                                                """Set the font style.
                                                                                                                                                                                                        
                                                                                                                                                                                                                Args:
                                                                                                                                                                                                                    style: font style
                                                                                                                                                                                                                """
                                                                                                                                                                                                                self.setStyle(STYLE.get_enum_value(style))
                                                                                                                                                                                                        
                                                                                                                                                                                                            def get_style(self) -> StyleStr:
                                                                                                                                                                                                                """Get current font style.
                                                                                                                                                                                                        
                                                                                                                                                                                                                Returns:
                                                                                                                                                                                                                    current font style
                                                                                                                                                                                                                """
                                                                                                                                                                                                                return STYLE.inverse[self.style()]
                                                                                                                                                                                                        
                                                                                                                                                                                                            def set_family(self, family: str, fallback: str | None = None):
                                                                                                                                                                                                                """Set the font family.
                                                                                                                                                                                                        
                                                                                                                                                                                                                Args:
                                                                                                                                                                                                                    family: font family
                                                                                                                                                                                                                    fallback: fallback font family
                                                                                                                                                                                                                """
                                                                                                                                                                                                                self.setFamily(family)
                                                                                                                                                                                                                font_info = gui.FontInfo(self)
                                                                                                                                                                                                                if fallback is not None and font_info.family() != family:
                                                                                                                                                                                                                    self.setFamily(fallback)
                                                                                                                                                                                                        

                                                                                                                                                                                                        get_capitalization() -> CapitalizationStr

                                                                                                                                                                                                        Get current font capitalization.

                                                                                                                                                                                                        Source code in prettyqt/gui/font.py
                                                                                                                                                                                                        def get_capitalization(self) -> CapitalizationStr:
                                                                                                                                                                                                            """Get current font capitalization.
                                                                                                                                                                                                        
                                                                                                                                                                                                            Returns:
                                                                                                                                                                                                                current font capitalization
                                                                                                                                                                                                            """
                                                                                                                                                                                                            return CAPITALIZATION.inverse[self.capitalization()]
                                                                                                                                                                                                        

                                                                                                                                                                                                        get_hinting_preference() -> HintingPreferenceStr

                                                                                                                                                                                                        Get current hinting preference.

                                                                                                                                                                                                        Source code in prettyqt/gui/font.py
                                                                                                                                                                                                        def get_hinting_preference(self) -> HintingPreferenceStr:
                                                                                                                                                                                                            """Get current hinting preference.
                                                                                                                                                                                                        
                                                                                                                                                                                                            Returns:
                                                                                                                                                                                                                current hinting preference
                                                                                                                                                                                                            """
                                                                                                                                                                                                            return HINTING_PREFERENCE.inverse[self.hintingPreference()]
                                                                                                                                                                                                        

                                                                                                                                                                                                        get_letter_spacing_type() -> SpacingTypeStr

                                                                                                                                                                                                        Get current letter spacing type.

                                                                                                                                                                                                        Source code in prettyqt/gui/font.py
                                                                                                                                                                                                        def get_letter_spacing_type(self) -> SpacingTypeStr:
                                                                                                                                                                                                            """Get current letter spacing type.
                                                                                                                                                                                                        
                                                                                                                                                                                                            Returns:
                                                                                                                                                                                                                current letter spacing type
                                                                                                                                                                                                            """
                                                                                                                                                                                                            return SPACING_TYPE.inverse[self.letterSpacingType()]
                                                                                                                                                                                                        

                                                                                                                                                                                                        get_style() -> StyleStr

                                                                                                                                                                                                        Get current font style.

                                                                                                                                                                                                        Source code in prettyqt/gui/font.py
                                                                                                                                                                                                        def get_style(self) -> StyleStr:
                                                                                                                                                                                                            """Get current font style.
                                                                                                                                                                                                        
                                                                                                                                                                                                            Returns:
                                                                                                                                                                                                                current font style
                                                                                                                                                                                                            """
                                                                                                                                                                                                            return STYLE.inverse[self.style()]
                                                                                                                                                                                                        

                                                                                                                                                                                                        get_weight() -> WeightStr

                                                                                                                                                                                                        Get current font weight.

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

                                                                                                                                                                                                        set_capitalization(capitalization: CapitalizationStr | gui.Font.Capitalization)

                                                                                                                                                                                                        Set the font capitalization.

                                                                                                                                                                                                        Parameters:

                                                                                                                                                                                                        Name Type Description Default
                                                                                                                                                                                                        capitalization CapitalizationStr | Capitalization

                                                                                                                                                                                                        font capitalization

                                                                                                                                                                                                        required
                                                                                                                                                                                                        Source code in prettyqt/gui/font.py
                                                                                                                                                                                                        def set_capitalization(
                                                                                                                                                                                                            self, capitalization: CapitalizationStr | gui.Font.Capitalization
                                                                                                                                                                                                        ):
                                                                                                                                                                                                            """Set the font capitalization.
                                                                                                                                                                                                        
                                                                                                                                                                                                            Args:
                                                                                                                                                                                                                capitalization: font capitalization
                                                                                                                                                                                                            """
                                                                                                                                                                                                            self.setCapitalization(CAPITALIZATION.get_enum_value(capitalization))
                                                                                                                                                                                                        

                                                                                                                                                                                                        set_family(family: str, fallback: str | None = None)

                                                                                                                                                                                                        Set the font family.

                                                                                                                                                                                                        Parameters:

                                                                                                                                                                                                        Name Type Description Default
                                                                                                                                                                                                        family str

                                                                                                                                                                                                        font family

                                                                                                                                                                                                        required
                                                                                                                                                                                                        fallback str | None

                                                                                                                                                                                                        fallback font family

                                                                                                                                                                                                        None
                                                                                                                                                                                                        Source code in prettyqt/gui/font.py
                                                                                                                                                                                                        def set_family(self, family: str, fallback: str | None = None):
                                                                                                                                                                                                            """Set the font family.
                                                                                                                                                                                                        
                                                                                                                                                                                                            Args:
                                                                                                                                                                                                                family: font family
                                                                                                                                                                                                                fallback: fallback font family
                                                                                                                                                                                                            """
                                                                                                                                                                                                            self.setFamily(family)
                                                                                                                                                                                                            font_info = gui.FontInfo(self)
                                                                                                                                                                                                            if fallback is not None and font_info.family() != family:
                                                                                                                                                                                                                self.setFamily(fallback)
                                                                                                                                                                                                        

                                                                                                                                                                                                        set_hinting_preference(preference: HintingPreferenceStr | gui.Font.HintingPreference)

                                                                                                                                                                                                        Set the hinting preference.

                                                                                                                                                                                                        Parameters:

                                                                                                                                                                                                        Name Type Description Default
                                                                                                                                                                                                        preference HintingPreferenceStr | HintingPreference

                                                                                                                                                                                                        hinting preference

                                                                                                                                                                                                        required
                                                                                                                                                                                                        Source code in prettyqt/gui/font.py
                                                                                                                                                                                                        def set_hinting_preference(
                                                                                                                                                                                                            self, preference: HintingPreferenceStr | gui.Font.HintingPreference
                                                                                                                                                                                                        ):
                                                                                                                                                                                                            """Set the hinting preference.
                                                                                                                                                                                                        
                                                                                                                                                                                                            Args:
                                                                                                                                                                                                                preference: hinting preference
                                                                                                                                                                                                            """
                                                                                                                                                                                                            self.setHintingPreference(HINTING_PREFERENCE.get_enum_value(preference))
                                                                                                                                                                                                        

                                                                                                                                                                                                        set_letter_spacing(typ: SpacingTypeStr | gui.Font.SpacingType, spacing: float)

                                                                                                                                                                                                        Set the letter spacing.

                                                                                                                                                                                                        Parameters:

                                                                                                                                                                                                        Name Type Description Default
                                                                                                                                                                                                        typ SpacingTypeStr | SpacingType

                                                                                                                                                                                                        letter spacing type

                                                                                                                                                                                                        required
                                                                                                                                                                                                        spacing float

                                                                                                                                                                                                        spacing

                                                                                                                                                                                                        required
                                                                                                                                                                                                        Source code in prettyqt/gui/font.py
                                                                                                                                                                                                        def set_letter_spacing(
                                                                                                                                                                                                            self, typ: SpacingTypeStr | gui.Font.SpacingType, spacing: float
                                                                                                                                                                                                        ):
                                                                                                                                                                                                            """Set the letter spacing.
                                                                                                                                                                                                        
                                                                                                                                                                                                            Args:
                                                                                                                                                                                                                typ: letter spacing type
                                                                                                                                                                                                                spacing: spacing
                                                                                                                                                                                                            """
                                                                                                                                                                                                            self.setLetterSpacing(SPACING_TYPE.get_enum_value(typ), spacing)
                                                                                                                                                                                                        

                                                                                                                                                                                                        set_style(style: StyleStr | gui.Font.Style)

                                                                                                                                                                                                        Set the font style.

                                                                                                                                                                                                        Parameters:

                                                                                                                                                                                                        Name Type Description Default
                                                                                                                                                                                                        style StyleStr | Style

                                                                                                                                                                                                        font style

                                                                                                                                                                                                        required
                                                                                                                                                                                                        Source code in prettyqt/gui/font.py
                                                                                                                                                                                                        def set_style(self, style: StyleStr | gui.Font.Style):
                                                                                                                                                                                                            """Set the font style.
                                                                                                                                                                                                        
                                                                                                                                                                                                            Args:
                                                                                                                                                                                                                style: font style
                                                                                                                                                                                                            """
                                                                                                                                                                                                            self.setStyle(STYLE.get_enum_value(style))
                                                                                                                                                                                                        

                                                                                                                                                                                                        set_style_hint(hint: StyleHintStr | gui.QFont.StyleHint)

                                                                                                                                                                                                        Set the style hint.

                                                                                                                                                                                                        Parameters:

                                                                                                                                                                                                        Name Type Description Default
                                                                                                                                                                                                        hint StyleHintStr | StyleHint

                                                                                                                                                                                                        style hint

                                                                                                                                                                                                        required
                                                                                                                                                                                                        Source code in prettyqt/gui/font.py
                                                                                                                                                                                                        def set_style_hint(self, hint: StyleHintStr | gui.QFont.StyleHint):
                                                                                                                                                                                                            """Set the style hint.
                                                                                                                                                                                                        
                                                                                                                                                                                                            Args:
                                                                                                                                                                                                                hint: style hint
                                                                                                                                                                                                            """
                                                                                                                                                                                                            self.setStyleHint(STYLE_HINTS.get_enum_value(hint))
                                                                                                                                                                                                        

                                                                                                                                                                                                        set_weight(weight: WeightStr | gui.QFont.Weight)

                                                                                                                                                                                                        Set the font weight.

                                                                                                                                                                                                        Parameters:

                                                                                                                                                                                                        Name Type Description Default
                                                                                                                                                                                                        weight WeightStr | Weight

                                                                                                                                                                                                        font weight

                                                                                                                                                                                                        required
                                                                                                                                                                                                        Source code in prettyqt/gui/font.py
                                                                                                                                                                                                        def set_weight(self, weight: WeightStr | gui.QFont.Weight):
                                                                                                                                                                                                            """Set the font weight.
                                                                                                                                                                                                        
                                                                                                                                                                                                            Args:
                                                                                                                                                                                                                weight: font weight
                                                                                                                                                                                                            """
                                                                                                                                                                                                            self.setWeight(WEIGHT.get_enum_value(weight))
                                                                                                                                                                                                        

                                                                                                                                                                                                        FontDatabase

                                                                                                                                                                                                        Bases: QFontDatabase

                                                                                                                                                                                                        Information about the fonts available in the underlying window system.

                                                                                                                                                                                                        Source code in prettyqt/gui/fontdatabase.py
                                                                                                                                                                                                        class FontDatabase(QtGui.QFontDatabase):
                                                                                                                                                                                                            """Information about the fonts available in the underlying window system."""
                                                                                                                                                                                                        
                                                                                                                                                                                                            font_paths: ClassVar[dict[str, int]] = {}
                                                                                                                                                                                                        
                                                                                                                                                                                                            @classmethod
                                                                                                                                                                                                            def add_fonts_from_folder(cls, path: datatypes.PathType):
                                                                                                                                                                                                                path = pathlib.Path(path)
                                                                                                                                                                                                                for p in path.iterdir():
                                                                                                                                                                                                                    if p.suffix.lower() in [".ttf", ".otf"]:
                                                                                                                                                                                                                        logger.debug("adding font %r to database.", p)
                                                                                                                                                                                                                        cls.addApplicationFont(str(p))
                                                                                                                                                                                                        
                                                                                                                                                                                                            @classmethod
                                                                                                                                                                                                            def add_font(cls, path: datatypes.PathType, ttf_hash: str | None = None) -> int:
                                                                                                                                                                                                                path = pathlib.Path(path)
                                                                                                                                                                                                                font_id = cls.addApplicationFont(str(path))
                                                                                                                                                                                                                if not cls.applicationFontFamilies(font_id):
                                                                                                                                                                                                                    msg = (
                                                                                                                                                                                                                        f"Font {path!r} appears to be empty. "
                                                                                                                                                                                                                        "If you are on Windows 10, please read "
                                                                                                                                                                                                                        "https://support.microsoft.com/"
                                                                                                                                                                                                                        "en-us/kb/3053676"
                                                                                                                                                                                                                    )
                                                                                                                                                                                                                    raise RuntimeError(msg)
                                                                                                                                                                                                                if ttf_hash is not None:
                                                                                                                                                                                                                    content = path.read_bytes()
                                                                                                                                                                                                                    if hashlib.md5(content).hexdigest() != ttf_hash:
                                                                                                                                                                                                                        msg = f"Font is corrupt at: {path!r}"
                                                                                                                                                                                                                        raise OSError(msg)
                                                                                                                                                                                                                cls.font_paths[str(path)] = font_id
                                                                                                                                                                                                                return font_id
                                                                                                                                                                                                        
                                                                                                                                                                                                            @classmethod
                                                                                                                                                                                                            def remove_font(cls, font: datatypes.PathType | int):
                                                                                                                                                                                                                font_id = font if isinstance(font, int) else cls.font_paths[str(font)]
                                                                                                                                                                                                                cls.removeApplicationFont(font_id)
                                                                                                                                                                                                        
                                                                                                                                                                                                            @classmethod
                                                                                                                                                                                                            def get_system_font(
                                                                                                                                                                                                                cls, font_type: SystemFontStr | QtGui.QFontDatabase.SystemFont
                                                                                                                                                                                                            ) -> gui.Font:
                                                                                                                                                                                                                return gui.Font(cls.systemFont(SYSTEM_FONT.get_enum_value(font_type)))
                                                                                                                                                                                                        

                                                                                                                                                                                                        FontInfo

                                                                                                                                                                                                        Bases: QFontInfo

                                                                                                                                                                                                        General information about fonts.

                                                                                                                                                                                                        Source code in prettyqt/gui/fontinfo.py
                                                                                                                                                                                                        4
                                                                                                                                                                                                        5
                                                                                                                                                                                                        6
                                                                                                                                                                                                        7
                                                                                                                                                                                                        8
                                                                                                                                                                                                        class FontInfo(gui.QFontInfo):
                                                                                                                                                                                                            """General information about fonts."""
                                                                                                                                                                                                        
                                                                                                                                                                                                            def get_style_hint(self) -> gui.font.StyleHintStr:
                                                                                                                                                                                                                return gui.font.STYLE_HINTS.inverse[self.styleHint()]
                                                                                                                                                                                                        

                                                                                                                                                                                                        FontMetrics

                                                                                                                                                                                                        Bases: QFontMetrics

                                                                                                                                                                                                        Font metrics information.

                                                                                                                                                                                                        Source code in prettyqt/gui/fontmetrics.py
                                                                                                                                                                                                        class FontMetrics(QtGui.QFontMetrics):
                                                                                                                                                                                                            """Font metrics information."""
                                                                                                                                                                                                        
                                                                                                                                                                                                            def elided_text(
                                                                                                                                                                                                                self,
                                                                                                                                                                                                                text: str,
                                                                                                                                                                                                                mode: constants.TextElideModeStr | constants.TextElideMode,
                                                                                                                                                                                                                width: int,
                                                                                                                                                                                                                flags=0,
                                                                                                                                                                                                            ) -> str:
                                                                                                                                                                                                                val = constants.TEXT_ELIDE_MODE.get_enum_value(mode)
                                                                                                                                                                                                                return self.elidedText(text, val, width, flags)
                                                                                                                                                                                                        
                                                                                                                                                                                                            def get_bounding_rect(self, *args) -> core.Rect:
                                                                                                                                                                                                                return core.Rect(self.boundingRect(*args))
                                                                                                                                                                                                        
                                                                                                                                                                                                            def get_tight_bounding_rect(self, text: str) -> core.Rect:
                                                                                                                                                                                                                return core.Rect(self.tightBoundingRect(text))
                                                                                                                                                                                                        

                                                                                                                                                                                                        FontMetricsF

                                                                                                                                                                                                        Bases: QFontMetricsF

                                                                                                                                                                                                        Font metrics information.

                                                                                                                                                                                                        Source code in prettyqt/gui/fontmetricsf.py
                                                                                                                                                                                                        class FontMetricsF(QtGui.QFontMetricsF):
                                                                                                                                                                                                            """Font metrics information."""
                                                                                                                                                                                                        
                                                                                                                                                                                                            def elided_text(
                                                                                                                                                                                                                self,
                                                                                                                                                                                                                text: str,
                                                                                                                                                                                                                mode: constants.TextElideModeStr | constants.TextElideMode,
                                                                                                                                                                                                                width: float,
                                                                                                                                                                                                                flags=0,
                                                                                                                                                                                                            ) -> str:
                                                                                                                                                                                                                val = constants.TEXT_ELIDE_MODE.get_enum_value(mode)
                                                                                                                                                                                                                return self.elidedText(text, val, width, flags)
                                                                                                                                                                                                        
                                                                                                                                                                                                            def get_bounding_rect(self, *args) -> core.RectF:
                                                                                                                                                                                                                return core.RectF(self.boundingRect(*args))
                                                                                                                                                                                                        
                                                                                                                                                                                                            def get_tight_bounding_rect(self, text: str) -> core.RectF:
                                                                                                                                                                                                                return core.RectF(self.tightBoundingRect(text))
                                                                                                                                                                                                        

                                                                                                                                                                                                        FontVariableAxis

                                                                                                                                                                                                        Bases: QFontVariableAxis

                                                                                                                                                                                                        Represents a variable axis in a font.

                                                                                                                                                                                                        Source code in prettyqt/gui/fontvariableaxis.py
                                                                                                                                                                                                        class FontVariableAxis(QtGui.QFontVariableAxis):
                                                                                                                                                                                                            """Represents a variable axis in a font."""
                                                                                                                                                                                                        
                                                                                                                                                                                                            def __repr__(self):
                                                                                                                                                                                                                return get_repr(
                                                                                                                                                                                                                    self,
                                                                                                                                                                                                                    self.name(),
                                                                                                                                                                                                                    self.minimumValue(),
                                                                                                                                                                                                                    self.maximumValue(),
                                                                                                                                                                                                                    self.defaultValue(),
                                                                                                                                                                                                                )
                                                                                                                                                                                                        
                                                                                                                                                                                                            def get_tag(self) -> str:
                                                                                                                                                                                                                """Return the axis tag as a 4-character string."""
                                                                                                                                                                                                                return bytes(self.tag().toString().data()).decode()
                                                                                                                                                                                                        
                                                                                                                                                                                                            def set_tag(self, tag: str | QtGui.QFont.Tag):
                                                                                                                                                                                                                """Set the axis tag from a string or QFont.Tag."""
                                                                                                                                                                                                                if isinstance(tag, str):
                                                                                                                                                                                                                    parsed = QtGui.QFont.Tag.fromString(tag)
                                                                                                                                                                                                                    if parsed is None:
                                                                                                                                                                                                                        raise ValueError(tag)
                                                                                                                                                                                                                    tag = parsed
                                                                                                                                                                                                                self.setTag(tag)
                                                                                                                                                                                                        

                                                                                                                                                                                                        get_tag() -> str

                                                                                                                                                                                                        Return the axis tag as a 4-character string.

                                                                                                                                                                                                        Source code in prettyqt/gui/fontvariableaxis.py
                                                                                                                                                                                                        def get_tag(self) -> str:
                                                                                                                                                                                                            """Return the axis tag as a 4-character string."""
                                                                                                                                                                                                            return bytes(self.tag().toString().data()).decode()
                                                                                                                                                                                                        

                                                                                                                                                                                                        set_tag(tag: str | QtGui.QFont.Tag)

                                                                                                                                                                                                        Set the axis tag from a string or QFont.Tag.

                                                                                                                                                                                                        Source code in prettyqt/gui/fontvariableaxis.py
                                                                                                                                                                                                        def set_tag(self, tag: str | QtGui.QFont.Tag):
                                                                                                                                                                                                            """Set the axis tag from a string or QFont.Tag."""
                                                                                                                                                                                                            if isinstance(tag, str):
                                                                                                                                                                                                                parsed = QtGui.QFont.Tag.fromString(tag)
                                                                                                                                                                                                                if parsed is None:
                                                                                                                                                                                                                    raise ValueError(tag)
                                                                                                                                                                                                                tag = parsed
                                                                                                                                                                                                            self.setTag(tag)
                                                                                                                                                                                                        

                                                                                                                                                                                                        Gradient

                                                                                                                                                                                                        Bases: GradientMixin, QGradient

                                                                                                                                                                                                        Used in combination with QBrush to specify gradient fills.

                                                                                                                                                                                                        Source code in prettyqt/gui/gradient.py
                                                                                                                                                                                                        class Gradient(GradientMixin, gui.QGradient):
                                                                                                                                                                                                            """Used in combination with QBrush to specify gradient fills."""
                                                                                                                                                                                                        

                                                                                                                                                                                                        GradientMixin

                                                                                                                                                                                                        Bases: _GradientBase

                                                                                                                                                                                                        Source code in prettyqt/gui/gradient.py
                                                                                                                                                                                                        class GradientMixin(_GradientBase):
                                                                                                                                                                                                            def __setitem__(self, key: float, value: datatypes.ColorType):
                                                                                                                                                                                                                self.set_color_at(key, value)
                                                                                                                                                                                                        
                                                                                                                                                                                                            def serialize(self) -> dict[str, Any]:
                                                                                                                                                                                                                return dict(
                                                                                                                                                                                                                    coordinate_mode=self.get_coordinate_mode(),
                                                                                                                                                                                                                    spread=self.get_spread(),
                                                                                                                                                                                                                    stops=self.get_stops(),
                                                                                                                                                                                                                )
                                                                                                                                                                                                        
                                                                                                                                                                                                            def set_color_at(self, key: float, color: datatypes.ColorType):
                                                                                                                                                                                                                super().setColorAt(key, colors.get_color(color))
                                                                                                                                                                                                        
                                                                                                                                                                                                            def set_coordinate_mode(self, mode: CoordinateModeStr | gui.QGradient.CoordinateMode):
                                                                                                                                                                                                                """Set the coordinate mode.
                                                                                                                                                                                                        
                                                                                                                                                                                                                Args:
                                                                                                                                                                                                                    mode: coordinate mode
                                                                                                                                                                                                                """
                                                                                                                                                                                                                self.setCoordinateMode(COORDINATE_MODE.get_enum_value(mode))
                                                                                                                                                                                                        
                                                                                                                                                                                                            def get_coordinate_mode(self) -> CoordinateModeStr:
                                                                                                                                                                                                                """Return current coordinate mode.
                                                                                                                                                                                                        
                                                                                                                                                                                                                Returns:
                                                                                                                                                                                                                    coordinate mode
                                                                                                                                                                                                                """
                                                                                                                                                                                                                return COORDINATE_MODE.inverse[self.coordinateMode()]
                                                                                                                                                                                                        
                                                                                                                                                                                                            def set_spread(self, method: SpreadStr | gui.QGradient.Spread):
                                                                                                                                                                                                                """Set the spread method.
                                                                                                                                                                                                        
                                                                                                                                                                                                                Args:
                                                                                                                                                                                                                    method: spread method
                                                                                                                                                                                                                """
                                                                                                                                                                                                                self.setSpread(SPREAD.get_enum_value(method))
                                                                                                                                                                                                        
                                                                                                                                                                                                            def get_spread(self) -> SpreadStr:
                                                                                                                                                                                                                """Return current spread method.
                                                                                                                                                                                                        
                                                                                                                                                                                                                Returns:
                                                                                                                                                                                                                    spread method
                                                                                                                                                                                                                """
                                                                                                                                                                                                                return SPREAD.inverse[self.spread()]
                                                                                                                                                                                                        
                                                                                                                                                                                                            def get_type(self) -> TypeStr:
                                                                                                                                                                                                                """Return current gradient type.
                                                                                                                                                                                                        
                                                                                                                                                                                                                Returns:
                                                                                                                                                                                                                    gradient type
                                                                                                                                                                                                                """
                                                                                                                                                                                                                return TYPE.inverse[self.type()]
                                                                                                                                                                                                        
                                                                                                                                                                                                            def get_stops(self) -> list[tuple[float, gui.Color]]:
                                                                                                                                                                                                                return [(i, gui.Color(j)) for (i, j) in self.stops()]
                                                                                                                                                                                                        
                                                                                                                                                                                                            @classmethod
                                                                                                                                                                                                            def for_palette(cls, palette: gui.Palette, group: gui.palette.GroupStr = "active"):
                                                                                                                                                                                                                gradient = cls()
                                                                                                                                                                                                                for i, role_name in enumerate(gui.palette.ROLE):
                                                                                                                                                                                                                    color = palette.get_color(role_name, group)
                                                                                                                                                                                                                    gradient.setColorAt(i / len(gui.palette.ROLE), color)
                                                                                                                                                                                                                return gradient
                                                                                                                                                                                                        
                                                                                                                                                                                                            def change_brightness(self, factor: float):
                                                                                                                                                                                                                # still need to streamline changing brightness across the framework...
                                                                                                                                                                                                                # color.lighter returns a lighter color when arg is > 100 (same for darker)
                                                                                                                                                                                                                factor = int(factor * 100)
                                                                                                                                                                                                                for pos, color in self.stops():
                                                                                                                                                                                                                    if factor > 0:
                                                                                                                                                                                                                        self.setColorAt(pos, color.lighter(factor))
                                                                                                                                                                                                                    else:
                                                                                                                                                                                                                        self.setColorAt(pos, color.darker(-factor))
                                                                                                                                                                                                        

                                                                                                                                                                                                        get_coordinate_mode() -> CoordinateModeStr

                                                                                                                                                                                                        Return current coordinate mode.

                                                                                                                                                                                                        Source code in prettyqt/gui/gradient.py
                                                                                                                                                                                                        def get_coordinate_mode(self) -> CoordinateModeStr:
                                                                                                                                                                                                            """Return current coordinate mode.
                                                                                                                                                                                                        
                                                                                                                                                                                                            Returns:
                                                                                                                                                                                                                coordinate mode
                                                                                                                                                                                                            """
                                                                                                                                                                                                            return COORDINATE_MODE.inverse[self.coordinateMode()]
                                                                                                                                                                                                        

                                                                                                                                                                                                        get_spread() -> SpreadStr

                                                                                                                                                                                                        Return current spread method.

                                                                                                                                                                                                        Source code in prettyqt/gui/gradient.py
                                                                                                                                                                                                        def get_spread(self) -> SpreadStr:
                                                                                                                                                                                                            """Return current spread method.
                                                                                                                                                                                                        
                                                                                                                                                                                                            Returns:
                                                                                                                                                                                                                spread method
                                                                                                                                                                                                            """
                                                                                                                                                                                                            return SPREAD.inverse[self.spread()]
                                                                                                                                                                                                        

                                                                                                                                                                                                        get_type() -> TypeStr

                                                                                                                                                                                                        Return current gradient type.

                                                                                                                                                                                                        Source code in prettyqt/gui/gradient.py
                                                                                                                                                                                                        def get_type(self) -> TypeStr:
                                                                                                                                                                                                            """Return current gradient type.
                                                                                                                                                                                                        
                                                                                                                                                                                                            Returns:
                                                                                                                                                                                                                gradient type
                                                                                                                                                                                                            """
                                                                                                                                                                                                            return TYPE.inverse[self.type()]
                                                                                                                                                                                                        

                                                                                                                                                                                                        set_coordinate_mode(mode: CoordinateModeStr | gui.QGradient.CoordinateMode)

                                                                                                                                                                                                        Set the coordinate mode.

                                                                                                                                                                                                        Parameters:

                                                                                                                                                                                                        Name Type Description Default
                                                                                                                                                                                                        mode CoordinateModeStr | CoordinateMode

                                                                                                                                                                                                        coordinate mode

                                                                                                                                                                                                        required
                                                                                                                                                                                                        Source code in prettyqt/gui/gradient.py
                                                                                                                                                                                                        def set_coordinate_mode(self, mode: CoordinateModeStr | gui.QGradient.CoordinateMode):
                                                                                                                                                                                                            """Set the coordinate mode.
                                                                                                                                                                                                        
                                                                                                                                                                                                            Args:
                                                                                                                                                                                                                mode: coordinate mode
                                                                                                                                                                                                            """
                                                                                                                                                                                                            self.setCoordinateMode(COORDINATE_MODE.get_enum_value(mode))
                                                                                                                                                                                                        

                                                                                                                                                                                                        set_spread(method: SpreadStr | gui.QGradient.Spread)

                                                                                                                                                                                                        Set the spread method.

                                                                                                                                                                                                        Parameters:

                                                                                                                                                                                                        Name Type Description Default
                                                                                                                                                                                                        method SpreadStr | Spread

                                                                                                                                                                                                        spread method

                                                                                                                                                                                                        required
                                                                                                                                                                                                        Source code in prettyqt/gui/gradient.py
                                                                                                                                                                                                        def set_spread(self, method: SpreadStr | gui.QGradient.Spread):
                                                                                                                                                                                                            """Set the spread method.
                                                                                                                                                                                                        
                                                                                                                                                                                                            Args:
                                                                                                                                                                                                                method: spread method
                                                                                                                                                                                                            """
                                                                                                                                                                                                            self.setSpread(SPREAD.get_enum_value(method))
                                                                                                                                                                                                        

                                                                                                                                                                                                        GuiApplication

                                                                                                                                                                                                        Bases: GuiApplicationMixin, QGuiApplication

                                                                                                                                                                                                        Manages the GUI application's control flow and main settings.

                                                                                                                                                                                                        Source code in prettyqt/gui/guiapplication.py
                                                                                                                                                                                                        class GuiApplication(GuiApplicationMixin, gui.QGuiApplication):
                                                                                                                                                                                                            """Manages the GUI application's control flow and main settings."""
                                                                                                                                                                                                        

                                                                                                                                                                                                        GuiApplicationMixin

                                                                                                                                                                                                        Bases: CoreApplicationMixin, _GuiApplicationBase

                                                                                                                                                                                                        Source code in prettyqt/gui/guiapplication.py
                                                                                                                                                                                                        class GuiApplicationMixin(core.CoreApplicationMixin, _GuiApplicationBase):
                                                                                                                                                                                                            palette_changed = core.Signal(gui.Palette)
                                                                                                                                                                                                        
                                                                                                                                                                                                            def __init__(self, *args, **kwargs):
                                                                                                                                                                                                                self._window_icon_color = DEFAULT_WINDOW_ICON_COLOR
                                                                                                                                                                                                                super().__init__(*args, **kwargs)
                                                                                                                                                                                                        
                                                                                                                                                                                                            def _get_map(self):
                                                                                                                                                                                                                maps = super()._get_map()
                                                                                                                                                                                                                maps |= {"layoutDirection": constants.LAYOUT_DIRECTION}
                                                                                                                                                                                                                return maps
                                                                                                                                                                                                        
                                                                                                                                                                                                            def event(self, e):
                                                                                                                                                                                                                match e.type():
                                                                                                                                                                                                                    case core.QEvent.Type.ApplicationPaletteChange:
                                                                                                                                                                                                                        self.palette_changed.emit(gui.Palette(self.palette()))
                                                                                                                                                                                                                return super().event(e)
                                                                                                                                                                                                        
                                                                                                                                                                                                            @classmethod
                                                                                                                                                                                                            @contextlib.contextmanager
                                                                                                                                                                                                            def override_cursor(cls, cursor: constants.CursorShapeStr | constants.CursorShape):
                                                                                                                                                                                                                cls.set_override_cursor(cursor)
                                                                                                                                                                                                                try:
                                                                                                                                                                                                                    yield cursor
                                                                                                                                                                                                                finally:
                                                                                                                                                                                                                    cls.restore_override_cursor()
                                                                                                                                                                                                        
                                                                                                                                                                                                            @classmethod
                                                                                                                                                                                                            def set_override_cursor(
                                                                                                                                                                                                                cls, cursor: constants.CursorShapeStr | constants.CursorShape
                                                                                                                                                                                                            ):
                                                                                                                                                                                                                crs = gui.Cursor(constants.CURSOR_SHAPE.get_enum_value(cursor))
                                                                                                                                                                                                                cls.setOverrideCursor(crs)
                                                                                                                                                                                                        
                                                                                                                                                                                                            @classmethod
                                                                                                                                                                                                            def restore_override_cursor(cls):
                                                                                                                                                                                                                cls.restoreOverrideCursor()
                                                                                                                                                                                                        
                                                                                                                                                                                                            @classmethod
                                                                                                                                                                                                            def get_clipboard(cls) -> gui.Clipboard:
                                                                                                                                                                                                                return gui.Clipboard(cls.clipboard())
                                                                                                                                                                                                        
                                                                                                                                                                                                            @classmethod
                                                                                                                                                                                                            @contextlib.contextmanager
                                                                                                                                                                                                            def edit_palette(cls) -> Generator[gui.Palette]:
                                                                                                                                                                                                                palette = gui.Palette(cls.palette())
                                                                                                                                                                                                                try:
                                                                                                                                                                                                                    yield palette
                                                                                                                                                                                                                finally:
                                                                                                                                                                                                                    cls.setPalette(palette)
                                                                                                                                                                                                        
                                                                                                                                                                                                            @classmethod
                                                                                                                                                                                                            def find_window(cls, h_wnd: SupportsInt) -> gui.QWindow | None:
                                                                                                                                                                                                                for window in cls.topLevelWindows():
                                                                                                                                                                                                                    if window and int(window.winId()) == int(h_wnd):
                                                                                                                                                                                                                        return window
                                                                                                                                                                                                                return None
                                                                                                                                                                                                        
                                                                                                                                                                                                            def set_layout_direction(
                                                                                                                                                                                                                self, direction: constants.LayoutDirectionStr | constants.LayoutDirection
                                                                                                                                                                                                            ):
                                                                                                                                                                                                                """Set layout direction.
                                                                                                                                                                                                        
                                                                                                                                                                                                                Args:
                                                                                                                                                                                                                    direction: layout direction
                                                                                                                                                                                                                """
                                                                                                                                                                                                                self.setLayoutDirection(constants.LAYOUT_DIRECTION.get_enum_value(direction))
                                                                                                                                                                                                        
                                                                                                                                                                                                            def get_layout_direction(self) -> constants.LayoutDirectionStr:
                                                                                                                                                                                                                """Get the current layout direction.
                                                                                                                                                                                                        
                                                                                                                                                                                                                Returns:
                                                                                                                                                                                                                    layout direction
                                                                                                                                                                                                                """
                                                                                                                                                                                                                return constants.LAYOUT_DIRECTION.inverse[self.layoutDirection()]
                                                                                                                                                                                                        
                                                                                                                                                                                                            @classmethod
                                                                                                                                                                                                            def set_high_dpi_scale_factor_rounding_policy(
                                                                                                                                                                                                                cls,
                                                                                                                                                                                                                policy: (
                                                                                                                                                                                                                    constants.HighDpiScaleFactorRoundingPolicyStr
                                                                                                                                                                                                                    | constants.HighDpiScaleFactorRoundingPolicy
                                                                                                                                                                                                                ),
                                                                                                                                                                                                            ):
                                                                                                                                                                                                                """Set high dpi scale factor rounding policy.
                                                                                                                                                                                                        
                                                                                                                                                                                                                Args:
                                                                                                                                                                                                                    policy: rounding policy
                                                                                                                                                                                                                """
                                                                                                                                                                                                                cls.setHighDpiScaleFactorRoundingPolicy(
                                                                                                                                                                                                                    constants.HIGH_DPI_SCALE_FACTOR_ROUNDING_POLICY.get_enum_value(policy)
                                                                                                                                                                                                                )
                                                                                                                                                                                                        
                                                                                                                                                                                                            @classmethod
                                                                                                                                                                                                            def get_high_dpi_scale_factor_rounding_policy(
                                                                                                                                                                                                                cls,
                                                                                                                                                                                                            ) -> constants.HighDpiScaleFactorRoundingPolicyStr:
                                                                                                                                                                                                                """Get the current high dpi scale factor rounding policy.
                                                                                                                                                                                                        
                                                                                                                                                                                                                Returns:
                                                                                                                                                                                                                    rounding policy
                                                                                                                                                                                                                """
                                                                                                                                                                                                                return constants.HIGH_DPI_SCALE_FACTOR_ROUNDING_POLICY.inverse[
                                                                                                                                                                                                                    cls.highDpiScaleFactorRoundingPolicy()
                                                                                                                                                                                                                ]
                                                                                                                                                                                                        
                                                                                                                                                                                                            @classmethod
                                                                                                                                                                                                            def get_application_state(cls) -> list[constants.ApplicationStateStr]:
                                                                                                                                                                                                                """Get the current application state.
                                                                                                                                                                                                        
                                                                                                                                                                                                                Returns:
                                                                                                                                                                                                                    application state
                                                                                                                                                                                                                """
                                                                                                                                                                                                                return [
                                                                                                                                                                                                                    k
                                                                                                                                                                                                                    for k, v in constants.APPLICATION_STATES.items()
                                                                                                                                                                                                                    if v & cls.applicationState()
                                                                                                                                                                                                                ]
                                                                                                                                                                                                        
                                                                                                                                                                                                            def get_primary_screen(self) -> gui.Screen:
                                                                                                                                                                                                                return gui.Screen(self.primaryScreen())
                                                                                                                                                                                                        
                                                                                                                                                                                                            def get_screen_at(self, point: datatypes.PointType) -> gui.Screen | None:
                                                                                                                                                                                                                p = datatypes.to_point(point)
                                                                                                                                                                                                                return gui.Screen(screen) if (screen := self.screenAt(p)) else None
                                                                                                                                                                                                        
                                                                                                                                                                                                            def get_screens(self) -> list[gui.Screen]:
                                                                                                                                                                                                                return [gui.Screen(i) for i in self.screens()]
                                                                                                                                                                                                        
                                                                                                                                                                                                            @classmethod
                                                                                                                                                                                                            def get_input_method(cls) -> gui.InputMethod:
                                                                                                                                                                                                                return gui.InputMethod(cls.inputMethod())
                                                                                                                                                                                                        
                                                                                                                                                                                                            @classmethod
                                                                                                                                                                                                            def get_style_hints(cls) -> gui.StyleHints:
                                                                                                                                                                                                                return gui.StyleHints(cls.styleHints())
                                                                                                                                                                                                        
                                                                                                                                                                                                            @classmethod
                                                                                                                                                                                                            def copy_to_clipboard(cls, text: str):
                                                                                                                                                                                                                """Sets clipboard to supplied text."""
                                                                                                                                                                                                                cb = cls.clipboard()
                                                                                                                                                                                                                cb.clear(mode=cb.Mode.Clipboard)
                                                                                                                                                                                                                cb.setText(text, mode=cb.Mode.Clipboard)
                                                                                                                                                                                                        
                                                                                                                                                                                                            @classmethod
                                                                                                                                                                                                            def get_font(cls) -> gui.Font:
                                                                                                                                                                                                                return gui.Font(cls.font())
                                                                                                                                                                                                        
                                                                                                                                                                                                            def set_icon(self, icon: datatypes.IconType):
                                                                                                                                                                                                                """Set the default window icon.
                                                                                                                                                                                                        
                                                                                                                                                                                                                Args:
                                                                                                                                                                                                                    icon: icon to use
                                                                                                                                                                                                                """
                                                                                                                                                                                                                color = self.get_window_icon_color()
                                                                                                                                                                                                                icon = iconprovider.get_icon(icon, color=color)
                                                                                                                                                                                                                self.setWindowIcon(icon)
                                                                                                                                                                                                        
                                                                                                                                                                                                            def get_icon(self) -> gui.Icon | None:
                                                                                                                                                                                                                icon = self.windowIcon()
                                                                                                                                                                                                                return None if icon.isNull() else gui.Icon(self.windowIcon())
                                                                                                                                                                                                        
                                                                                                                                                                                                            @classmethod
                                                                                                                                                                                                            def set_palette(cls, palette: constants.ThemeStr | gui.QPalette):
                                                                                                                                                                                                                match palette:
                                                                                                                                                                                                                    case "default":
                                                                                                                                                                                                                        pal = gui.Palette()
                                                                                                                                                                                                                    case "dark":
                                                                                                                                                                                                                        pal = gui.Palette.create_dark_palette()
                                                                                                                                                                                                                    case _:
                                                                                                                                                                                                                        pal = palette
                                                                                                                                                                                                                cls.setPalette(pal)
                                                                                                                                                                                                        
                                                                                                                                                                                                            @classmethod
                                                                                                                                                                                                            def get_keyboard_modifiers(cls) -> list[constants.KeyboardModifierStr]:
                                                                                                                                                                                                                return constants.KEYBOARD_MODIFIERS.get_list(cls.keyboardModifiers())
                                                                                                                                                                                                        
                                                                                                                                                                                                            @classmethod
                                                                                                                                                                                                            def query_keyboard_modifiers(cls) -> list[constants.KeyboardModifierStr]:
                                                                                                                                                                                                                return constants.KEYBOARD_MODIFIERS.get_list(cls.queryKeyboardModifiers())
                                                                                                                                                                                                        
                                                                                                                                                                                                            @classmethod
                                                                                                                                                                                                            def get_palette(cls) -> gui.Palette:
                                                                                                                                                                                                                return gui.Palette(cls.palette())
                                                                                                                                                                                                        
                                                                                                                                                                                                            def set_badge_number(self, number: int | None):
                                                                                                                                                                                                                self.setBadgeNumber(number or 0)
                                                                                                                                                                                                        
                                                                                                                                                                                                            def set_progress_value(self, value: int, total: int = 100):
                                                                                                                                                                                                                windows = self.topLevelWindows()
                                                                                                                                                                                                                if not windows:
                                                                                                                                                                                                                    return
                                                                                                                                                                                                                if sys.platform.startswith("win"):
                                                                                                                                                                                                                    from prettyqt.utils.platforms.windows import taskbaritem
                                                                                                                                                                                                        
                                                                                                                                                                                                                    window_id = windows[0].winId()
                                                                                                                                                                                                                    tb = taskbaritem.TaskBarItem(window_id)
                                                                                                                                                                                                                    tb.set_progress_value(value, total)
                                                                                                                                                                                                        
                                                                                                                                                                                                            def set_window_icon_color(self, color: datatypes.ColorType):
                                                                                                                                                                                                                self._window_icon_color = colors.get_color(color).name()
                                                                                                                                                                                                        
                                                                                                                                                                                                            def get_window_icon_color(self):
                                                                                                                                                                                                                return self._window_icon_color
                                                                                                                                                                                                        
                                                                                                                                                                                                            window_icon_color = core.Property(
                                                                                                                                                                                                                str,
                                                                                                                                                                                                                get_window_icon_color,
                                                                                                                                                                                                                set_window_icon_color,
                                                                                                                                                                                                                doc="Global window icon color",
                                                                                                                                                                                                            )
                                                                                                                                                                                                        

                                                                                                                                                                                                        copy_to_clipboard(text: str) classmethod

                                                                                                                                                                                                        Sets clipboard to supplied text.

                                                                                                                                                                                                        Source code in prettyqt/gui/guiapplication.py
                                                                                                                                                                                                        @classmethod
                                                                                                                                                                                                        def copy_to_clipboard(cls, text: str):
                                                                                                                                                                                                            """Sets clipboard to supplied text."""
                                                                                                                                                                                                            cb = cls.clipboard()
                                                                                                                                                                                                            cb.clear(mode=cb.Mode.Clipboard)
                                                                                                                                                                                                            cb.setText(text, mode=cb.Mode.Clipboard)
                                                                                                                                                                                                        

                                                                                                                                                                                                        get_application_state() -> list[constants.ApplicationStateStr] classmethod

                                                                                                                                                                                                        Get the current application state.

                                                                                                                                                                                                        Source code in prettyqt/gui/guiapplication.py
                                                                                                                                                                                                        @classmethod
                                                                                                                                                                                                        def get_application_state(cls) -> list[constants.ApplicationStateStr]:
                                                                                                                                                                                                            """Get the current application state.
                                                                                                                                                                                                        
                                                                                                                                                                                                            Returns:
                                                                                                                                                                                                                application state
                                                                                                                                                                                                            """
                                                                                                                                                                                                            return [
                                                                                                                                                                                                                k
                                                                                                                                                                                                                for k, v in constants.APPLICATION_STATES.items()
                                                                                                                                                                                                                if v & cls.applicationState()
                                                                                                                                                                                                            ]
                                                                                                                                                                                                        

                                                                                                                                                                                                        get_high_dpi_scale_factor_rounding_policy() -> constants.HighDpiScaleFactorRoundingPolicyStr classmethod

                                                                                                                                                                                                        Get the current high dpi scale factor rounding policy.

                                                                                                                                                                                                        Source code in prettyqt/gui/guiapplication.py
                                                                                                                                                                                                        @classmethod
                                                                                                                                                                                                        def get_high_dpi_scale_factor_rounding_policy(
                                                                                                                                                                                                            cls,
                                                                                                                                                                                                        ) -> constants.HighDpiScaleFactorRoundingPolicyStr:
                                                                                                                                                                                                            """Get the current high dpi scale factor rounding policy.
                                                                                                                                                                                                        
                                                                                                                                                                                                            Returns:
                                                                                                                                                                                                                rounding policy
                                                                                                                                                                                                            """
                                                                                                                                                                                                            return constants.HIGH_DPI_SCALE_FACTOR_ROUNDING_POLICY.inverse[
                                                                                                                                                                                                                cls.highDpiScaleFactorRoundingPolicy()
                                                                                                                                                                                                            ]
                                                                                                                                                                                                        

                                                                                                                                                                                                        get_layout_direction() -> constants.LayoutDirectionStr

                                                                                                                                                                                                        Get the current layout direction.

                                                                                                                                                                                                        Source code in prettyqt/gui/guiapplication.py
                                                                                                                                                                                                        def get_layout_direction(self) -> constants.LayoutDirectionStr:
                                                                                                                                                                                                            """Get the current layout direction.
                                                                                                                                                                                                        
                                                                                                                                                                                                            Returns:
                                                                                                                                                                                                                layout direction
                                                                                                                                                                                                            """
                                                                                                                                                                                                            return constants.LAYOUT_DIRECTION.inverse[self.layoutDirection()]
                                                                                                                                                                                                        

                                                                                                                                                                                                        set_high_dpi_scale_factor_rounding_policy(policy: constants.HighDpiScaleFactorRoundingPolicyStr | constants.HighDpiScaleFactorRoundingPolicy) classmethod

                                                                                                                                                                                                        Set high dpi scale factor rounding policy.

                                                                                                                                                                                                        Parameters:

                                                                                                                                                                                                        Name Type Description Default
                                                                                                                                                                                                        policy HighDpiScaleFactorRoundingPolicyStr | HighDpiScaleFactorRoundingPolicy

                                                                                                                                                                                                        rounding policy

                                                                                                                                                                                                        required
                                                                                                                                                                                                        Source code in prettyqt/gui/guiapplication.py
                                                                                                                                                                                                        @classmethod
                                                                                                                                                                                                        def set_high_dpi_scale_factor_rounding_policy(
                                                                                                                                                                                                            cls,
                                                                                                                                                                                                            policy: (
                                                                                                                                                                                                                constants.HighDpiScaleFactorRoundingPolicyStr
                                                                                                                                                                                                                | constants.HighDpiScaleFactorRoundingPolicy
                                                                                                                                                                                                            ),
                                                                                                                                                                                                        ):
                                                                                                                                                                                                            """Set high dpi scale factor rounding policy.
                                                                                                                                                                                                        
                                                                                                                                                                                                            Args:
                                                                                                                                                                                                                policy: rounding policy
                                                                                                                                                                                                            """
                                                                                                                                                                                                            cls.setHighDpiScaleFactorRoundingPolicy(
                                                                                                                                                                                                                constants.HIGH_DPI_SCALE_FACTOR_ROUNDING_POLICY.get_enum_value(policy)
                                                                                                                                                                                                            )
                                                                                                                                                                                                        

                                                                                                                                                                                                        set_icon(icon: datatypes.IconType)

                                                                                                                                                                                                        Set the default window icon.

                                                                                                                                                                                                        Parameters:

                                                                                                                                                                                                        Name Type Description Default
                                                                                                                                                                                                        icon IconType

                                                                                                                                                                                                        icon to use

                                                                                                                                                                                                        required
                                                                                                                                                                                                        Source code in prettyqt/gui/guiapplication.py
                                                                                                                                                                                                        def set_icon(self, icon: datatypes.IconType):
                                                                                                                                                                                                            """Set the default window icon.
                                                                                                                                                                                                        
                                                                                                                                                                                                            Args:
                                                                                                                                                                                                                icon: icon to use
                                                                                                                                                                                                            """
                                                                                                                                                                                                            color = self.get_window_icon_color()
                                                                                                                                                                                                            icon = iconprovider.get_icon(icon, color=color)
                                                                                                                                                                                                            self.setWindowIcon(icon)
                                                                                                                                                                                                        

                                                                                                                                                                                                        set_layout_direction(direction: constants.LayoutDirectionStr | constants.LayoutDirection)

                                                                                                                                                                                                        Set layout direction.

                                                                                                                                                                                                        Parameters:

                                                                                                                                                                                                        Name Type Description Default
                                                                                                                                                                                                        direction LayoutDirectionStr | LayoutDirection

                                                                                                                                                                                                        layout direction

                                                                                                                                                                                                        required
                                                                                                                                                                                                        Source code in prettyqt/gui/guiapplication.py
                                                                                                                                                                                                        def set_layout_direction(
                                                                                                                                                                                                            self, direction: constants.LayoutDirectionStr | constants.LayoutDirection
                                                                                                                                                                                                        ):
                                                                                                                                                                                                            """Set layout direction.
                                                                                                                                                                                                        
                                                                                                                                                                                                            Args:
                                                                                                                                                                                                                direction: layout direction
                                                                                                                                                                                                            """
                                                                                                                                                                                                            self.setLayoutDirection(constants.LAYOUT_DIRECTION.get_enum_value(direction))
                                                                                                                                                                                                        

                                                                                                                                                                                                        Icon

                                                                                                                                                                                                        Bases: SerializeMixin, QIcon

                                                                                                                                                                                                        Scalable icons in different modes and states.

                                                                                                                                                                                                        Source code in prettyqt/gui/icon.py
                                                                                                                                                                                                        class Icon(serializemixin.SerializeMixin, gui.QIcon):
                                                                                                                                                                                                            """Scalable icons in different modes and states."""
                                                                                                                                                                                                        
                                                                                                                                                                                                            def __repr__(self):
                                                                                                                                                                                                                return get_repr(self)
                                                                                                                                                                                                        
                                                                                                                                                                                                            def __bool__(self):
                                                                                                                                                                                                                return not self.isNull()
                                                                                                                                                                                                        
                                                                                                                                                                                                            def __getstate__(self):
                                                                                                                                                                                                                pixmap = self.pixmap(256, 256)
                                                                                                                                                                                                                return bytes(gui.Pixmap(pixmap))
                                                                                                                                                                                                        
                                                                                                                                                                                                            def __setstate__(self, ba):
                                                                                                                                                                                                                px = gui.Pixmap()
                                                                                                                                                                                                                px.__setstate__(ba)
                                                                                                                                                                                                                self.add_pixmap(px)
                                                                                                                                                                                                        
                                                                                                                                                                                                            @classmethod
                                                                                                                                                                                                            def for_color(cls, color_str: str) -> Self:
                                                                                                                                                                                                                color = gui.Color(color_str)
                                                                                                                                                                                                                bitmap = gui.Pixmap(16, 16)
                                                                                                                                                                                                                bitmap.fill(color)
                                                                                                                                                                                                                return cls(bitmap)
                                                                                                                                                                                                        
                                                                                                                                                                                                            @classmethod
                                                                                                                                                                                                            def from_char(cls, char: str, background="black", color="white") -> Self:
                                                                                                                                                                                                                """Create a QIcon with a given character."""
                                                                                                                                                                                                                icon = cls()
                                                                                                                                                                                                                for size in (16, 32, 64):
                                                                                                                                                                                                                    px = gui.Pixmap.create_char(
                                                                                                                                                                                                                        char, background=background, color=color, size=size
                                                                                                                                                                                                                    )
                                                                                                                                                                                                                    icon.addPixmap(px)
                                                                                                                                                                                                                return icon
                                                                                                                                                                                                        
                                                                                                                                                                                                            @classmethod
                                                                                                                                                                                                            def for_mimetype(cls, path: os.PathLike[str] | str) -> Self | None:
                                                                                                                                                                                                                """Try to create an icon from theme using the file mimetype.
                                                                                                                                                                                                        
                                                                                                                                                                                                                Returns None if there is no theme icon for the mimetype.
                                                                                                                                                                                                                """
                                                                                                                                                                                                                path = os.fspath(path)
                                                                                                                                                                                                                if mime := mimetypes.guess_type(path)[0]:
                                                                                                                                                                                                                    name = mime.replace("/", "-")
                                                                                                                                                                                                                    if cls.hasThemeIcon(name) and not (icon := cls(cls.fromTheme(name))).isNull():
                                                                                                                                                                                                                        return icon
                                                                                                                                                                                                                return None
                                                                                                                                                                                                        
                                                                                                                                                                                                            @classmethod
                                                                                                                                                                                                            def from_theme(
                                                                                                                                                                                                                cls,
                                                                                                                                                                                                                name: ThemeIconStr | gui.QIcon.ThemeIcon | str,
                                                                                                                                                                                                                fallback: gui.QIcon | None = None,
                                                                                                                                                                                                            ) -> Self:
                                                                                                                                                                                                                """Create an icon from a theme name or Qt 6.7+ ThemeIcon."""
                                                                                                                                                                                                                if isinstance(name, str) and name in THEME_ICON:
                                                                                                                                                                                                                    icon_arg: gui.QIcon.ThemeIcon | str = THEME_ICON[name]
                                                                                                                                                                                                                else:
                                                                                                                                                                                                                    icon_arg = name
                                                                                                                                                                                                                if fallback is None:
                                                                                                                                                                                                                    return cls(cls.fromTheme(icon_arg))
                                                                                                                                                                                                                return cls(cls.fromTheme(icon_arg, fallback))
                                                                                                                                                                                                        
                                                                                                                                                                                                            @classmethod
                                                                                                                                                                                                            def from_image(cls, image: gui.QImage) -> Self:
                                                                                                                                                                                                                return cls(gui.Pixmap.fromImage(image))
                                                                                                                                                                                                        
                                                                                                                                                                                                            def get_available_sizes(
                                                                                                                                                                                                                self,
                                                                                                                                                                                                                mode: ModeStr | gui.QIcon.Mode = "normal",
                                                                                                                                                                                                                state: StateStr | gui.QIcon.State = "off",
                                                                                                                                                                                                            ) -> list[core.Size]:
                                                                                                                                                                                                                m = MODE.get_enum_value(mode)
                                                                                                                                                                                                                s = STATE.get_enum_value(state)
                                                                                                                                                                                                                return [core.Size(i) for i in self.availableSizes(m, s)]
                                                                                                                                                                                                        
                                                                                                                                                                                                            def add_pixmap(
                                                                                                                                                                                                                self,
                                                                                                                                                                                                                data: core.QByteArray | gui.QPixmap | bytes,
                                                                                                                                                                                                                mode: ModeStr | gui.QIcon.Mode = "normal",
                                                                                                                                                                                                                state: StateStr | gui.QIcon.State = "off",
                                                                                                                                                                                                            ):
                                                                                                                                                                                                                if isinstance(data, bytes):
                                                                                                                                                                                                                    data = core.QByteArray(data)
                                                                                                                                                                                                                if isinstance(data, core.QByteArray):
                                                                                                                                                                                                                    pixmap = gui.QPixmap()
                                                                                                                                                                                                                    pixmap.loadFromData(data)
                                                                                                                                                                                                                else:
                                                                                                                                                                                                                    pixmap = data
                                                                                                                                                                                                                self.addPixmap(pixmap, MODE.get_enum_value(mode), STATE.get_enum_value(state))
                                                                                                                                                                                                        
                                                                                                                                                                                                            def get_pixmap(
                                                                                                                                                                                                                self,
                                                                                                                                                                                                                size: datatypes.SizeType | int,
                                                                                                                                                                                                                mode: ModeStr | gui.QIcon.Mode = "normal",
                                                                                                                                                                                                                state: StateStr | gui.QIcon.State = "off",
                                                                                                                                                                                                            ) -> gui.Pixmap:
                                                                                                                                                                                                                sz = datatypes.to_size(size)
                                                                                                                                                                                                                return gui.Pixmap(
                                                                                                                                                                                                                    self.pixmap(sz, MODE.get_enum_value(mode), STATE.get_enum_value(state))
                                                                                                                                                                                                                )
                                                                                                                                                                                                        
                                                                                                                                                                                                            def get_actual_size(
                                                                                                                                                                                                                self,
                                                                                                                                                                                                                size: datatypes.SizeType,
                                                                                                                                                                                                                mode: ModeStr | gui.QIcon.Mode = "normal",
                                                                                                                                                                                                                state: StateStr | gui.QIcon.State = "off",
                                                                                                                                                                                                            ) -> core.Size:
                                                                                                                                                                                                                sz = datatypes.to_size(size)
                                                                                                                                                                                                                m = MODE.get_enum_value(mode)
                                                                                                                                                                                                                s = STATE.get_enum_value(state)
                                                                                                                                                                                                                actual_size = self.actualSize(sz, m, s)
                                                                                                                                                                                                                return core.Size(actual_size)
                                                                                                                                                                                                        

                                                                                                                                                                                                        for_mimetype(path: os.PathLike[str] | str) -> Self | None classmethod

                                                                                                                                                                                                        Try to create an icon from theme using the file mimetype.

                                                                                                                                                                                                        Returns None if there is no theme icon for the mimetype.

                                                                                                                                                                                                        Source code in prettyqt/gui/icon.py
                                                                                                                                                                                                        @classmethod
                                                                                                                                                                                                        def for_mimetype(cls, path: os.PathLike[str] | str) -> Self | None:
                                                                                                                                                                                                            """Try to create an icon from theme using the file mimetype.
                                                                                                                                                                                                        
                                                                                                                                                                                                            Returns None if there is no theme icon for the mimetype.
                                                                                                                                                                                                            """
                                                                                                                                                                                                            path = os.fspath(path)
                                                                                                                                                                                                            if mime := mimetypes.guess_type(path)[0]:
                                                                                                                                                                                                                name = mime.replace("/", "-")
                                                                                                                                                                                                                if cls.hasThemeIcon(name) and not (icon := cls(cls.fromTheme(name))).isNull():
                                                                                                                                                                                                                    return icon
                                                                                                                                                                                                            return None
                                                                                                                                                                                                        

                                                                                                                                                                                                        from_char(char: str, background='black', color='white') -> Self classmethod

                                                                                                                                                                                                        Create a QIcon with a given character.

                                                                                                                                                                                                        Source code in prettyqt/gui/icon.py
                                                                                                                                                                                                        @classmethod
                                                                                                                                                                                                        def from_char(cls, char: str, background="black", color="white") -> Self:
                                                                                                                                                                                                            """Create a QIcon with a given character."""
                                                                                                                                                                                                            icon = cls()
                                                                                                                                                                                                            for size in (16, 32, 64):
                                                                                                                                                                                                                px = gui.Pixmap.create_char(
                                                                                                                                                                                                                    char, background=background, color=color, size=size
                                                                                                                                                                                                                )
                                                                                                                                                                                                                icon.addPixmap(px)
                                                                                                                                                                                                            return icon
                                                                                                                                                                                                        

                                                                                                                                                                                                        from_theme(name: ThemeIconStr | gui.QIcon.ThemeIcon | str, fallback: gui.QIcon | None = None) -> Self classmethod

                                                                                                                                                                                                        Create an icon from a theme name or Qt 6.7+ ThemeIcon.

                                                                                                                                                                                                        Source code in prettyqt/gui/icon.py
                                                                                                                                                                                                        @classmethod
                                                                                                                                                                                                        def from_theme(
                                                                                                                                                                                                            cls,
                                                                                                                                                                                                            name: ThemeIconStr | gui.QIcon.ThemeIcon | str,
                                                                                                                                                                                                            fallback: gui.QIcon | None = None,
                                                                                                                                                                                                        ) -> Self:
                                                                                                                                                                                                            """Create an icon from a theme name or Qt 6.7+ ThemeIcon."""
                                                                                                                                                                                                            if isinstance(name, str) and name in THEME_ICON:
                                                                                                                                                                                                                icon_arg: gui.QIcon.ThemeIcon | str = THEME_ICON[name]
                                                                                                                                                                                                            else:
                                                                                                                                                                                                                icon_arg = name
                                                                                                                                                                                                            if fallback is None:
                                                                                                                                                                                                                return cls(cls.fromTheme(icon_arg))
                                                                                                                                                                                                            return cls(cls.fromTheme(icon_arg, fallback))
                                                                                                                                                                                                        

                                                                                                                                                                                                        IconEngine

                                                                                                                                                                                                        Bases: QIconEngine

                                                                                                                                                                                                        Abstract base class for QIcon renderers.

                                                                                                                                                                                                        Source code in prettyqt/gui/iconengine.py
                                                                                                                                                                                                        class IconEngine(gui.QIconEngine):
                                                                                                                                                                                                            """Abstract base class for QIcon renderers."""
                                                                                                                                                                                                        
                                                                                                                                                                                                            def __repr__(self):
                                                                                                                                                                                                                return get_repr(self)
                                                                                                                                                                                                        
                                                                                                                                                                                                            def __bool__(self):
                                                                                                                                                                                                                return not self.isNull()
                                                                                                                                                                                                        
                                                                                                                                                                                                            def add_file(
                                                                                                                                                                                                                self,
                                                                                                                                                                                                                path: datatypes.PathType,
                                                                                                                                                                                                                size: datatypes.SizeType,
                                                                                                                                                                                                                mode: gui.icon.ModeStr | gui.QIcon.Mode,
                                                                                                                                                                                                                state: gui.icon.StateStr | gui.QIcon.State,
                                                                                                                                                                                                            ):
                                                                                                                                                                                                                self.addFile(
                                                                                                                                                                                                                    os.fspath(path),
                                                                                                                                                                                                                    datatypes.to_size(size),
                                                                                                                                                                                                                    gui.icon.MODE.get_enum_value(mode),
                                                                                                                                                                                                                    gui.icon.STATE.get_enum_value(state),
                                                                                                                                                                                                                )
                                                                                                                                                                                                        
                                                                                                                                                                                                            def add_pixmap(
                                                                                                                                                                                                                self,
                                                                                                                                                                                                                pixmap: gui.QPixmap,
                                                                                                                                                                                                                mode: gui.icon.ModeStr | gui.QIcon.Mode,
                                                                                                                                                                                                                state: gui.icon.StateStr | gui.QIcon.State,
                                                                                                                                                                                                            ):
                                                                                                                                                                                                                self.addPixmap(
                                                                                                                                                                                                                    pixmap,
                                                                                                                                                                                                                    gui.icon.MODE.get_enum_value(mode),
                                                                                                                                                                                                                    gui.icon.STATE.get_enum_value(state),
                                                                                                                                                                                                                )
                                                                                                                                                                                                        
                                                                                                                                                                                                            def get_actual_size(
                                                                                                                                                                                                                self,
                                                                                                                                                                                                                size: datatypes.SizeType,
                                                                                                                                                                                                                mode: gui.icon.ModeStr | gui.QIcon.Mode = "normal",
                                                                                                                                                                                                                state: gui.icon.StateStr | gui.QIcon.State = "off",
                                                                                                                                                                                                            ) -> core.Size:
                                                                                                                                                                                                                return core.Size(
                                                                                                                                                                                                                    self.actualSize(
                                                                                                                                                                                                                        datatypes.to_size(size),
                                                                                                                                                                                                                        gui.icon.MODE.get_enum_value(mode),
                                                                                                                                                                                                                        gui.icon.STATE.get_enum_value(state),
                                                                                                                                                                                                                    )
                                                                                                                                                                                                                )
                                                                                                                                                                                                        
                                                                                                                                                                                                            def get_available_sizes(
                                                                                                                                                                                                                self,
                                                                                                                                                                                                                mode: gui.icon.ModeStr | gui.QIcon.Mode = "normal",
                                                                                                                                                                                                                state: gui.icon.StateStr | gui.QIcon.State = "off",
                                                                                                                                                                                                            ) -> list[core.Size]:
                                                                                                                                                                                                                return [
                                                                                                                                                                                                                    core.Size(i)
                                                                                                                                                                                                                    for i in self.availableSizes(
                                                                                                                                                                                                                        gui.icon.MODE.get_enum_value(mode), gui.icon.STATE.get_enum_value(state)
                                                                                                                                                                                                                    )
                                                                                                                                                                                                                ]
                                                                                                                                                                                                        
                                                                                                                                                                                                            def get_pixmap(
                                                                                                                                                                                                                self,
                                                                                                                                                                                                                size: datatypes.SizeType,
                                                                                                                                                                                                                mode: gui.icon.ModeStr | gui.QIcon.Mode = "normal",
                                                                                                                                                                                                                state: gui.icon.StateStr | gui.QIcon.State = "off",
                                                                                                                                                                                                                scale: float | None = None,
                                                                                                                                                                                                            ) -> gui.Pixmap:
                                                                                                                                                                                                                if scale is None:
                                                                                                                                                                                                                    return gui.Pixmap(
                                                                                                                                                                                                                        self.pixmap(
                                                                                                                                                                                                                            datatypes.to_size(size),
                                                                                                                                                                                                                            gui.icon.MODE.get_enum_value(mode),
                                                                                                                                                                                                                            gui.icon.STATE.get_enum_value(state),
                                                                                                                                                                                                                        )
                                                                                                                                                                                                                    )
                                                                                                                                                                                                                return gui.Pixmap(
                                                                                                                                                                                                                    self.scaledPixmap(
                                                                                                                                                                                                                        datatypes.to_size(size),
                                                                                                                                                                                                                        gui.icon.MODE.get_enum_value(mode),
                                                                                                                                                                                                                        gui.icon.STATE.get_enum_value(state),
                                                                                                                                                                                                                        scale,
                                                                                                                                                                                                                    )
                                                                                                                                                                                                                )
                                                                                                                                                                                                        

                                                                                                                                                                                                        Image

                                                                                                                                                                                                        Bases: SerializeMixin, PaintDeviceMixin, QImage

                                                                                                                                                                                                        Hardware-independent image representation with direct access to the pixel data.

                                                                                                                                                                                                        Source code in prettyqt/gui/image.py
                                                                                                                                                                                                        class Image(serializemixin.SerializeMixin, gui.PaintDeviceMixin, gui.QImage):
                                                                                                                                                                                                            """Hardware-independent image representation with direct access to the pixel data."""
                                                                                                                                                                                                        
                                                                                                                                                                                                            def __setitem__(self, index: tuple[int, int], value):
                                                                                                                                                                                                                self.setPixel(index[1], index[0], value)
                                                                                                                                                                                                        
                                                                                                                                                                                                            def __getitem__(self, index: tuple[int, int]) -> int | list[int]:
                                                                                                                                                                                                                match index:
                                                                                                                                                                                                                    case int() as row, int() as col:
                                                                                                                                                                                                                        return self.pixel(col, row)
                                                                                                                                                                                                                    case (row, col):
                                                                                                                                                                                                                        rowcount = self.height()
                                                                                                                                                                                                                        colcount = self.width()
                                                                                                                                                                                                                        return [
                                                                                                                                                                                                                            self.pixel(j, i)
                                                                                                                                                                                                                            for i, j in helpers.iter_positions(row, col, rowcount, colcount)
                                                                                                                                                                                                                        ]
                                                                                                                                                                                                                    case _:
                                                                                                                                                                                                                        raise TypeError(index)
                                                                                                                                                                                                        
                                                                                                                                                                                                            @classmethod
                                                                                                                                                                                                            def from_ndarray(cls, arr) -> Self:
                                                                                                                                                                                                                import numpy as np
                                                                                                                                                                                                        
                                                                                                                                                                                                                height, width, bytes_per_component = arr.shape
                                                                                                                                                                                                                if arr.dtype in {np.float32, np.float64}:
                                                                                                                                                                                                                    arr = (255 * arr).round()
                                                                                                                                                                                                                arr = np.ascontiguousarray(arr, dtype=np.uint8)
                                                                                                                                                                                                                img = cls(
                                                                                                                                                                                                                    arr.data,
                                                                                                                                                                                                                    width,
                                                                                                                                                                                                                    height,
                                                                                                                                                                                                                    bytes_per_component * width,
                                                                                                                                                                                                                    gui.QImage.Format.Format_RGB888,
                                                                                                                                                                                                                )
                                                                                                                                                                                                                img.__data = arr  # ty: ignore[missing-attribute]  # keeps the buffer alive
                                                                                                                                                                                                                return img
                                                                                                                                                                                                        
                                                                                                                                                                                                            def to_ndarray(
                                                                                                                                                                                                                self, fmt: FormatStr | gui.QImage.Format = "rgb888", channels: int = 3
                                                                                                                                                                                                            ):
                                                                                                                                                                                                                import numpy as np
                                                                                                                                                                                                        
                                                                                                                                                                                                                qimage = self.convert_to_format(fmt)
                                                                                                                                                                                                                width = qimage.width()
                                                                                                                                                                                                                height = qimage.height()
                                                                                                                                                                                                                ptr = qimage.constBits()
                                                                                                                                                                                                                if ptr is None:
                                                                                                                                                                                                                    return np.empty((0, 0, channels), dtype=np.uint8)
                                                                                                                                                                                                                if API == "pyqt6":
                                                                                                                                                                                                                    raw = ptr.asstring(qimage.sizeInBytes())  # ty: ignore[missing-attribute]
                                                                                                                                                                                                                    arr = np.frombuffer(raw, dtype=np.uint8)
                                                                                                                                                                                                                else:
                                                                                                                                                                                                                    arr = np.frombuffer(ptr, dtype=np.uint8)
                                                                                                                                                                                                                bytes_per_line = qimage.bytesPerLine()
                                                                                                                                                                                                                arr = arr.reshape((height, bytes_per_line))[:, : width * channels]
                                                                                                                                                                                                                return arr.reshape((height, width, channels)).copy()
                                                                                                                                                                                                        
                                                                                                                                                                                                            @classmethod
                                                                                                                                                                                                            def from_pil(cls, image) -> Self:
                                                                                                                                                                                                                # from https://github.com/python-pillow/Pillow/blob/main/src/PIL/ImageQt.py
                                                                                                                                                                                                                from PIL import ImageQt
                                                                                                                                                                                                        
                                                                                                                                                                                                                data = ImageQt._toqclass_helper(image)
                                                                                                                                                                                                                img = cls(data["data"], data["size"][0], data["size"][1], data["format"])
                                                                                                                                                                                                                if data["colortable"]:
                                                                                                                                                                                                                    img.setColorTable(data["colortable"])
                                                                                                                                                                                                                img.__data = data["data"]  # ty: ignore[missing-attribute]  # keeps the buffer alive
                                                                                                                                                                                                                return img
                                                                                                                                                                                                        
                                                                                                                                                                                                            def to_pil(self):
                                                                                                                                                                                                                from PIL import Image as PILImage
                                                                                                                                                                                                        
                                                                                                                                                                                                                buffer = core.Buffer()
                                                                                                                                                                                                                buffer.open(core.Buffer.OpenModeFlag.ReadWrite)
                                                                                                                                                                                                                # PySide6's stub wants bytes, but only str works at runtime.
                                                                                                                                                                                                                self.save(buffer, "PNG")  # ty: ignore[no-matching-overload]
                                                                                                                                                                                                                return PILImage.open(io.BytesIO(buffer.data().data()))
                                                                                                                                                                                                        
                                                                                                                                                                                                            def invert_pixels(self, invert_alpha: bool = False):
                                                                                                                                                                                                                self.invertPixels(
                                                                                                                                                                                                                    gui.QImage.InvertMode.InvertRgba
                                                                                                                                                                                                                    if invert_alpha
                                                                                                                                                                                                                    else gui.QImage.InvertMode.InvertRgb
                                                                                                                                                                                                                )
                                                                                                                                                                                                        
                                                                                                                                                                                                            def convert_to_format(self, fmt: FormatStr | gui.QImage.Format) -> Self:
                                                                                                                                                                                                                return type(self)(self.convertToFormat(FORMAT.get_enum_value(fmt)))
                                                                                                                                                                                                        
                                                                                                                                                                                                            def as_bytes(self) -> bytes:
                                                                                                                                                                                                                bits = self.bits()
                                                                                                                                                                                                                if bits is None:
                                                                                                                                                                                                                    return b""
                                                                                                                                                                                                                if API == "pyqt6":  # sip.voidptr, the stubs only know PySide6's memoryview
                                                                                                                                                                                                                    return bits.asstring(self.sizeInBytes())  # ty: ignore[missing-attribute]
                                                                                                                                                                                                                return bytes(bits)
                                                                                                                                                                                                        

                                                                                                                                                                                                        ImageIOHandler

                                                                                                                                                                                                        Bases: mod

                                                                                                                                                                                                        Defines the common image I/O interface for all image formats in Qt.

                                                                                                                                                                                                        Source code in prettyqt/gui/imageiohandler.py
                                                                                                                                                                                                        class ImageIOHandler(mod):
                                                                                                                                                                                                            """Defines the common image I/O interface for all image formats in Qt."""
                                                                                                                                                                                                        
                                                                                                                                                                                                            def __getitem__(self, key: ImageOptionStr | mod.ImageOption) -> datatypes.Variant:
                                                                                                                                                                                                                return self.get_option(key)
                                                                                                                                                                                                        
                                                                                                                                                                                                            def __setitem__(
                                                                                                                                                                                                                self, key: ImageOptionStr | mod.ImageOption, value: datatypes.Variant
                                                                                                                                                                                                            ):
                                                                                                                                                                                                                self.set_option(key, value)
                                                                                                                                                                                                        
                                                                                                                                                                                                            def get_format(self) -> str:
                                                                                                                                                                                                                return bytes(self.format().data()).decode()
                                                                                                                                                                                                        
                                                                                                                                                                                                            def set_option(
                                                                                                                                                                                                                self, option: ImageOptionStr | mod.ImageOption, value: datatypes.Variant
                                                                                                                                                                                                            ):
                                                                                                                                                                                                                """Set option to given value.
                                                                                                                                                                                                        
                                                                                                                                                                                                                Args:
                                                                                                                                                                                                                    option: option to use
                                                                                                                                                                                                                    value: value to set
                                                                                                                                                                                                                """
                                                                                                                                                                                                                self.setOption(IMAGE_OPTION.get_enum_value(option), value)
                                                                                                                                                                                                        
                                                                                                                                                                                                            def get_option(self, option: ImageOptionStr | mod.ImageOption) -> datatypes.Variant:
                                                                                                                                                                                                                """Return the value assigned to option.
                                                                                                                                                                                                        
                                                                                                                                                                                                                Args:
                                                                                                                                                                                                                    option: option to get
                                                                                                                                                                                                        
                                                                                                                                                                                                                Returns:
                                                                                                                                                                                                                    option
                                                                                                                                                                                                                """
                                                                                                                                                                                                                return self.option(IMAGE_OPTION.get_enum_value(option))
                                                                                                                                                                                                        
                                                                                                                                                                                                            def supports_option(self, option: ImageOptionStr | mod.ImageOption) -> bool:
                                                                                                                                                                                                                """Return whether the image handler supports given option.
                                                                                                                                                                                                        
                                                                                                                                                                                                                Args:
                                                                                                                                                                                                                    option: option to check
                                                                                                                                                                                                        
                                                                                                                                                                                                                Returns:
                                                                                                                                                                                                                    option
                                                                                                                                                                                                                """
                                                                                                                                                                                                                return self.supportsOption(IMAGE_OPTION.get_enum_value(option))
                                                                                                                                                                                                        

                                                                                                                                                                                                        get_option(option: ImageOptionStr | mod.ImageOption) -> datatypes.Variant

                                                                                                                                                                                                        Return the value assigned to option.

                                                                                                                                                                                                        Parameters:

                                                                                                                                                                                                        Name Type Description Default
                                                                                                                                                                                                        option ImageOptionStr | ImageOption

                                                                                                                                                                                                        option to get

                                                                                                                                                                                                        required
                                                                                                                                                                                                        Source code in prettyqt/gui/imageiohandler.py
                                                                                                                                                                                                        def get_option(self, option: ImageOptionStr | mod.ImageOption) -> datatypes.Variant:
                                                                                                                                                                                                            """Return the value assigned to option.
                                                                                                                                                                                                        
                                                                                                                                                                                                            Args:
                                                                                                                                                                                                                option: option to get
                                                                                                                                                                                                        
                                                                                                                                                                                                            Returns:
                                                                                                                                                                                                                option
                                                                                                                                                                                                            """
                                                                                                                                                                                                            return self.option(IMAGE_OPTION.get_enum_value(option))
                                                                                                                                                                                                        

                                                                                                                                                                                                        set_option(option: ImageOptionStr | mod.ImageOption, value: datatypes.Variant)

                                                                                                                                                                                                        Set option to given value.

                                                                                                                                                                                                        Parameters:

                                                                                                                                                                                                        Name Type Description Default
                                                                                                                                                                                                        option ImageOptionStr | ImageOption

                                                                                                                                                                                                        option to use

                                                                                                                                                                                                        required
                                                                                                                                                                                                        value Variant

                                                                                                                                                                                                        value to set

                                                                                                                                                                                                        required
                                                                                                                                                                                                        Source code in prettyqt/gui/imageiohandler.py
                                                                                                                                                                                                        def set_option(
                                                                                                                                                                                                            self, option: ImageOptionStr | mod.ImageOption, value: datatypes.Variant
                                                                                                                                                                                                        ):
                                                                                                                                                                                                            """Set option to given value.
                                                                                                                                                                                                        
                                                                                                                                                                                                            Args:
                                                                                                                                                                                                                option: option to use
                                                                                                                                                                                                                value: value to set
                                                                                                                                                                                                            """
                                                                                                                                                                                                            self.setOption(IMAGE_OPTION.get_enum_value(option), value)
                                                                                                                                                                                                        

                                                                                                                                                                                                        supports_option(option: ImageOptionStr | mod.ImageOption) -> bool

                                                                                                                                                                                                        Return whether the image handler supports given option.

                                                                                                                                                                                                        Parameters:

                                                                                                                                                                                                        Name Type Description Default
                                                                                                                                                                                                        option ImageOptionStr | ImageOption

                                                                                                                                                                                                        option to check

                                                                                                                                                                                                        required
                                                                                                                                                                                                        Source code in prettyqt/gui/imageiohandler.py
                                                                                                                                                                                                        def supports_option(self, option: ImageOptionStr | mod.ImageOption) -> bool:
                                                                                                                                                                                                            """Return whether the image handler supports given option.
                                                                                                                                                                                                        
                                                                                                                                                                                                            Args:
                                                                                                                                                                                                                option: option to check
                                                                                                                                                                                                        
                                                                                                                                                                                                            Returns:
                                                                                                                                                                                                                option
                                                                                                                                                                                                            """
                                                                                                                                                                                                            return self.supportsOption(IMAGE_OPTION.get_enum_value(option))
                                                                                                                                                                                                        

                                                                                                                                                                                                        ImageReader

                                                                                                                                                                                                        Bases: QImageReader

                                                                                                                                                                                                        Format independent interface for reading images from files or other devices.

                                                                                                                                                                                                        Source code in prettyqt/gui/imagereader.py
                                                                                                                                                                                                        class ImageReader(gui.QImageReader):
                                                                                                                                                                                                            """Format independent interface for reading images from files or other devices."""
                                                                                                                                                                                                        
                                                                                                                                                                                                            def __getitem__(self, key: str) -> str:
                                                                                                                                                                                                                return self.text(key)
                                                                                                                                                                                                        
                                                                                                                                                                                                            def get_error(self) -> ImageReaderErrorStr:
                                                                                                                                                                                                                """Return error type.
                                                                                                                                                                                                        
                                                                                                                                                                                                                Returns:
                                                                                                                                                                                                                    error type
                                                                                                                                                                                                                """
                                                                                                                                                                                                                return IMAGE_READER_ERROR.inverse[self.error()]
                                                                                                                                                                                                        
                                                                                                                                                                                                            def get_background_color(self) -> gui.Color:
                                                                                                                                                                                                                return gui.Color(self.backgroundColor())
                                                                                                                                                                                                        
                                                                                                                                                                                                            def get_clip_rect(self) -> core.Rect:
                                                                                                                                                                                                                return core.Rect(self.clipRect())
                                                                                                                                                                                                        
                                                                                                                                                                                                            def get_current_image_rect(self) -> core.Rect:
                                                                                                                                                                                                                return core.Rect(self.currentImageRect())
                                                                                                                                                                                                        
                                                                                                                                                                                                            def get_scaled_clip_rect(self) -> core.Rect:
                                                                                                                                                                                                                return core.Rect(self.scaledClipRect())
                                                                                                                                                                                                        
                                                                                                                                                                                                            def get_size(self) -> core.Size:
                                                                                                                                                                                                                return core.Size(self.size())
                                                                                                                                                                                                        
                                                                                                                                                                                                            def get_scaled_size(self) -> core.Size:
                                                                                                                                                                                                                return core.Size(self.scaledSize())
                                                                                                                                                                                                        
                                                                                                                                                                                                            def get_format(self) -> str:
                                                                                                                                                                                                                return bytes(self.format().data()).decode()
                                                                                                                                                                                                        
                                                                                                                                                                                                            def get_subtype(self) -> str:
                                                                                                                                                                                                                return bytes(self.subType().data()).decode()
                                                                                                                                                                                                        
                                                                                                                                                                                                            def get_supported_subtypes(self) -> list[str]:
                                                                                                                                                                                                                return [bytes(i.data()).decode() for i in self.supportedSubTypes()]
                                                                                                                                                                                                        
                                                                                                                                                                                                            def set_format(self, fmt: datatypes.ByteArrayType):
                                                                                                                                                                                                                fmt = datatypes.to_bytearray(fmt)
                                                                                                                                                                                                                self.setFormat(fmt)
                                                                                                                                                                                                        
                                                                                                                                                                                                            def get_transformation(self) -> gui.imageiohandler.TransformationStr:
                                                                                                                                                                                                                """Return the transformation and orientation the image has been set to.
                                                                                                                                                                                                        
                                                                                                                                                                                                                Returns:
                                                                                                                                                                                                                    transformation
                                                                                                                                                                                                                """
                                                                                                                                                                                                                return gui.imageiohandler.TRANSFORMATION.inverse[self.transformation()]
                                                                                                                                                                                                        
                                                                                                                                                                                                            def read_image(self) -> gui.Image:
                                                                                                                                                                                                                return gui.Image(self.read())
                                                                                                                                                                                                        
                                                                                                                                                                                                            def supports_option(
                                                                                                                                                                                                                self, option: gui.imageiohandler.ImageOptionStr | gui.QImageIOHandler.ImageOption
                                                                                                                                                                                                            ) -> bool:
                                                                                                                                                                                                                """Return whether the image handler supports given option.
                                                                                                                                                                                                        
                                                                                                                                                                                                                Args:
                                                                                                                                                                                                                    option: option to check
                                                                                                                                                                                                        
                                                                                                                                                                                                                Returns:
                                                                                                                                                                                                                    option
                                                                                                                                                                                                                """
                                                                                                                                                                                                                return self.supportsOption(gui.imageiohandler.IMAGE_OPTION.get_enum_value(option))
                                                                                                                                                                                                        
                                                                                                                                                                                                            @staticmethod
                                                                                                                                                                                                            def get_image_format(obj: str | core.QIODevice) -> str:
                                                                                                                                                                                                                return bytes(ImageReader.imageFormat(obj).data()).decode()
                                                                                                                                                                                                        
                                                                                                                                                                                                            @staticmethod
                                                                                                                                                                                                            def get_supported_image_formats() -> list[str]:
                                                                                                                                                                                                                return [bytes(i.data()).decode() for i in ImageReader.supportedImageFormats()]
                                                                                                                                                                                                        
                                                                                                                                                                                                            @staticmethod
                                                                                                                                                                                                            def get_supported_mime_types() -> list[str]:
                                                                                                                                                                                                                return [bytes(i.data()).decode() for i in ImageReader.supportedMimeTypes()]
                                                                                                                                                                                                        
                                                                                                                                                                                                            @staticmethod
                                                                                                                                                                                                            def get_image_formats_for_mime_type(typ: datatypes.ByteArrayType) -> list[str]:
                                                                                                                                                                                                                typ = datatypes.to_bytearray(typ)
                                                                                                                                                                                                                return [
                                                                                                                                                                                                                    bytes(i.data()).decode() for i in ImageReader.imageFormatsForMimeType(typ)
                                                                                                                                                                                                                ]
                                                                                                                                                                                                        

                                                                                                                                                                                                        get_error() -> ImageReaderErrorStr

                                                                                                                                                                                                        Return error type.

                                                                                                                                                                                                        Source code in prettyqt/gui/imagereader.py
                                                                                                                                                                                                        def get_error(self) -> ImageReaderErrorStr:
                                                                                                                                                                                                            """Return error type.
                                                                                                                                                                                                        
                                                                                                                                                                                                            Returns:
                                                                                                                                                                                                                error type
                                                                                                                                                                                                            """
                                                                                                                                                                                                            return IMAGE_READER_ERROR.inverse[self.error()]
                                                                                                                                                                                                        

                                                                                                                                                                                                        get_transformation() -> gui.imageiohandler.TransformationStr

                                                                                                                                                                                                        Return the transformation and orientation the image has been set to.

                                                                                                                                                                                                        Source code in prettyqt/gui/imagereader.py
                                                                                                                                                                                                        def get_transformation(self) -> gui.imageiohandler.TransformationStr:
                                                                                                                                                                                                            """Return the transformation and orientation the image has been set to.
                                                                                                                                                                                                        
                                                                                                                                                                                                            Returns:
                                                                                                                                                                                                                transformation
                                                                                                                                                                                                            """
                                                                                                                                                                                                            return gui.imageiohandler.TRANSFORMATION.inverse[self.transformation()]
                                                                                                                                                                                                        

                                                                                                                                                                                                        supports_option(option: gui.imageiohandler.ImageOptionStr | gui.QImageIOHandler.ImageOption) -> bool

                                                                                                                                                                                                        Return whether the image handler supports given option.

                                                                                                                                                                                                        Parameters:

                                                                                                                                                                                                        Name Type Description Default
                                                                                                                                                                                                        option ImageOptionStr | ImageOption

                                                                                                                                                                                                        option to check

                                                                                                                                                                                                        required
                                                                                                                                                                                                        Source code in prettyqt/gui/imagereader.py
                                                                                                                                                                                                        def supports_option(
                                                                                                                                                                                                            self, option: gui.imageiohandler.ImageOptionStr | gui.QImageIOHandler.ImageOption
                                                                                                                                                                                                        ) -> bool:
                                                                                                                                                                                                            """Return whether the image handler supports given option.
                                                                                                                                                                                                        
                                                                                                                                                                                                            Args:
                                                                                                                                                                                                                option: option to check
                                                                                                                                                                                                        
                                                                                                                                                                                                            Returns:
                                                                                                                                                                                                                option
                                                                                                                                                                                                            """
                                                                                                                                                                                                            return self.supportsOption(gui.imageiohandler.IMAGE_OPTION.get_enum_value(option))
                                                                                                                                                                                                        

                                                                                                                                                                                                        ImageWriter

                                                                                                                                                                                                        Bases: QImageWriter

                                                                                                                                                                                                        Format independent interface for writing images to files or other devices.

                                                                                                                                                                                                        Source code in prettyqt/gui/imagewriter.py
                                                                                                                                                                                                        class ImageWriter(gui.QImageWriter):
                                                                                                                                                                                                            """Format independent interface for writing images to files or other devices."""
                                                                                                                                                                                                        
                                                                                                                                                                                                            def __setitem__(self, key: str, val: str):
                                                                                                                                                                                                                self.setText(key, val)
                                                                                                                                                                                                        
                                                                                                                                                                                                            def get_error(self) -> ImageWriterErrorStr:
                                                                                                                                                                                                                """Return error type.
                                                                                                                                                                                                        
                                                                                                                                                                                                                Returns:
                                                                                                                                                                                                                    error type
                                                                                                                                                                                                                """
                                                                                                                                                                                                                return IMAGE_WRITER_ERROR.inverse[self.error()]
                                                                                                                                                                                                        
                                                                                                                                                                                                            def get_format(self) -> str:
                                                                                                                                                                                                                return bytes(self.format().data()).decode()
                                                                                                                                                                                                        
                                                                                                                                                                                                            def get_subtype(self) -> str:
                                                                                                                                                                                                                return bytes(self.subType().data()).decode()
                                                                                                                                                                                                        
                                                                                                                                                                                                            def get_supported_image_formats(self) -> list[str]:
                                                                                                                                                                                                                return [bytes(i.data()).decode() for i in self.supportedImageFormats()]
                                                                                                                                                                                                        
                                                                                                                                                                                                            def get_supported_subtypes(self) -> list[str]:
                                                                                                                                                                                                                return [bytes(i.data()).decode() for i in self.supportedSubTypes()]
                                                                                                                                                                                                        
                                                                                                                                                                                                            def set_subtype(self, subtype: datatypes.ByteArrayType):
                                                                                                                                                                                                                subtype = datatypes.to_bytearray(subtype)
                                                                                                                                                                                                                self.setSubType(subtype)
                                                                                                                                                                                                        
                                                                                                                                                                                                            def set_format(self, fmt: datatypes.ByteArrayType):
                                                                                                                                                                                                                fmt = datatypes.to_bytearray(fmt)
                                                                                                                                                                                                                self.setFormat(fmt)
                                                                                                                                                                                                        
                                                                                                                                                                                                            def set_transformation(
                                                                                                                                                                                                                self,
                                                                                                                                                                                                                origin: gui.imageiohandler.TransformationStr | gui.ImageIOHandler.Transformation,
                                                                                                                                                                                                            ):
                                                                                                                                                                                                                """Set the image transformations metadata including orientation.
                                                                                                                                                                                                        
                                                                                                                                                                                                                Args:
                                                                                                                                                                                                                    origin: transformation to use
                                                                                                                                                                                                                """
                                                                                                                                                                                                                self.setTransformation(gui.imageiohandler.TRANSFORMATION.get_enum_value(origin))
                                                                                                                                                                                                        
                                                                                                                                                                                                            def get_transformation(self) -> gui.imageiohandler.TransformationStr:
                                                                                                                                                                                                                """Return the transformation and orientation the image has been set to.
                                                                                                                                                                                                        
                                                                                                                                                                                                                Returns:
                                                                                                                                                                                                                    transformation
                                                                                                                                                                                                                """
                                                                                                                                                                                                                return gui.imageiohandler.TRANSFORMATION.inverse[self.transformation()]
                                                                                                                                                                                                        

                                                                                                                                                                                                        get_error() -> ImageWriterErrorStr

                                                                                                                                                                                                        Return error type.

                                                                                                                                                                                                        Source code in prettyqt/gui/imagewriter.py
                                                                                                                                                                                                        def get_error(self) -> ImageWriterErrorStr:
                                                                                                                                                                                                            """Return error type.
                                                                                                                                                                                                        
                                                                                                                                                                                                            Returns:
                                                                                                                                                                                                                error type
                                                                                                                                                                                                            """
                                                                                                                                                                                                            return IMAGE_WRITER_ERROR.inverse[self.error()]
                                                                                                                                                                                                        

                                                                                                                                                                                                        get_transformation() -> gui.imageiohandler.TransformationStr

                                                                                                                                                                                                        Return the transformation and orientation the image has been set to.

                                                                                                                                                                                                        Source code in prettyqt/gui/imagewriter.py
                                                                                                                                                                                                        def get_transformation(self) -> gui.imageiohandler.TransformationStr:
                                                                                                                                                                                                            """Return the transformation and orientation the image has been set to.
                                                                                                                                                                                                        
                                                                                                                                                                                                            Returns:
                                                                                                                                                                                                                transformation
                                                                                                                                                                                                            """
                                                                                                                                                                                                            return gui.imageiohandler.TRANSFORMATION.inverse[self.transformation()]
                                                                                                                                                                                                        

                                                                                                                                                                                                        set_transformation(origin: gui.imageiohandler.TransformationStr | gui.ImageIOHandler.Transformation)

                                                                                                                                                                                                        Set the image transformations metadata including orientation.

                                                                                                                                                                                                        Parameters:

                                                                                                                                                                                                        Name Type Description Default
                                                                                                                                                                                                        origin TransformationStr | Transformation

                                                                                                                                                                                                        transformation to use

                                                                                                                                                                                                        required
                                                                                                                                                                                                        Source code in prettyqt/gui/imagewriter.py
                                                                                                                                                                                                        def set_transformation(
                                                                                                                                                                                                            self,
                                                                                                                                                                                                            origin: gui.imageiohandler.TransformationStr | gui.ImageIOHandler.Transformation,
                                                                                                                                                                                                        ):
                                                                                                                                                                                                            """Set the image transformations metadata including orientation.
                                                                                                                                                                                                        
                                                                                                                                                                                                            Args:
                                                                                                                                                                                                                origin: transformation to use
                                                                                                                                                                                                            """
                                                                                                                                                                                                            self.setTransformation(gui.imageiohandler.TRANSFORMATION.get_enum_value(origin))
                                                                                                                                                                                                        

                                                                                                                                                                                                        IntValidator

                                                                                                                                                                                                        Bases: ValidatorMixin, QIntValidator

                                                                                                                                                                                                        Validator that ensures a string contains a integer within a specified range.

                                                                                                                                                                                                        Source code in prettyqt/gui/intvalidator.py
                                                                                                                                                                                                        class IntValidator(gui.ValidatorMixin, gui.QIntValidator):
                                                                                                                                                                                                            """Validator that ensures a string contains a integer within a specified range."""
                                                                                                                                                                                                        
                                                                                                                                                                                                            ID = "integer_classic"
                                                                                                                                                                                                        
                                                                                                                                                                                                            def __repr__(self):
                                                                                                                                                                                                                return get_repr(self, self.bottom(), self.top())
                                                                                                                                                                                                        
                                                                                                                                                                                                            def __getstate__(self):
                                                                                                                                                                                                                return dict(bottom=self.bottom(), top=self.top())
                                                                                                                                                                                                        
                                                                                                                                                                                                            def __reduce__(self):
                                                                                                                                                                                                                return type(self), (self.bottom(), self.top()), None
                                                                                                                                                                                                        
                                                                                                                                                                                                            def __eq__(self, other: object):
                                                                                                                                                                                                                return (
                                                                                                                                                                                                                    self.bottom() == other.bottom() and self.top() == other.top()
                                                                                                                                                                                                                    if isinstance(other, type(self))
                                                                                                                                                                                                                    else False
                                                                                                                                                                                                                )
                                                                                                                                                                                                        
                                                                                                                                                                                                            def set_range(self, lower: int | None, upper: int | None):
                                                                                                                                                                                                                if lower is None:
                                                                                                                                                                                                                    lower = -MAX_VAL
                                                                                                                                                                                                                if upper is None:
                                                                                                                                                                                                                    upper = MAX_VAL
                                                                                                                                                                                                                self.setRange(lower, upper)
                                                                                                                                                                                                        

                                                                                                                                                                                                        KeySequence

                                                                                                                                                                                                        Bases: QKeySequence

                                                                                                                                                                                                        Encapsulates a key sequence as used by shortcuts.

                                                                                                                                                                                                        Source code in prettyqt/gui/keysequence.py
                                                                                                                                                                                                        class KeySequence(QtGui.QKeySequence):
                                                                                                                                                                                                            """Encapsulates a key sequence as used by shortcuts."""
                                                                                                                                                                                                        
                                                                                                                                                                                                            def __init__(self, *args, **kwargs):
                                                                                                                                                                                                                match args:
                                                                                                                                                                                                                    case (str(),) if args[0] in STANDARD_KEYS:
                                                                                                                                                                                                                        super().__init__(STANDARD_KEYS[args[0]])
                                                                                                                                                                                                                    case _:
                                                                                                                                                                                                                        super().__init__(*args, **kwargs)
                                                                                                                                                                                                        
                                                                                                                                                                                                            def __str__(self):
                                                                                                                                                                                                                return self.toString()
                                                                                                                                                                                                        
                                                                                                                                                                                                            def __repr__(self):
                                                                                                                                                                                                                return get_repr(self, self.toString())
                                                                                                                                                                                                        
                                                                                                                                                                                                            def __bool__(self):
                                                                                                                                                                                                                return not self.isEmpty()
                                                                                                                                                                                                        
                                                                                                                                                                                                            def __reduce__(self):
                                                                                                                                                                                                                return type(self), (self.toString(),)
                                                                                                                                                                                                        
                                                                                                                                                                                                            def __format__(self, format_spec: SequenceFormatStr):
                                                                                                                                                                                                                if format_spec in SEQUENCE_FORMAT:
                                                                                                                                                                                                                    return self.toString(SEQUENCE_FORMAT[format_spec])
                                                                                                                                                                                                                return super().__format__(format_spec)
                                                                                                                                                                                                        
                                                                                                                                                                                                            def __getitem__(self, item) -> core.KeyCombination:
                                                                                                                                                                                                                item = super().__getitem__(item)  # ty: ignore[missing-attribute]  # not in stubs
                                                                                                                                                                                                                return core.KeyCombination(item)
                                                                                                                                                                                                        
                                                                                                                                                                                                            @property
                                                                                                                                                                                                            def _toString(self) -> str:
                                                                                                                                                                                                                return self.toString()
                                                                                                                                                                                                        
                                                                                                                                                                                                            __match_args__ = ("_toString",)
                                                                                                                                                                                                        
                                                                                                                                                                                                            def get_matches(self, seq: QtGui.QKeySequence | str) -> SequenceMatchStr:
                                                                                                                                                                                                                if isinstance(seq, str):
                                                                                                                                                                                                                    seq = KeySequence(seq)
                                                                                                                                                                                                                return SEQUENCE_MATCHES.inverse[self.matches(seq)]
                                                                                                                                                                                                        
                                                                                                                                                                                                            @functools.singledispatchmethod
                                                                                                                                                                                                            @classmethod
                                                                                                                                                                                                            def to_shortcut_str(cls, key: constants.Key, mod: int = 0) -> str:
                                                                                                                                                                                                                return cls(mod | key).toString()
                                                                                                                                                                                                        
                                                                                                                                                                                                            @to_shortcut_str.register
                                                                                                                                                                                                            @classmethod
                                                                                                                                                                                                            def _(cls, key: core.QKeyCombination) -> str:
                                                                                                                                                                                                                return cls(key).toString()
                                                                                                                                                                                                        
                                                                                                                                                                                                            @classmethod
                                                                                                                                                                                                            def get_key_bindings(cls, button: str | QtGui.QKeySequence.StandardKey) -> list[Self]:
                                                                                                                                                                                                                return [cls(i) for i in cls.keyBindings(STANDARD_KEYS.get_enum_value(button))]
                                                                                                                                                                                                        

                                                                                                                                                                                                        LinearGradient

                                                                                                                                                                                                        Bases: GradientMixin, QLinearGradient

                                                                                                                                                                                                        Used in combination with QBrush to specify a linear gradient brush.

                                                                                                                                                                                                        Source code in prettyqt/gui/lineargradient.py
                                                                                                                                                                                                        class LinearGradient(gui.GradientMixin, gui.QLinearGradient):
                                                                                                                                                                                                            """Used in combination with QBrush to specify a linear gradient brush."""
                                                                                                                                                                                                        
                                                                                                                                                                                                            def __repr__(self):
                                                                                                                                                                                                                return get_repr(self, self.get_start(), self.get_final_stop())
                                                                                                                                                                                                        
                                                                                                                                                                                                            def get_start(self) -> core.PointF:
                                                                                                                                                                                                                return core.PointF(self.start())
                                                                                                                                                                                                        
                                                                                                                                                                                                            def get_final_stop(self) -> core.PointF:
                                                                                                                                                                                                                return core.PointF(self.finalStop())
                                                                                                                                                                                                        
                                                                                                                                                                                                            def get_css(self) -> str:
                                                                                                                                                                                                                """Convert gradient to a CSS string. Can be used for stylesheets."""
                                                                                                                                                                                                                stop, final_stop = self.start(), self.finalStop()
                                                                                                                                                                                                                x1, y1, x2, y2 = stop.x(), stop.y(), final_stop.x(), final_stop.y()
                                                                                                                                                                                                                stops = self.stops()
                                                                                                                                                                                                                stops = "\n".join(f"    stop: {stop:f} {color.name()}" for stop, color in stops)
                                                                                                                                                                                                                spread = self.get_spread()
                                                                                                                                                                                                                return (
                                                                                                                                                                                                                    "qlineargradient(\n"
                                                                                                                                                                                                                    f"    x1: {x1}, y1: {y1}, x2: {x2}, y2: {y2}, spread:{spread},\n"
                                                                                                                                                                                                                    f"{stops})"
                                                                                                                                                                                                                )
                                                                                                                                                                                                        

                                                                                                                                                                                                        get_css() -> str

                                                                                                                                                                                                        Convert gradient to a CSS string. Can be used for stylesheets.

                                                                                                                                                                                                        Source code in prettyqt/gui/lineargradient.py
                                                                                                                                                                                                        def get_css(self) -> str:
                                                                                                                                                                                                            """Convert gradient to a CSS string. Can be used for stylesheets."""
                                                                                                                                                                                                            stop, final_stop = self.start(), self.finalStop()
                                                                                                                                                                                                            x1, y1, x2, y2 = stop.x(), stop.y(), final_stop.x(), final_stop.y()
                                                                                                                                                                                                            stops = self.stops()
                                                                                                                                                                                                            stops = "\n".join(f"    stop: {stop:f} {color.name()}" for stop, color in stops)
                                                                                                                                                                                                            spread = self.get_spread()
                                                                                                                                                                                                            return (
                                                                                                                                                                                                                "qlineargradient(\n"
                                                                                                                                                                                                                f"    x1: {x1}, y1: {y1}, x2: {x2}, y2: {y2}, spread:{spread},\n"
                                                                                                                                                                                                                f"{stops})"
                                                                                                                                                                                                            )
                                                                                                                                                                                                        

                                                                                                                                                                                                        Matrix4x4

                                                                                                                                                                                                        Bases: QMatrix4x4

                                                                                                                                                                                                        Represents a 4x4 transformation matrix in 3D space.

                                                                                                                                                                                                        Source code in prettyqt/gui/matrix4x4.py
                                                                                                                                                                                                        class Matrix4x4(QtGui.QMatrix4x4):
                                                                                                                                                                                                            """Represents a 4x4 transformation matrix in 3D space."""
                                                                                                                                                                                                        

                                                                                                                                                                                                        Movie

                                                                                                                                                                                                        Bases: ObjectMixin, QMovie

                                                                                                                                                                                                        Convenience class for playing movies with QImageReader.

                                                                                                                                                                                                        Source code in prettyqt/gui/movie.py
                                                                                                                                                                                                        class Movie(core.ObjectMixin, QtGui.QMovie):
                                                                                                                                                                                                            """Convenience class for playing movies with QImageReader."""
                                                                                                                                                                                                        
                                                                                                                                                                                                            def __repr__(self):
                                                                                                                                                                                                                return get_repr(self, self.fileName(), self.get_format())
                                                                                                                                                                                                        
                                                                                                                                                                                                            def _get_map(self):
                                                                                                                                                                                                                maps = super()._get_map()
                                                                                                                                                                                                                maps |= {"cacheMode": CACHE_MODE}
                                                                                                                                                                                                                return maps
                                                                                                                                                                                                        
                                                                                                                                                                                                            def set_cache_mode(self, mode: CacheModeStr | QtGui.QMovie.CacheMode):
                                                                                                                                                                                                                """Set cache mode.
                                                                                                                                                                                                        
                                                                                                                                                                                                                Args:
                                                                                                                                                                                                                    mode: cache mode
                                                                                                                                                                                                                """
                                                                                                                                                                                                                self.setCacheMode(CACHE_MODE.get_enum_value(mode))
                                                                                                                                                                                                        
                                                                                                                                                                                                            def get_cache_mode(self) -> CacheModeStr:
                                                                                                                                                                                                                """Get the current cache mode.
                                                                                                                                                                                                        
                                                                                                                                                                                                                Returns:
                                                                                                                                                                                                                    cache mode
                                                                                                                                                                                                                """
                                                                                                                                                                                                                return CACHE_MODE.inverse[self.cacheMode()]
                                                                                                                                                                                                        
                                                                                                                                                                                                            def get_state(self) -> MovieStateStr:
                                                                                                                                                                                                                """Get the current state.
                                                                                                                                                                                                        
                                                                                                                                                                                                                Returns:
                                                                                                                                                                                                                    state
                                                                                                                                                                                                                """
                                                                                                                                                                                                                return MOVIE_STATE.inverse[self.state()]
                                                                                                                                                                                                        
                                                                                                                                                                                                            def get_format(self) -> str:
                                                                                                                                                                                                                return bytes(self.format().data()).decode()
                                                                                                                                                                                                        
                                                                                                                                                                                                            @classmethod
                                                                                                                                                                                                            def get_supported_formats(cls) -> list[str]:
                                                                                                                                                                                                                return [bytes(i.data()).decode() for i in cls.supportedFormats()]
                                                                                                                                                                                                        

                                                                                                                                                                                                        get_cache_mode() -> CacheModeStr

                                                                                                                                                                                                        Get the current cache mode.

                                                                                                                                                                                                        Source code in prettyqt/gui/movie.py
                                                                                                                                                                                                        def get_cache_mode(self) -> CacheModeStr:
                                                                                                                                                                                                            """Get the current cache mode.
                                                                                                                                                                                                        
                                                                                                                                                                                                            Returns:
                                                                                                                                                                                                                cache mode
                                                                                                                                                                                                            """
                                                                                                                                                                                                            return CACHE_MODE.inverse[self.cacheMode()]
                                                                                                                                                                                                        

                                                                                                                                                                                                        get_state() -> MovieStateStr

                                                                                                                                                                                                        Get the current state.

                                                                                                                                                                                                        Source code in prettyqt/gui/movie.py
                                                                                                                                                                                                        def get_state(self) -> MovieStateStr:
                                                                                                                                                                                                            """Get the current state.
                                                                                                                                                                                                        
                                                                                                                                                                                                            Returns:
                                                                                                                                                                                                                state
                                                                                                                                                                                                            """
                                                                                                                                                                                                            return MOVIE_STATE.inverse[self.state()]
                                                                                                                                                                                                        

                                                                                                                                                                                                        set_cache_mode(mode: CacheModeStr | QtGui.QMovie.CacheMode)

                                                                                                                                                                                                        Set cache mode.

                                                                                                                                                                                                        Parameters:

                                                                                                                                                                                                        Name Type Description Default
                                                                                                                                                                                                        mode CacheModeStr | CacheMode

                                                                                                                                                                                                        cache mode

                                                                                                                                                                                                        required
                                                                                                                                                                                                        Source code in prettyqt/gui/movie.py
                                                                                                                                                                                                        def set_cache_mode(self, mode: CacheModeStr | QtGui.QMovie.CacheMode):
                                                                                                                                                                                                            """Set cache mode.
                                                                                                                                                                                                        
                                                                                                                                                                                                            Args:
                                                                                                                                                                                                                mode: cache mode
                                                                                                                                                                                                            """
                                                                                                                                                                                                            self.setCacheMode(CACHE_MODE.get_enum_value(mode))
                                                                                                                                                                                                        

                                                                                                                                                                                                        PageLayout

                                                                                                                                                                                                        Bases: QPageLayout

                                                                                                                                                                                                        Describes the size, orientation and margins of a page.

                                                                                                                                                                                                        Source code in prettyqt/gui/pagelayout.py
                                                                                                                                                                                                        class PageLayout(gui.QPageLayout):
                                                                                                                                                                                                            """Describes the size, orientation and margins of a page."""
                                                                                                                                                                                                        
                                                                                                                                                                                                            def __repr__(self):
                                                                                                                                                                                                                return get_repr(self)
                                                                                                                                                                                                        
                                                                                                                                                                                                            def set_units(self, unit: UnitStr | gui.QPageLayout.Unit):
                                                                                                                                                                                                                """Set unit.
                                                                                                                                                                                                        
                                                                                                                                                                                                                Args:
                                                                                                                                                                                                                    unit: unit
                                                                                                                                                                                                                """
                                                                                                                                                                                                                self.setUnits(UNITS.get_enum_value(unit))
                                                                                                                                                                                                        
                                                                                                                                                                                                            def get_units(self) -> UnitStr:
                                                                                                                                                                                                                """Get the current unit.
                                                                                                                                                                                                        
                                                                                                                                                                                                                Returns:
                                                                                                                                                                                                                    unit
                                                                                                                                                                                                                """
                                                                                                                                                                                                                return UNITS.inverse[self.units()]
                                                                                                                                                                                                        
                                                                                                                                                                                                            def set_mode(self, mode: ModeStr | gui.QPageLayout.Mode):
                                                                                                                                                                                                                """Set mode.
                                                                                                                                                                                                        
                                                                                                                                                                                                                Args:
                                                                                                                                                                                                                    mode: mode
                                                                                                                                                                                                                """
                                                                                                                                                                                                                self.setMode(MODES.get_enum_value(mode))
                                                                                                                                                                                                        
                                                                                                                                                                                                            def get_mode(self) -> ModeStr:
                                                                                                                                                                                                                """Get the current mode.
                                                                                                                                                                                                        
                                                                                                                                                                                                                Returns:
                                                                                                                                                                                                                    mode
                                                                                                                                                                                                                """
                                                                                                                                                                                                                return MODES.inverse[self.mode()]
                                                                                                                                                                                                        
                                                                                                                                                                                                            def set_orientation(self, orientation: OrientationStr | gui.QPageLayout.Orientation):
                                                                                                                                                                                                                """Set orientation.
                                                                                                                                                                                                        
                                                                                                                                                                                                                Args:
                                                                                                                                                                                                                    orientation: orientation
                                                                                                                                                                                                                """
                                                                                                                                                                                                                self.setOrientation(ORIENTATIONS.get_enum_value(orientation))
                                                                                                                                                                                                        
                                                                                                                                                                                                            def get_orientation(self) -> OrientationStr:
                                                                                                                                                                                                                """Get the current orientation.
                                                                                                                                                                                                        
                                                                                                                                                                                                                Returns:
                                                                                                                                                                                                                    orientation
                                                                                                                                                                                                                """
                                                                                                                                                                                                                return ORIENTATIONS.inverse[self.orientation()]
                                                                                                                                                                                                        
                                                                                                                                                                                                            def get_page_size(self) -> gui.PageSize:
                                                                                                                                                                                                                return gui.PageSize(self.pageSize())
                                                                                                                                                                                                        

                                                                                                                                                                                                        get_mode() -> ModeStr

                                                                                                                                                                                                        Get the current mode.

                                                                                                                                                                                                        Source code in prettyqt/gui/pagelayout.py
                                                                                                                                                                                                        def get_mode(self) -> ModeStr:
                                                                                                                                                                                                            """Get the current mode.
                                                                                                                                                                                                        
                                                                                                                                                                                                            Returns:
                                                                                                                                                                                                                mode
                                                                                                                                                                                                            """
                                                                                                                                                                                                            return MODES.inverse[self.mode()]
                                                                                                                                                                                                        

                                                                                                                                                                                                        get_orientation() -> OrientationStr

                                                                                                                                                                                                        Get the current orientation.

                                                                                                                                                                                                        Source code in prettyqt/gui/pagelayout.py
                                                                                                                                                                                                        def get_orientation(self) -> OrientationStr:
                                                                                                                                                                                                            """Get the current orientation.
                                                                                                                                                                                                        
                                                                                                                                                                                                            Returns:
                                                                                                                                                                                                                orientation
                                                                                                                                                                                                            """
                                                                                                                                                                                                            return ORIENTATIONS.inverse[self.orientation()]
                                                                                                                                                                                                        

                                                                                                                                                                                                        get_units() -> UnitStr

                                                                                                                                                                                                        Get the current unit.

                                                                                                                                                                                                        Source code in prettyqt/gui/pagelayout.py
                                                                                                                                                                                                        def get_units(self) -> UnitStr:
                                                                                                                                                                                                            """Get the current unit.
                                                                                                                                                                                                        
                                                                                                                                                                                                            Returns:
                                                                                                                                                                                                                unit
                                                                                                                                                                                                            """
                                                                                                                                                                                                            return UNITS.inverse[self.units()]
                                                                                                                                                                                                        

                                                                                                                                                                                                        set_mode(mode: ModeStr | gui.QPageLayout.Mode)

                                                                                                                                                                                                        Set mode.

                                                                                                                                                                                                        Parameters:

                                                                                                                                                                                                        Name Type Description Default
                                                                                                                                                                                                        mode ModeStr | Mode

                                                                                                                                                                                                        mode

                                                                                                                                                                                                        required
                                                                                                                                                                                                        Source code in prettyqt/gui/pagelayout.py
                                                                                                                                                                                                        def set_mode(self, mode: ModeStr | gui.QPageLayout.Mode):
                                                                                                                                                                                                            """Set mode.
                                                                                                                                                                                                        
                                                                                                                                                                                                            Args:
                                                                                                                                                                                                                mode: mode
                                                                                                                                                                                                            """
                                                                                                                                                                                                            self.setMode(MODES.get_enum_value(mode))
                                                                                                                                                                                                        

                                                                                                                                                                                                        set_orientation(orientation: OrientationStr | gui.QPageLayout.Orientation)

                                                                                                                                                                                                        Set orientation.

                                                                                                                                                                                                        Parameters:

                                                                                                                                                                                                        Name Type Description Default
                                                                                                                                                                                                        orientation OrientationStr | Orientation

                                                                                                                                                                                                        orientation

                                                                                                                                                                                                        required
                                                                                                                                                                                                        Source code in prettyqt/gui/pagelayout.py
                                                                                                                                                                                                        def set_orientation(self, orientation: OrientationStr | gui.QPageLayout.Orientation):
                                                                                                                                                                                                            """Set orientation.
                                                                                                                                                                                                        
                                                                                                                                                                                                            Args:
                                                                                                                                                                                                                orientation: orientation
                                                                                                                                                                                                            """
                                                                                                                                                                                                            self.setOrientation(ORIENTATIONS.get_enum_value(orientation))
                                                                                                                                                                                                        

                                                                                                                                                                                                        set_units(unit: UnitStr | gui.QPageLayout.Unit)

                                                                                                                                                                                                        Set unit.

                                                                                                                                                                                                        Parameters:

                                                                                                                                                                                                        Name Type Description Default
                                                                                                                                                                                                        unit UnitStr | Unit

                                                                                                                                                                                                        unit

                                                                                                                                                                                                        required
                                                                                                                                                                                                        Source code in prettyqt/gui/pagelayout.py
                                                                                                                                                                                                        def set_units(self, unit: UnitStr | gui.QPageLayout.Unit):
                                                                                                                                                                                                            """Set unit.
                                                                                                                                                                                                        
                                                                                                                                                                                                            Args:
                                                                                                                                                                                                                unit: unit
                                                                                                                                                                                                            """
                                                                                                                                                                                                            self.setUnits(UNITS.get_enum_value(unit))
                                                                                                                                                                                                        

                                                                                                                                                                                                        PageRanges

                                                                                                                                                                                                        Bases: QPageRanges

                                                                                                                                                                                                        Represents a collection of page ranges.

                                                                                                                                                                                                        Source code in prettyqt/gui/pageranges.py
                                                                                                                                                                                                        class PageRanges(QtGui.QPageRanges):
                                                                                                                                                                                                            """Represents a collection of page ranges."""
                                                                                                                                                                                                        
                                                                                                                                                                                                            def __bool__(self):
                                                                                                                                                                                                                return not self.isEmpty()
                                                                                                                                                                                                        
                                                                                                                                                                                                            def __getitem__(self, index: int):
                                                                                                                                                                                                                return self.get_range_list()[index]
                                                                                                                                                                                                        
                                                                                                                                                                                                            def __str__(self):
                                                                                                                                                                                                                return self.toString()
                                                                                                                                                                                                        
                                                                                                                                                                                                            def __repr__(self):
                                                                                                                                                                                                                return get_repr(self, self.get_range_list())
                                                                                                                                                                                                        
                                                                                                                                                                                                            def __contains__(self, other: int):
                                                                                                                                                                                                                return self.contains(other)
                                                                                                                                                                                                        
                                                                                                                                                                                                            def __add__(self, other: int | tuple[int, int]):
                                                                                                                                                                                                                if isinstance(other, int):
                                                                                                                                                                                                                    self.addPage(other)
                                                                                                                                                                                                                else:
                                                                                                                                                                                                                    self.addRange(*other)
                                                                                                                                                                                                                return self
                                                                                                                                                                                                        
                                                                                                                                                                                                            def __len__(self):
                                                                                                                                                                                                                return self.lastPage() - self.firstPage()
                                                                                                                                                                                                        
                                                                                                                                                                                                            def get_range_list(self) -> list[tuple[int, int]]:
                                                                                                                                                                                                                return [(i.from_, i.to) for i in self.toRangeList()]
                                                                                                                                                                                                        

                                                                                                                                                                                                        PageSize

                                                                                                                                                                                                        Bases: QPageSize

                                                                                                                                                                                                        Describes the size and name of a defined page size.

                                                                                                                                                                                                        Source code in prettyqt/gui/pagesize.py
                                                                                                                                                                                                        class PageSize(QtGui.QPageSize):
                                                                                                                                                                                                            """Describes the size and name of a defined page size."""
                                                                                                                                                                                                        
                                                                                                                                                                                                            def __repr__(self):
                                                                                                                                                                                                                return get_repr(self, self.get_id())
                                                                                                                                                                                                        
                                                                                                                                                                                                            def __reduce__(self):
                                                                                                                                                                                                                return type(self), (self.id(),)
                                                                                                                                                                                                        
                                                                                                                                                                                                            def get_definition_units(self) -> UnitStr:
                                                                                                                                                                                                                """Get the definition unit.
                                                                                                                                                                                                        
                                                                                                                                                                                                                Returns:
                                                                                                                                                                                                                    unit
                                                                                                                                                                                                                """
                                                                                                                                                                                                                units = self.definitionUnits()
                                                                                                                                                                                                                if units.value == -1:
                                                                                                                                                                                                                    msg = "Invalid page size"
                                                                                                                                                                                                                    raise ValueError(msg)
                                                                                                                                                                                                                return UNITS.inverse[units]
                                                                                                                                                                                                        
                                                                                                                                                                                                            def get_id(self) -> str:
                                                                                                                                                                                                                """Get the standard page size id.
                                                                                                                                                                                                        
                                                                                                                                                                                                                Returns:
                                                                                                                                                                                                                    page size id
                                                                                                                                                                                                                """
                                                                                                                                                                                                                return PAGE_SIZE_ID.inverse[self.id()]
                                                                                                                                                                                                        

                                                                                                                                                                                                        get_definition_units() -> UnitStr

                                                                                                                                                                                                        Get the definition unit.

                                                                                                                                                                                                        Source code in prettyqt/gui/pagesize.py
                                                                                                                                                                                                        def get_definition_units(self) -> UnitStr:
                                                                                                                                                                                                            """Get the definition unit.
                                                                                                                                                                                                        
                                                                                                                                                                                                            Returns:
                                                                                                                                                                                                                unit
                                                                                                                                                                                                            """
                                                                                                                                                                                                            units = self.definitionUnits()
                                                                                                                                                                                                            if units.value == -1:
                                                                                                                                                                                                                msg = "Invalid page size"
                                                                                                                                                                                                                raise ValueError(msg)
                                                                                                                                                                                                            return UNITS.inverse[units]
                                                                                                                                                                                                        

                                                                                                                                                                                                        get_id() -> str

                                                                                                                                                                                                        Get the standard page size id.

                                                                                                                                                                                                        Source code in prettyqt/gui/pagesize.py
                                                                                                                                                                                                        def get_id(self) -> str:
                                                                                                                                                                                                            """Get the standard page size id.
                                                                                                                                                                                                        
                                                                                                                                                                                                            Returns:
                                                                                                                                                                                                                page size id
                                                                                                                                                                                                            """
                                                                                                                                                                                                            return PAGE_SIZE_ID.inverse[self.id()]
                                                                                                                                                                                                        

                                                                                                                                                                                                        PaintDevice

                                                                                                                                                                                                        Bases: PaintDeviceMixin, QPaintDevice

                                                                                                                                                                                                        The base class of objects that can be painted on with QPainter.

                                                                                                                                                                                                        Source code in prettyqt/gui/paintdevice.py
                                                                                                                                                                                                        class PaintDevice(PaintDeviceMixin, QtGui.QPaintDevice):
                                                                                                                                                                                                            """The base class of objects that can be painted on with QPainter."""
                                                                                                                                                                                                        

                                                                                                                                                                                                        PaintDeviceMixin

                                                                                                                                                                                                        Bases: _PaintDeviceBase

                                                                                                                                                                                                        Source code in prettyqt/gui/paintdevice.py
                                                                                                                                                                                                        class PaintDeviceMixin(_PaintDeviceBase):
                                                                                                                                                                                                            def get_metric(self, metric: MetricStr | QtGui.QPaintDevice.PaintDeviceMetric) -> int:
                                                                                                                                                                                                                """Return metric information.
                                                                                                                                                                                                        
                                                                                                                                                                                                                Args:
                                                                                                                                                                                                                    metric: metric information to get
                                                                                                                                                                                                        
                                                                                                                                                                                                                Returns:
                                                                                                                                                                                                                    metric information
                                                                                                                                                                                                                """
                                                                                                                                                                                                                return self.metric(METRICS.get_enum_value(metric))
                                                                                                                                                                                                        

                                                                                                                                                                                                        get_metric(metric: MetricStr | QtGui.QPaintDevice.PaintDeviceMetric) -> int

                                                                                                                                                                                                        Return metric information.

                                                                                                                                                                                                        Parameters:

                                                                                                                                                                                                        Name Type Description Default
                                                                                                                                                                                                        metric MetricStr | PaintDeviceMetric

                                                                                                                                                                                                        metric information to get

                                                                                                                                                                                                        required
                                                                                                                                                                                                        Source code in prettyqt/gui/paintdevice.py
                                                                                                                                                                                                        def get_metric(self, metric: MetricStr | QtGui.QPaintDevice.PaintDeviceMetric) -> int:
                                                                                                                                                                                                            """Return metric information.
                                                                                                                                                                                                        
                                                                                                                                                                                                            Args:
                                                                                                                                                                                                                metric: metric information to get
                                                                                                                                                                                                        
                                                                                                                                                                                                            Returns:
                                                                                                                                                                                                                metric information
                                                                                                                                                                                                            """
                                                                                                                                                                                                            return self.metric(METRICS.get_enum_value(metric))
                                                                                                                                                                                                        

                                                                                                                                                                                                        Painter

                                                                                                                                                                                                        Bases: PainterMixin, QPainter

                                                                                                                                                                                                        Performs low-level painting on widgets and other paint devices.

                                                                                                                                                                                                        Source code in prettyqt/gui/painter.py
                                                                                                                                                                                                        class Painter(PainterMixin, gui.QPainter):
                                                                                                                                                                                                            """Performs low-level painting on widgets and other paint devices."""
                                                                                                                                                                                                        

                                                                                                                                                                                                        PainterMixin

                                                                                                                                                                                                        Bases: _PainterBase

                                                                                                                                                                                                        Source code in prettyqt/gui/painter.py
                                                                                                                                                                                                        class PainterMixin(_PainterBase):
                                                                                                                                                                                                            def __enter__(self):
                                                                                                                                                                                                                return self
                                                                                                                                                                                                        
                                                                                                                                                                                                            def __exit__(self, typ, value, traceback):
                                                                                                                                                                                                                self.end()
                                                                                                                                                                                                        
                                                                                                                                                                                                            @contextlib.contextmanager
                                                                                                                                                                                                            def paint_on(self, obj) -> Generator[Self]:
                                                                                                                                                                                                                self.begin(obj)
                                                                                                                                                                                                                try:
                                                                                                                                                                                                                    yield self
                                                                                                                                                                                                                finally:
                                                                                                                                                                                                                    self.end()
                                                                                                                                                                                                        
                                                                                                                                                                                                            @contextlib.contextmanager
                                                                                                                                                                                                            def backup_state(self) -> Generator[Self]:
                                                                                                                                                                                                                self.save()
                                                                                                                                                                                                                try:
                                                                                                                                                                                                                    yield self
                                                                                                                                                                                                                finally:
                                                                                                                                                                                                                    self.restore()
                                                                                                                                                                                                        
                                                                                                                                                                                                            @contextlib.contextmanager
                                                                                                                                                                                                            def native_mode(self) -> Generator[Self]:
                                                                                                                                                                                                                self.beginNativePainting()
                                                                                                                                                                                                                try:
                                                                                                                                                                                                                    yield self
                                                                                                                                                                                                                finally:
                                                                                                                                                                                                                    self.endNativePainting()
                                                                                                                                                                                                        
                                                                                                                                                                                                            @contextlib.contextmanager
                                                                                                                                                                                                            def edit_pen(self) -> Generator[gui.Pen]:
                                                                                                                                                                                                                pen = gui.Pen(self.pen())
                                                                                                                                                                                                                try:
                                                                                                                                                                                                                    yield pen
                                                                                                                                                                                                                finally:
                                                                                                                                                                                                                    self.setPen(pen)
                                                                                                                                                                                                        
                                                                                                                                                                                                            @contextlib.contextmanager
                                                                                                                                                                                                            def edit_font(self) -> Generator[gui.Font]:
                                                                                                                                                                                                                font = gui.Font(self.font())
                                                                                                                                                                                                                try:
                                                                                                                                                                                                                    yield font
                                                                                                                                                                                                                finally:
                                                                                                                                                                                                                    self.setFont(font)
                                                                                                                                                                                                        
                                                                                                                                                                                                            def draw_text(
                                                                                                                                                                                                                self,
                                                                                                                                                                                                                position: datatypes.PointType | datatypes.RectType | datatypes.RectFType,
                                                                                                                                                                                                                text: str,
                                                                                                                                                                                                                alignment: constants.AlignmentStr = "center",
                                                                                                                                                                                                            ):
                                                                                                                                                                                                                # alignment needs a rect, a point is the text's baseline start
                                                                                                                                                                                                                flag = constants.ALIGNMENTS[alignment]
                                                                                                                                                                                                                match position:
                                                                                                                                                                                                                    case core.QPoint() | core.QPointF():
                                                                                                                                                                                                                        self.drawText(position, text)
                                                                                                                                                                                                                    case (int() | float() as x, int() | float() as y):
                                                                                                                                                                                                                        self.drawText(core.PointF(x, y), text)
                                                                                                                                                                                                                    case core.QRect() | core.QRectF():
                                                                                                                                                                                                                        self.drawText(position, flag, text)
                                                                                                                                                                                                                    case (
                                                                                                                                                                                                                        int() | float() as x,
                                                                                                                                                                                                                        int() | float() as y,
                                                                                                                                                                                                                        int() | float() as w,
                                                                                                                                                                                                                        int() | float() as h,
                                                                                                                                                                                                                    ):
                                                                                                                                                                                                                        self.drawText(core.RectF(x, y, w, h), flag, text)
                                                                                                                                                                                                                    case _:
                                                                                                                                                                                                                        raise TypeError(position)
                                                                                                                                                                                                        
                                                                                                                                                                                                            def draw_image(
                                                                                                                                                                                                                self,
                                                                                                                                                                                                                target: core.QPoint | core.QPointF | core.QRect | core.QRectF,
                                                                                                                                                                                                                frame_buffer: gui.QImage,
                                                                                                                                                                                                            ):
                                                                                                                                                                                                                mode = self.compositionMode()
                                                                                                                                                                                                                self.set_composition_mode("source_atop")
                                                                                                                                                                                                                try:
                                                                                                                                                                                                                    self.drawImage(target, frame_buffer)
                                                                                                                                                                                                                finally:
                                                                                                                                                                                                                    self.setCompositionMode(mode)
                                                                                                                                                                                                        
                                                                                                                                                                                                            def draw_polygon(
                                                                                                                                                                                                                self,
                                                                                                                                                                                                                points: gui.QPolygon | gui.QPolygonF | list[core.QPoint] | list[core.QPointF],
                                                                                                                                                                                                                fill_rule: constants.FillRuleStr | constants.FillRule = "odd_even",
                                                                                                                                                                                                            ):
                                                                                                                                                                                                                self.drawPolygon(points, fillRule=constants.FILL_RULE.get_enum_value(fill_rule))
                                                                                                                                                                                                        
                                                                                                                                                                                                            def draw_rounded_rect(
                                                                                                                                                                                                                self,
                                                                                                                                                                                                                rect: datatypes.RectType | datatypes.RectFType,
                                                                                                                                                                                                                x_radius: float,
                                                                                                                                                                                                                y_radius: float,
                                                                                                                                                                                                                relative: bool = False,
                                                                                                                                                                                                            ):
                                                                                                                                                                                                                flag = (
                                                                                                                                                                                                                    constants.SizeMode.RelativeSize
                                                                                                                                                                                                                    if relative
                                                                                                                                                                                                                    else constants.SizeMode.AbsoluteSize
                                                                                                                                                                                                                )
                                                                                                                                                                                                                self.drawRoundedRect(datatypes.to_rectf(rect), x_radius, y_radius, flag)
                                                                                                                                                                                                        
                                                                                                                                                                                                            def draw_star(self, size: float = 1.0, fill_rule: constants.FillRuleStr = "winding"):
                                                                                                                                                                                                                star = gui.PolygonF.create_star(size)
                                                                                                                                                                                                                self.drawPolygon(star, constants.FILL_RULE[fill_rule])
                                                                                                                                                                                                        
                                                                                                                                                                                                            def draw_diamond(
                                                                                                                                                                                                                self, size: float = 1.0, fill_rule: constants.FillRuleStr = "winding"
                                                                                                                                                                                                            ):
                                                                                                                                                                                                                star = gui.PolygonF.create_diamond(size)
                                                                                                                                                                                                                self.drawPolygon(star, constants.FILL_RULE[fill_rule])
                                                                                                                                                                                                        
                                                                                                                                                                                                            def use_antialiasing(self):
                                                                                                                                                                                                                self.setRenderHint(self.RenderHint.Antialiasing, True)
                                                                                                                                                                                                        
                                                                                                                                                                                                            def fill_rect(
                                                                                                                                                                                                                self,
                                                                                                                                                                                                                rect: datatypes.RectType | datatypes.RectFType,
                                                                                                                                                                                                                color: datatypes.ColorType,
                                                                                                                                                                                                                pattern: constants.BrushStyleStr | constants.BrushStyle = "solid",
                                                                                                                                                                                                            ):
                                                                                                                                                                                                                color = colors.get_color(color)
                                                                                                                                                                                                                if pattern != "solid":
                                                                                                                                                                                                                    brush = gui.Brush(color, constants.BRUSH_STYLE.get_enum_value(pattern))
                                                                                                                                                                                                                    self.fillRect(datatypes.to_rectf(rect), brush)
                                                                                                                                                                                                                else:
                                                                                                                                                                                                                    self.fillRect(datatypes.to_rectf(rect), color)
                                                                                                                                                                                                        
                                                                                                                                                                                                            def set_pen(
                                                                                                                                                                                                                self,
                                                                                                                                                                                                                style: constants.PenStyleStr | None = "solid",
                                                                                                                                                                                                                width: float = 1.0,
                                                                                                                                                                                                                color: datatypes.ColorType = "black",
                                                                                                                                                                                                                brush: gui.QBrush | None = None,
                                                                                                                                                                                                                miter_limit: float = 2.0,
                                                                                                                                                                                                                join_style: constants.JoinStyleStr = "bevel",
                                                                                                                                                                                                                cap_style: constants.CapStyleStr = "square",
                                                                                                                                                                                                            ) -> gui.Pen:
                                                                                                                                                                                                                """Set pen to use.
                                                                                                                                                                                                        
                                                                                                                                                                                                                Args:
                                                                                                                                                                                                                    style: pen style
                                                                                                                                                                                                                    width: pen width
                                                                                                                                                                                                                    color: pen color
                                                                                                                                                                                                                    brush: pen brush
                                                                                                                                                                                                                    miter_limit: miter limit
                                                                                                                                                                                                                    join_style: pen join style
                                                                                                                                                                                                                    cap_style: pen cap style
                                                                                                                                                                                                                """
                                                                                                                                                                                                                pen = gui.Pen()
                                                                                                                                                                                                                pen.set_style(style)
                                                                                                                                                                                                                if style in ["none", None]:
                                                                                                                                                                                                                    self.setPen(pen)
                                                                                                                                                                                                                    return pen
                                                                                                                                                                                                                pen.set_cap_style(cap_style)
                                                                                                                                                                                                                pen.set_join_style(join_style)
                                                                                                                                                                                                                pen.setMiterLimit(miter_limit)
                                                                                                                                                                                                                pen.setWidthF(width)
                                                                                                                                                                                                                if brush is not None:
                                                                                                                                                                                                                    pen.setBrush(brush)
                                                                                                                                                                                                                else:
                                                                                                                                                                                                                    pen.set_color(color)
                                                                                                                                                                                                                self.setPen(pen)
                                                                                                                                                                                                                return pen
                                                                                                                                                                                                        
                                                                                                                                                                                                            def get_pen(self) -> gui.Pen:
                                                                                                                                                                                                                """Return current pen.
                                                                                                                                                                                                        
                                                                                                                                                                                                                Returns:
                                                                                                                                                                                                                    current pen
                                                                                                                                                                                                                """
                                                                                                                                                                                                                return gui.Pen(self.pen())
                                                                                                                                                                                                        
                                                                                                                                                                                                            def set_color(self, color: datatypes.ColorType):
                                                                                                                                                                                                                color = colors.get_color(color)
                                                                                                                                                                                                                self.setPen(color)
                                                                                                                                                                                                        
                                                                                                                                                                                                            def set_brush(self, brush: gui.QBrush | datatypes.ColorType):
                                                                                                                                                                                                                if not isinstance(brush, gui.QBrush):
                                                                                                                                                                                                                    brush = colors.get_color(brush)
                                                                                                                                                                                                                self.setBrush(brush)
                                                                                                                                                                                                        
                                                                                                                                                                                                            def set_transparent_background(self, transparent: bool = True):
                                                                                                                                                                                                                mode = (
                                                                                                                                                                                                                    constants.BGMode.TransparentMode
                                                                                                                                                                                                                    if transparent
                                                                                                                                                                                                                    else constants.BGMode.OpaqueMode
                                                                                                                                                                                                                )
                                                                                                                                                                                                                self.setBackgroundMode(mode)
                                                                                                                                                                                                        
                                                                                                                                                                                                            def set_composition_mode(
                                                                                                                                                                                                                self, mode: CompositionModeStr | gui.QPainter.CompositionMode
                                                                                                                                                                                                            ):
                                                                                                                                                                                                                """Set the current composition mode.
                                                                                                                                                                                                        
                                                                                                                                                                                                                Arguments:
                                                                                                                                                                                                                    mode: composition mode
                                                                                                                                                                                                                """
                                                                                                                                                                                                                self.setCompositionMode(COMPOSITION_MODE.get_enum_value(mode))
                                                                                                                                                                                                        
                                                                                                                                                                                                            def get_composition_mode(self) -> CompositionModeStr:
                                                                                                                                                                                                                """Get the current composition mode.
                                                                                                                                                                                                        
                                                                                                                                                                                                                Returns:
                                                                                                                                                                                                                    composition mode
                                                                                                                                                                                                                """
                                                                                                                                                                                                                return COMPOSITION_MODE.inverse[self.compositionMode()]
                                                                                                                                                                                                        
                                                                                                                                                                                                            def set_transform(self, transform: datatypes.TransformType, combine: bool = False):
                                                                                                                                                                                                                self.setTransform(datatypes.to_transform(transform), combine)
                                                                                                                                                                                                        
                                                                                                                                                                                                            def get_font_metrics(self) -> gui.FontMetrics:
                                                                                                                                                                                                                return gui.FontMetrics(self.fontMetrics())
                                                                                                                                                                                                        
                                                                                                                                                                                                            def set_clip_path(
                                                                                                                                                                                                                self,
                                                                                                                                                                                                                path: gui.QPainterPath,
                                                                                                                                                                                                                operation: constants.ClipOperationStr | constants.ClipOperation = "replace",
                                                                                                                                                                                                            ):
                                                                                                                                                                                                                self.setClipPath(path, constants.CLIP_OPERATION.get_enum_value(operation))
                                                                                                                                                                                                        
                                                                                                                                                                                                            def get_text_rect(self, text: str) -> core.Rect:
                                                                                                                                                                                                                return core.Rect(
                                                                                                                                                                                                                    self.drawText(core.Rect(), constants.TextFlag.TextDontPrint, text)
                                                                                                                                                                                                                )
                                                                                                                                                                                                        
                                                                                                                                                                                                            @contextlib.contextmanager
                                                                                                                                                                                                            def clip_path(
                                                                                                                                                                                                                self, operation: constants.ClipOperationStr = "replace"
                                                                                                                                                                                                            ) -> Generator[gui.PainterPath]:
                                                                                                                                                                                                                path = gui.PainterPath()
                                                                                                                                                                                                                try:
                                                                                                                                                                                                                    yield path
                                                                                                                                                                                                                finally:
                                                                                                                                                                                                                    self.set_clip_path(path, operation)
                                                                                                                                                                                                        
                                                                                                                                                                                                            @contextlib.contextmanager
                                                                                                                                                                                                            def apply_transform(self, combine: bool = True) -> Generator[gui.Transform]:
                                                                                                                                                                                                                transform = gui.Transform()
                                                                                                                                                                                                                try:
                                                                                                                                                                                                                    yield transform
                                                                                                                                                                                                                finally:
                                                                                                                                                                                                                    self.setTransform(transform, combine)
                                                                                                                                                                                                        
                                                                                                                                                                                                            @contextlib.contextmanager
                                                                                                                                                                                                            def offset_by(self, x: int = 0, y: int = 0) -> Generator[Self]:
                                                                                                                                                                                                                self.translate(x, y)
                                                                                                                                                                                                                try:
                                                                                                                                                                                                                    yield self
                                                                                                                                                                                                                finally:
                                                                                                                                                                                                                    self.translate(-x, -y)
                                                                                                                                                                                                        

                                                                                                                                                                                                        get_composition_mode() -> CompositionModeStr

                                                                                                                                                                                                        Get the current composition mode.

                                                                                                                                                                                                        Source code in prettyqt/gui/painter.py
                                                                                                                                                                                                        def get_composition_mode(self) -> CompositionModeStr:
                                                                                                                                                                                                            """Get the current composition mode.
                                                                                                                                                                                                        
                                                                                                                                                                                                            Returns:
                                                                                                                                                                                                                composition mode
                                                                                                                                                                                                            """
                                                                                                                                                                                                            return COMPOSITION_MODE.inverse[self.compositionMode()]
                                                                                                                                                                                                        

                                                                                                                                                                                                        get_pen() -> gui.Pen

                                                                                                                                                                                                        Return current pen.

                                                                                                                                                                                                        Source code in prettyqt/gui/painter.py
                                                                                                                                                                                                        def get_pen(self) -> gui.Pen:
                                                                                                                                                                                                            """Return current pen.
                                                                                                                                                                                                        
                                                                                                                                                                                                            Returns:
                                                                                                                                                                                                                current pen
                                                                                                                                                                                                            """
                                                                                                                                                                                                            return gui.Pen(self.pen())
                                                                                                                                                                                                        

                                                                                                                                                                                                        set_composition_mode(mode: CompositionModeStr | gui.QPainter.CompositionMode)

                                                                                                                                                                                                        Set the current composition mode.

                                                                                                                                                                                                        Parameters:

                                                                                                                                                                                                        Name Type Description Default
                                                                                                                                                                                                        mode CompositionModeStr | CompositionMode

                                                                                                                                                                                                        composition mode

                                                                                                                                                                                                        required
                                                                                                                                                                                                        Source code in prettyqt/gui/painter.py
                                                                                                                                                                                                        def set_composition_mode(
                                                                                                                                                                                                            self, mode: CompositionModeStr | gui.QPainter.CompositionMode
                                                                                                                                                                                                        ):
                                                                                                                                                                                                            """Set the current composition mode.
                                                                                                                                                                                                        
                                                                                                                                                                                                            Arguments:
                                                                                                                                                                                                                mode: composition mode
                                                                                                                                                                                                            """
                                                                                                                                                                                                            self.setCompositionMode(COMPOSITION_MODE.get_enum_value(mode))
                                                                                                                                                                                                        

                                                                                                                                                                                                        set_pen(style: constants.PenStyleStr | None = 'solid', width: float = 1.0, color: datatypes.ColorType = 'black', brush: gui.QBrush | None = None, miter_limit: float = 2.0, join_style: constants.JoinStyleStr = 'bevel', cap_style: constants.CapStyleStr = 'square') -> gui.Pen

                                                                                                                                                                                                        Set pen to use.

                                                                                                                                                                                                        Parameters:

                                                                                                                                                                                                        Name Type Description Default
                                                                                                                                                                                                        style PenStyleStr | None

                                                                                                                                                                                                        pen style

                                                                                                                                                                                                        'solid'
                                                                                                                                                                                                        width float

                                                                                                                                                                                                        pen width

                                                                                                                                                                                                        1.0
                                                                                                                                                                                                        color ColorType

                                                                                                                                                                                                        pen color

                                                                                                                                                                                                        'black'
                                                                                                                                                                                                        brush QBrush | None

                                                                                                                                                                                                        pen brush

                                                                                                                                                                                                        None
                                                                                                                                                                                                        miter_limit float

                                                                                                                                                                                                        miter limit

                                                                                                                                                                                                        2.0
                                                                                                                                                                                                        join_style JoinStyleStr

                                                                                                                                                                                                        pen join style

                                                                                                                                                                                                        'bevel'
                                                                                                                                                                                                        cap_style CapStyleStr

                                                                                                                                                                                                        pen cap style

                                                                                                                                                                                                        'square'
                                                                                                                                                                                                        Source code in prettyqt/gui/painter.py
                                                                                                                                                                                                        def set_pen(
                                                                                                                                                                                                            self,
                                                                                                                                                                                                            style: constants.PenStyleStr | None = "solid",
                                                                                                                                                                                                            width: float = 1.0,
                                                                                                                                                                                                            color: datatypes.ColorType = "black",
                                                                                                                                                                                                            brush: gui.QBrush | None = None,
                                                                                                                                                                                                            miter_limit: float = 2.0,
                                                                                                                                                                                                            join_style: constants.JoinStyleStr = "bevel",
                                                                                                                                                                                                            cap_style: constants.CapStyleStr = "square",
                                                                                                                                                                                                        ) -> gui.Pen:
                                                                                                                                                                                                            """Set pen to use.
                                                                                                                                                                                                        
                                                                                                                                                                                                            Args:
                                                                                                                                                                                                                style: pen style
                                                                                                                                                                                                                width: pen width
                                                                                                                                                                                                                color: pen color
                                                                                                                                                                                                                brush: pen brush
                                                                                                                                                                                                                miter_limit: miter limit
                                                                                                                                                                                                                join_style: pen join style
                                                                                                                                                                                                                cap_style: pen cap style
                                                                                                                                                                                                            """
                                                                                                                                                                                                            pen = gui.Pen()
                                                                                                                                                                                                            pen.set_style(style)
                                                                                                                                                                                                            if style in ["none", None]:
                                                                                                                                                                                                                self.setPen(pen)
                                                                                                                                                                                                                return pen
                                                                                                                                                                                                            pen.set_cap_style(cap_style)
                                                                                                                                                                                                            pen.set_join_style(join_style)
                                                                                                                                                                                                            pen.setMiterLimit(miter_limit)
                                                                                                                                                                                                            pen.setWidthF(width)
                                                                                                                                                                                                            if brush is not None:
                                                                                                                                                                                                                pen.setBrush(brush)
                                                                                                                                                                                                            else:
                                                                                                                                                                                                                pen.set_color(color)
                                                                                                                                                                                                            self.setPen(pen)
                                                                                                                                                                                                            return pen
                                                                                                                                                                                                        

                                                                                                                                                                                                        PainterPath

                                                                                                                                                                                                        Bases: QPainterPath

                                                                                                                                                                                                        Source code in prettyqt/gui/painterpath.py
                                                                                                                                                                                                        class PainterPath(QtGui.QPainterPath):
                                                                                                                                                                                                            def __len__(self):
                                                                                                                                                                                                                return self.elementCount()
                                                                                                                                                                                                        
                                                                                                                                                                                                            def __getitem__(self, index: int) -> QtGui.QPainterPath.Element:
                                                                                                                                                                                                                return self.elementAt(index)
                                                                                                                                                                                                        
                                                                                                                                                                                                            def __iter__(self) -> Iterator[QtGui.QPainterPath.Element]:
                                                                                                                                                                                                                return iter(self.elementAt(i) for i in range(self.elementCount()))
                                                                                                                                                                                                        
                                                                                                                                                                                                            def __setitem__(self, index: int, value: tuple[int, int]):
                                                                                                                                                                                                                self.setElementPositionAt(index, *value)
                                                                                                                                                                                                        
                                                                                                                                                                                                            def __iadd__(self, other):
                                                                                                                                                                                                                if not isinstance(
                                                                                                                                                                                                                    other,
                                                                                                                                                                                                                    core.QRect
                                                                                                                                                                                                                    | core.QRectF
                                                                                                                                                                                                                    | QtGui.QPolygonF
                                                                                                                                                                                                                    | QtGui.QPainterPath
                                                                                                                                                                                                                    | QtGui.QRegion,
                                                                                                                                                                                                                ):
                                                                                                                                                                                                                    raise TypeError(other)
                                                                                                                                                                                                                self.add(other)
                                                                                                                                                                                                                return self
                                                                                                                                                                                                        
                                                                                                                                                                                                            def add(
                                                                                                                                                                                                                self,
                                                                                                                                                                                                                other: core.QRect
                                                                                                                                                                                                                | core.QRectF
                                                                                                                                                                                                                | QtGui.QPolygonF
                                                                                                                                                                                                                | QtGui.QPainterPath
                                                                                                                                                                                                                | QtGui.QRegion,
                                                                                                                                                                                                            ):
                                                                                                                                                                                                                match other:
                                                                                                                                                                                                                    case QtGui.QPolygonF():
                                                                                                                                                                                                                        self.addPolygon(other)
                                                                                                                                                                                                                    case QtGui.QPainterPath():
                                                                                                                                                                                                                        self.addPath(other)
                                                                                                                                                                                                                    case core.QRect():
                                                                                                                                                                                                                        self.addRect(core.QRectF(other))
                                                                                                                                                                                                                    case core.QRectF():
                                                                                                                                                                                                                        self.addRect(other)
                                                                                                                                                                                                                    case QtGui.QRegion():
                                                                                                                                                                                                                        self.addRegion(other)
                                                                                                                                                                                                        
                                                                                                                                                                                                            def __bool__(self):
                                                                                                                                                                                                                return not self.isEmpty()
                                                                                                                                                                                                        
                                                                                                                                                                                                            def __contains__(self, item: core.QPointF | core.QRectF | QtGui.QPainterPath):
                                                                                                                                                                                                                return self.contains(item)
                                                                                                                                                                                                        
                                                                                                                                                                                                            def add_rect(self, rect: datatypes.RectType | datatypes.RectFType):
                                                                                                                                                                                                                self.addRect(datatypes.to_rectf(rect))
                                                                                                                                                                                                        
                                                                                                                                                                                                            def set_fill_rule(self, rule: constants.FillRuleStr | constants.FillRule):
                                                                                                                                                                                                                """Set fill rule.
                                                                                                                                                                                                        
                                                                                                                                                                                                                Args:
                                                                                                                                                                                                                    rule: fill rule to use
                                                                                                                                                                                                                """
                                                                                                                                                                                                                self.setFillRule(constants.FILL_RULE.get_enum_value(rule))
                                                                                                                                                                                                        
                                                                                                                                                                                                            def get_fill_rule(self) -> constants.FillRuleStr:
                                                                                                                                                                                                                """Return current fill rule.
                                                                                                                                                                                                        
                                                                                                                                                                                                                Returns:
                                                                                                                                                                                                                    fill rule
                                                                                                                                                                                                                """
                                                                                                                                                                                                                return constants.FILL_RULE.inverse[self.fillRule()]
                                                                                                                                                                                                        
                                                                                                                                                                                                            def get_bounding_rect(self) -> core.RectF:
                                                                                                                                                                                                                return core.RectF(self.boundingRect())
                                                                                                                                                                                                        
                                                                                                                                                                                                            def get_simplified(self) -> PainterPath:
                                                                                                                                                                                                                return PainterPath(self.simplified())
                                                                                                                                                                                                        
                                                                                                                                                                                                            def to_reversed(self) -> PainterPath:
                                                                                                                                                                                                                return PainterPath(self.toReversed())
                                                                                                                                                                                                        
                                                                                                                                                                                                            @classmethod
                                                                                                                                                                                                            def create_star(cls, size: int):
                                                                                                                                                                                                                path = cls()
                                                                                                                                                                                                                star_center_x = size / 2
                                                                                                                                                                                                                star_center_y = size / 2
                                                                                                                                                                                                                radius_outer = size * 0.35
                                                                                                                                                                                                                golden_ratio = (1 + math.sqrt(5)) / 2
                                                                                                                                                                                                                radius_inner = radius_outer / (1 + golden_ratio)
                                                                                                                                                                                                                theta_start = math.pi / 2
                                                                                                                                                                                                                theta_inc = (2 * math.pi) / 10
                                                                                                                                                                                                                for n in range(11):
                                                                                                                                                                                                                    theta = theta_start + (n * theta_inc)
                                                                                                                                                                                                                    theta = theta % (2 * math.pi)
                                                                                                                                                                                                                    if n % 2 == 0:
                                                                                                                                                                                                                        x = radius_outer * math.cos(theta)
                                                                                                                                                                                                                        y = radius_outer * math.sin(theta)
                                                                                                                                                                                                        
                                                                                                                                                                                                                    else:
                                                                                                                                                                                                                        x = radius_inner * math.cos(theta)
                                                                                                                                                                                                                        y = radius_inner * math.sin(theta)
                                                                                                                                                                                                        
                                                                                                                                                                                                                    x_adj = star_center_x - x
                                                                                                                                                                                                                    y_adj = star_center_y - y + 3
                                                                                                                                                                                                                    if n == 0:
                                                                                                                                                                                                                        path.moveTo(x_adj, y_adj)
                                                                                                                                                                                                                    else:
                                                                                                                                                                                                                        path.lineTo(x_adj, y_adj)
                                                                                                                                                                                                        
                                                                                                                                                                                                                return path
                                                                                                                                                                                                        

                                                                                                                                                                                                        get_fill_rule() -> constants.FillRuleStr

                                                                                                                                                                                                        Return current fill rule.

                                                                                                                                                                                                        Source code in prettyqt/gui/painterpath.py
                                                                                                                                                                                                        def get_fill_rule(self) -> constants.FillRuleStr:
                                                                                                                                                                                                            """Return current fill rule.
                                                                                                                                                                                                        
                                                                                                                                                                                                            Returns:
                                                                                                                                                                                                                fill rule
                                                                                                                                                                                                            """
                                                                                                                                                                                                            return constants.FILL_RULE.inverse[self.fillRule()]
                                                                                                                                                                                                        

                                                                                                                                                                                                        set_fill_rule(rule: constants.FillRuleStr | constants.FillRule)

                                                                                                                                                                                                        Set fill rule.

                                                                                                                                                                                                        Parameters:

                                                                                                                                                                                                        Name Type Description Default
                                                                                                                                                                                                        rule FillRuleStr | FillRule

                                                                                                                                                                                                        fill rule to use

                                                                                                                                                                                                        required
                                                                                                                                                                                                        Source code in prettyqt/gui/painterpath.py
                                                                                                                                                                                                        def set_fill_rule(self, rule: constants.FillRuleStr | constants.FillRule):
                                                                                                                                                                                                            """Set fill rule.
                                                                                                                                                                                                        
                                                                                                                                                                                                            Args:
                                                                                                                                                                                                                rule: fill rule to use
                                                                                                                                                                                                            """
                                                                                                                                                                                                            self.setFillRule(constants.FILL_RULE.get_enum_value(rule))
                                                                                                                                                                                                        

                                                                                                                                                                                                        PainterPathStroker

                                                                                                                                                                                                        Bases: QPainterPathStroker

                                                                                                                                                                                                        Source code in prettyqt/gui/painterpathstroker.py
                                                                                                                                                                                                        class PainterPathStroker(gui.QPainterPathStroker):
                                                                                                                                                                                                            def set_cap_style(self, style: constants.CapStyleStr | constants.PenCapStyle):
                                                                                                                                                                                                                """Set cap style to use.
                                                                                                                                                                                                        
                                                                                                                                                                                                                Args:
                                                                                                                                                                                                                    style: cap style to use
                                                                                                                                                                                                                """
                                                                                                                                                                                                                self.setCapStyle(constants.CAP_STYLE.get_enum_value(style))
                                                                                                                                                                                                        
                                                                                                                                                                                                            def get_cap_style(self) -> constants.CapStyleStr | constants.PenCapStyle:
                                                                                                                                                                                                                """Return current cap style.
                                                                                                                                                                                                        
                                                                                                                                                                                                                Returns:
                                                                                                                                                                                                                    cap style
                                                                                                                                                                                                                """
                                                                                                                                                                                                                return constants.CAP_STYLE.inverse[self.capStyle()]
                                                                                                                                                                                                        
                                                                                                                                                                                                            def set_join_style(self, style: constants.JoinStyleStr | constants.PenJoinStyle):
                                                                                                                                                                                                                """Set join style to use.
                                                                                                                                                                                                        
                                                                                                                                                                                                                Args:
                                                                                                                                                                                                                    style: join style to use
                                                                                                                                                                                                                """
                                                                                                                                                                                                                self.setJoinStyle(constants.JOIN_STYLE.get_enum_value(style))
                                                                                                                                                                                                        
                                                                                                                                                                                                            def get_join_style(self) -> constants.JoinStyleStr:
                                                                                                                                                                                                                """Return current join style.
                                                                                                                                                                                                        
                                                                                                                                                                                                                Returns:
                                                                                                                                                                                                                    join style
                                                                                                                                                                                                                """
                                                                                                                                                                                                                return constants.JOIN_STYLE.inverse[self.joinStyle()]
                                                                                                                                                                                                        
                                                                                                                                                                                                            def create_stroke(self, path: gui.QPainterPath) -> gui.PainterPath:
                                                                                                                                                                                                                return gui.PainterPath(self.createStroke(path))
                                                                                                                                                                                                        

                                                                                                                                                                                                        get_cap_style() -> constants.CapStyleStr | constants.PenCapStyle

                                                                                                                                                                                                        Return current cap style.

                                                                                                                                                                                                        Source code in prettyqt/gui/painterpathstroker.py
                                                                                                                                                                                                        def get_cap_style(self) -> constants.CapStyleStr | constants.PenCapStyle:
                                                                                                                                                                                                            """Return current cap style.
                                                                                                                                                                                                        
                                                                                                                                                                                                            Returns:
                                                                                                                                                                                                                cap style
                                                                                                                                                                                                            """
                                                                                                                                                                                                            return constants.CAP_STYLE.inverse[self.capStyle()]
                                                                                                                                                                                                        

                                                                                                                                                                                                        get_join_style() -> constants.JoinStyleStr

                                                                                                                                                                                                        Return current join style.

                                                                                                                                                                                                        Source code in prettyqt/gui/painterpathstroker.py
                                                                                                                                                                                                        def get_join_style(self) -> constants.JoinStyleStr:
                                                                                                                                                                                                            """Return current join style.
                                                                                                                                                                                                        
                                                                                                                                                                                                            Returns:
                                                                                                                                                                                                                join style
                                                                                                                                                                                                            """
                                                                                                                                                                                                            return constants.JOIN_STYLE.inverse[self.joinStyle()]
                                                                                                                                                                                                        

                                                                                                                                                                                                        set_cap_style(style: constants.CapStyleStr | constants.PenCapStyle)

                                                                                                                                                                                                        Set cap style to use.

                                                                                                                                                                                                        Parameters:

                                                                                                                                                                                                        Name Type Description Default
                                                                                                                                                                                                        style CapStyleStr | PenCapStyle

                                                                                                                                                                                                        cap style to use

                                                                                                                                                                                                        required
                                                                                                                                                                                                        Source code in prettyqt/gui/painterpathstroker.py
                                                                                                                                                                                                        def set_cap_style(self, style: constants.CapStyleStr | constants.PenCapStyle):
                                                                                                                                                                                                            """Set cap style to use.
                                                                                                                                                                                                        
                                                                                                                                                                                                            Args:
                                                                                                                                                                                                                style: cap style to use
                                                                                                                                                                                                            """
                                                                                                                                                                                                            self.setCapStyle(constants.CAP_STYLE.get_enum_value(style))
                                                                                                                                                                                                        

                                                                                                                                                                                                        set_join_style(style: constants.JoinStyleStr | constants.PenJoinStyle)

                                                                                                                                                                                                        Set join style to use.

                                                                                                                                                                                                        Parameters:

                                                                                                                                                                                                        Name Type Description Default
                                                                                                                                                                                                        style JoinStyleStr | PenJoinStyle

                                                                                                                                                                                                        join style to use

                                                                                                                                                                                                        required
                                                                                                                                                                                                        Source code in prettyqt/gui/painterpathstroker.py
                                                                                                                                                                                                        def set_join_style(self, style: constants.JoinStyleStr | constants.PenJoinStyle):
                                                                                                                                                                                                            """Set join style to use.
                                                                                                                                                                                                        
                                                                                                                                                                                                            Args:
                                                                                                                                                                                                                style: join style to use
                                                                                                                                                                                                            """
                                                                                                                                                                                                            self.setJoinStyle(constants.JOIN_STYLE.get_enum_value(style))
                                                                                                                                                                                                        

                                                                                                                                                                                                        Palette

                                                                                                                                                                                                        Bases: SerializeMixin, QPalette

                                                                                                                                                                                                        Contains color groups for each widget state.

                                                                                                                                                                                                        Source code in prettyqt/gui/palette.py
                                                                                                                                                                                                        class Palette(serializemixin.SerializeMixin, gui.QPalette):
                                                                                                                                                                                                            """Contains color groups for each widget state."""
                                                                                                                                                                                                        
                                                                                                                                                                                                            def __getitem__(self, index: RoleStr | gui.QPalette.ColorRole) -> gui.Color:
                                                                                                                                                                                                                return self.get_color(index)
                                                                                                                                                                                                        
                                                                                                                                                                                                            def __setitem__(
                                                                                                                                                                                                                self, index: RoleStr | gui.QPalette.ColorRole, value: datatypes.ColorType
                                                                                                                                                                                                            ):
                                                                                                                                                                                                                self.set_color(index, value)
                                                                                                                                                                                                        
                                                                                                                                                                                                            def __repr__(self):
                                                                                                                                                                                                                return get_repr(self, self.get_color("button"), self.get_color("window"))
                                                                                                                                                                                                        
                                                                                                                                                                                                            def iter_colors(
                                                                                                                                                                                                                self, mode: Literal["auto", "auto_inverted", "dark", "light"] = "auto"
                                                                                                                                                                                                            ):
                                                                                                                                                                                                                if mode == "auto":
                                                                                                                                                                                                                    mode = "dark" if self.is_dark() else "light"
                                                                                                                                                                                                                elif mode == "auto_inverted":
                                                                                                                                                                                                                    mode = "light" if self.is_dark() else "dark"
                                                                                                                                                                                                                for color in gui.Color.colorNames():
                                                                                                                                                                                                                    c = gui.Color(color)
                                                                                                                                                                                                                    if (c.is_dark() and mode == "dark") or (not c.is_dark() and mode == "light"):
                                                                                                                                                                                                                        yield c.as_qt()
                                                                                                                                                                                                        
                                                                                                                                                                                                            def highlight_inactive(self, enable: bool = True):
                                                                                                                                                                                                                if enable:
                                                                                                                                                                                                                    color = self.color(self.ColorGroup.Active, self.ColorRole.Highlight)
                                                                                                                                                                                                                else:
                                                                                                                                                                                                                    pal = gui.Palette()
                                                                                                                                                                                                                    color = pal.color(self.ColorGroup.Inactive, self.ColorRole.Highlight)
                                                                                                                                                                                                                self.setColor(self.ColorGroup.Inactive, self.ColorRole.Highlight, color)
                                                                                                                                                                                                        
                                                                                                                                                                                                            def set_color(
                                                                                                                                                                                                                self,
                                                                                                                                                                                                                role: RoleStr | gui.QPalette.ColorRole,
                                                                                                                                                                                                                color: datatypes.ColorType,
                                                                                                                                                                                                                group: GroupStr | gui.QPalette.ColorGroup = "active",
                                                                                                                                                                                                            ):
                                                                                                                                                                                                                color = colors.get_color(color)
                                                                                                                                                                                                                self.setColor(GROUP.get_enum_value(group), ROLE.get_enum_value(role), color)
                                                                                                                                                                                                        
                                                                                                                                                                                                            def get_colors(
                                                                                                                                                                                                                self, group: GroupStr | gui.QPalette.ColorGroup = "active"
                                                                                                                                                                                                            ) -> dict[str, gui.Color]:
                                                                                                                                                                                                                return {k: self.get_color(k, group) for k in ROLE}
                                                                                                                                                                                                        
                                                                                                                                                                                                            def get_color(
                                                                                                                                                                                                                self,
                                                                                                                                                                                                                role: RoleStr | gui.QPalette.ColorRole,
                                                                                                                                                                                                                group: GroupStr | gui.QPalette.ColorGroup = "active",
                                                                                                                                                                                                            ) -> gui.Color:
                                                                                                                                                                                                                return gui.Color(
                                                                                                                                                                                                                    self.color(GROUP.get_enum_value(group), ROLE.get_enum_value(role))
                                                                                                                                                                                                                )
                                                                                                                                                                                                        
                                                                                                                                                                                                            def set_brush(
                                                                                                                                                                                                                self,
                                                                                                                                                                                                                role: RoleStr | gui.QPalette.ColorRole,
                                                                                                                                                                                                                brush: datatypes.ColorAndBrushType,
                                                                                                                                                                                                                group: GroupStr | gui.QPalette.ColorGroup = "active",
                                                                                                                                                                                                            ):
                                                                                                                                                                                                                if not isinstance(brush, gui.QBrush):
                                                                                                                                                                                                                    brush = gui.Brush(colors.get_color(brush))
                                                                                                                                                                                                                self.setBrush(GROUP.get_enum_value(group), ROLE.get_enum_value(role), brush)
                                                                                                                                                                                                        
                                                                                                                                                                                                            def get_brushes(
                                                                                                                                                                                                                self, group: GroupStr | gui.QPalette.ColorGroup = "active"
                                                                                                                                                                                                            ) -> dict[str, gui.Brush]:
                                                                                                                                                                                                                return {k: self.get_brush(k, group) for k in ROLE}
                                                                                                                                                                                                        
                                                                                                                                                                                                            def get_brush(
                                                                                                                                                                                                                self,
                                                                                                                                                                                                                role: RoleStr | gui.QPalette.ColorRole,
                                                                                                                                                                                                                group: GroupStr | gui.QPalette.ColorGroup = "active",
                                                                                                                                                                                                            ) -> gui.Brush:
                                                                                                                                                                                                                return gui.Brush(
                                                                                                                                                                                                                    self.brush(GROUP.get_enum_value(group), ROLE.get_enum_value(role))
                                                                                                                                                                                                                )
                                                                                                                                                                                                        
                                                                                                                                                                                                            def set_color_group(
                                                                                                                                                                                                                self,
                                                                                                                                                                                                                group: GroupStr | gui.QPalette.ColorGroup,
                                                                                                                                                                                                                window_text: gui.QBrush,
                                                                                                                                                                                                                button: gui.QBrush,
                                                                                                                                                                                                                light: gui.QBrush,
                                                                                                                                                                                                                dark: gui.QBrush,
                                                                                                                                                                                                                mid: gui.QBrush,
                                                                                                                                                                                                                text: gui.QBrush,
                                                                                                                                                                                                                bright_text: gui.QBrush,
                                                                                                                                                                                                                base: gui.QBrush,
                                                                                                                                                                                                                window: gui.QBrush,
                                                                                                                                                                                                            ):
                                                                                                                                                                                                                """Set the color group.
                                                                                                                                                                                                        
                                                                                                                                                                                                                Args:
                                                                                                                                                                                                                    group: color group to use
                                                                                                                                                                                                                    window_text: window text brush
                                                                                                                                                                                                                    button: button brush
                                                                                                                                                                                                                    light: light brush
                                                                                                                                                                                                                    dark: dark brush
                                                                                                                                                                                                                    mid: mid brush
                                                                                                                                                                                                                    text: text brush
                                                                                                                                                                                                                    bright_text: bright text brush
                                                                                                                                                                                                                    base: base brush
                                                                                                                                                                                                                    window: window brush
                                                                                                                                                                                                                """
                                                                                                                                                                                                                self.setColorGroup(
                                                                                                                                                                                                                    GROUP.get_enum_value(group),
                                                                                                                                                                                                                    window_text,
                                                                                                                                                                                                                    button,
                                                                                                                                                                                                                    light,
                                                                                                                                                                                                                    dark,
                                                                                                                                                                                                                    mid,
                                                                                                                                                                                                                    text,
                                                                                                                                                                                                                    bright_text,
                                                                                                                                                                                                                    base,
                                                                                                                                                                                                                    window,
                                                                                                                                                                                                                )
                                                                                                                                                                                                        
                                                                                                                                                                                                            def get_color_group(self) -> GroupStr:
                                                                                                                                                                                                                """Return color group.
                                                                                                                                                                                                        
                                                                                                                                                                                                                Returns:
                                                                                                                                                                                                                    color group
                                                                                                                                                                                                                """
                                                                                                                                                                                                                return GROUP.inverse[self.currentColorGroup()]
                                                                                                                                                                                                        
                                                                                                                                                                                                            def inverted(self) -> Self:
                                                                                                                                                                                                                pal = type(self)()
                                                                                                                                                                                                                for group in GROUP:
                                                                                                                                                                                                                    for role in ROLE:
                                                                                                                                                                                                                        color = self.get_color(role, group)
                                                                                                                                                                                                                        pal.set_color(role, color.inverted(), group)
                                                                                                                                                                                                                return pal
                                                                                                                                                                                                        
                                                                                                                                                                                                            @classmethod
                                                                                                                                                                                                            def create_dark_palette(cls) -> Self:
                                                                                                                                                                                                                pal = cls()
                                                                                                                                                                                                                pal.set_color("window", gui.Color(53, 53, 53))
                                                                                                                                                                                                                pal.set_color("window_text", "white")
                                                                                                                                                                                                                pal.set_color("window_text", "grey", group="disabled")
                                                                                                                                                                                                                pal.set_color("base", gui.Color(25, 25, 25))
                                                                                                                                                                                                                pal.set_color("alternate_base", gui.Color(53, 53, 53))
                                                                                                                                                                                                                pal.set_color("tool_tip_base", "slategrey")
                                                                                                                                                                                                                pal.set_color("tool_tip_base", "slategrey", group="inactive")
                                                                                                                                                                                                                pal.set_color("tool_tip_text", "white")
                                                                                                                                                                                                                pal.set_color("tool_tip_text", "white", group="inactive")
                                                                                                                                                                                                                pal.set_color("text", "white")
                                                                                                                                                                                                                pal.set_color("text", "grey", group="disabled")
                                                                                                                                                                                                                pal.set_color("button", gui.Color(53, 53, 53))
                                                                                                                                                                                                                pal.set_color("button_text", "white")
                                                                                                                                                                                                                pal.set_color("button_text", "grey", group="disabled")
                                                                                                                                                                                                                pal.set_color("bright_text", "red")
                                                                                                                                                                                                                pal.set_color("link", "dodgerblue")
                                                                                                                                                                                                                pal.set_color("highlight", "dodgerblue")
                                                                                                                                                                                                                pal.set_color("highlight", gui.Color(80, 80, 80), group="disabled")
                                                                                                                                                                                                                pal.set_color("highlighted_text", "black")
                                                                                                                                                                                                                pal.set_color("highlighted_text", "grey", group="disabled")
                                                                                                                                                                                                                return pal
                                                                                                                                                                                                        
                                                                                                                                                                                                            def is_dark(self) -> bool:
                                                                                                                                                                                                                col = self.color(self.ColorRole.Window)
                                                                                                                                                                                                                return max(col.red(), col.green(), col.blue()) < 115  # noqa: PLR2004
                                                                                                                                                                                                        

                                                                                                                                                                                                        get_color_group() -> GroupStr

                                                                                                                                                                                                        Return color group.

                                                                                                                                                                                                        Source code in prettyqt/gui/palette.py
                                                                                                                                                                                                        def get_color_group(self) -> GroupStr:
                                                                                                                                                                                                            """Return color group.
                                                                                                                                                                                                        
                                                                                                                                                                                                            Returns:
                                                                                                                                                                                                                color group
                                                                                                                                                                                                            """
                                                                                                                                                                                                            return GROUP.inverse[self.currentColorGroup()]
                                                                                                                                                                                                        

                                                                                                                                                                                                        set_color_group(group: GroupStr | gui.QPalette.ColorGroup, window_text: gui.QBrush, button: gui.QBrush, light: gui.QBrush, dark: gui.QBrush, mid: gui.QBrush, text: gui.QBrush, bright_text: gui.QBrush, base: gui.QBrush, window: gui.QBrush)

                                                                                                                                                                                                        Set the color group.

                                                                                                                                                                                                        Parameters:

                                                                                                                                                                                                        Name Type Description Default
                                                                                                                                                                                                        group GroupStr | ColorGroup

                                                                                                                                                                                                        color group to use

                                                                                                                                                                                                        required
                                                                                                                                                                                                        window_text QBrush

                                                                                                                                                                                                        window text brush

                                                                                                                                                                                                        required
                                                                                                                                                                                                        button QBrush

                                                                                                                                                                                                        button brush

                                                                                                                                                                                                        required
                                                                                                                                                                                                        light QBrush

                                                                                                                                                                                                        light brush

                                                                                                                                                                                                        required
                                                                                                                                                                                                        dark QBrush

                                                                                                                                                                                                        dark brush

                                                                                                                                                                                                        required
                                                                                                                                                                                                        mid QBrush

                                                                                                                                                                                                        mid brush

                                                                                                                                                                                                        required
                                                                                                                                                                                                        text QBrush

                                                                                                                                                                                                        text brush

                                                                                                                                                                                                        required
                                                                                                                                                                                                        bright_text QBrush

                                                                                                                                                                                                        bright text brush

                                                                                                                                                                                                        required
                                                                                                                                                                                                        base QBrush

                                                                                                                                                                                                        base brush

                                                                                                                                                                                                        required
                                                                                                                                                                                                        window QBrush

                                                                                                                                                                                                        window brush

                                                                                                                                                                                                        required
                                                                                                                                                                                                        Source code in prettyqt/gui/palette.py
                                                                                                                                                                                                        def set_color_group(
                                                                                                                                                                                                            self,
                                                                                                                                                                                                            group: GroupStr | gui.QPalette.ColorGroup,
                                                                                                                                                                                                            window_text: gui.QBrush,
                                                                                                                                                                                                            button: gui.QBrush,
                                                                                                                                                                                                            light: gui.QBrush,
                                                                                                                                                                                                            dark: gui.QBrush,
                                                                                                                                                                                                            mid: gui.QBrush,
                                                                                                                                                                                                            text: gui.QBrush,
                                                                                                                                                                                                            bright_text: gui.QBrush,
                                                                                                                                                                                                            base: gui.QBrush,
                                                                                                                                                                                                            window: gui.QBrush,
                                                                                                                                                                                                        ):
                                                                                                                                                                                                            """Set the color group.
                                                                                                                                                                                                        
                                                                                                                                                                                                            Args:
                                                                                                                                                                                                                group: color group to use
                                                                                                                                                                                                                window_text: window text brush
                                                                                                                                                                                                                button: button brush
                                                                                                                                                                                                                light: light brush
                                                                                                                                                                                                                dark: dark brush
                                                                                                                                                                                                                mid: mid brush
                                                                                                                                                                                                                text: text brush
                                                                                                                                                                                                                bright_text: bright text brush
                                                                                                                                                                                                                base: base brush
                                                                                                                                                                                                                window: window brush
                                                                                                                                                                                                            """
                                                                                                                                                                                                            self.setColorGroup(
                                                                                                                                                                                                                GROUP.get_enum_value(group),
                                                                                                                                                                                                                window_text,
                                                                                                                                                                                                                button,
                                                                                                                                                                                                                light,
                                                                                                                                                                                                                dark,
                                                                                                                                                                                                                mid,
                                                                                                                                                                                                                text,
                                                                                                                                                                                                                bright_text,
                                                                                                                                                                                                                base,
                                                                                                                                                                                                                window,
                                                                                                                                                                                                            )
                                                                                                                                                                                                        

                                                                                                                                                                                                        PdfOutputIntent

                                                                                                                                                                                                        Bases: QPdfOutputIntent

                                                                                                                                                                                                        Metadata describing the color reproduction characteristics of a PDF document.

                                                                                                                                                                                                        Source code in prettyqt/gui/pdfoutputintent.py
                                                                                                                                                                                                        class PdfOutputIntent(QtGui.QPdfOutputIntent):
                                                                                                                                                                                                            """Metadata describing the color reproduction characteristics of a PDF document."""
                                                                                                                                                                                                        
                                                                                                                                                                                                            def __repr__(self):
                                                                                                                                                                                                                return get_repr(self, self.outputConditionIdentifier())
                                                                                                                                                                                                        
                                                                                                                                                                                                            def get_registry_name(self) -> core.Url:
                                                                                                                                                                                                                """Return the registry name URL."""
                                                                                                                                                                                                                return core.Url(self.registryName())
                                                                                                                                                                                                        
                                                                                                                                                                                                            def set_registry_name(self, url: datatypes.UrlType):
                                                                                                                                                                                                                """Set the registry name URL."""
                                                                                                                                                                                                                self.setRegistryName(datatypes.to_url(url))
                                                                                                                                                                                                        
                                                                                                                                                                                                            def get_output_profile(self) -> gui.ColorSpace:
                                                                                                                                                                                                                """Return the output color space profile."""
                                                                                                                                                                                                                return gui.ColorSpace(self.outputProfile())
                                                                                                                                                                                                        

                                                                                                                                                                                                        get_output_profile() -> gui.ColorSpace

                                                                                                                                                                                                        Return the output color space profile.

                                                                                                                                                                                                        Source code in prettyqt/gui/pdfoutputintent.py
                                                                                                                                                                                                        def get_output_profile(self) -> gui.ColorSpace:
                                                                                                                                                                                                            """Return the output color space profile."""
                                                                                                                                                                                                            return gui.ColorSpace(self.outputProfile())
                                                                                                                                                                                                        

                                                                                                                                                                                                        get_registry_name() -> core.Url

                                                                                                                                                                                                        Return the registry name URL.

                                                                                                                                                                                                        Source code in prettyqt/gui/pdfoutputintent.py
                                                                                                                                                                                                        def get_registry_name(self) -> core.Url:
                                                                                                                                                                                                            """Return the registry name URL."""
                                                                                                                                                                                                            return core.Url(self.registryName())
                                                                                                                                                                                                        

                                                                                                                                                                                                        set_registry_name(url: datatypes.UrlType)

                                                                                                                                                                                                        Set the registry name URL.

                                                                                                                                                                                                        Source code in prettyqt/gui/pdfoutputintent.py
                                                                                                                                                                                                        def set_registry_name(self, url: datatypes.UrlType):
                                                                                                                                                                                                            """Set the registry name URL."""
                                                                                                                                                                                                            self.setRegistryName(datatypes.to_url(url))
                                                                                                                                                                                                        

                                                                                                                                                                                                        PdfWriter

                                                                                                                                                                                                        Bases: ObjectMixin, PagedPaintDeviceMixin, QPdfWriter

                                                                                                                                                                                                        Class to generate PDFs that can be used as a paint device.

                                                                                                                                                                                                        Source code in prettyqt/gui/pdfwriter.py
                                                                                                                                                                                                        class PdfWriter(core.ObjectMixin, gui.PagedPaintDeviceMixin, gui.QPdfWriter):
                                                                                                                                                                                                            """Class to generate PDFs that can be used as a paint device."""
                                                                                                                                                                                                        
                                                                                                                                                                                                            def get_color_model(self) -> ColorModelStr:
                                                                                                                                                                                                                return COLOR_MODEL.inverse[self.colorModel()]
                                                                                                                                                                                                        
                                                                                                                                                                                                            def set_color_model(self, model: ColorModelStr | gui.QPdfWriter.ColorModel):
                                                                                                                                                                                                                self.setColorModel(COLOR_MODEL.get_enum_value(model))
                                                                                                                                                                                                        
                                                                                                                                                                                                            def set_desktop_resolution(self):
                                                                                                                                                                                                                primary = gui.app().primaryScreen()
                                                                                                                                                                                                                dpi = primary.logicalDotsPerInch()
                                                                                                                                                                                                                self.setResolution(int(dpi))
                                                                                                                                                                                                        
                                                                                                                                                                                                            def set_page_margins(
                                                                                                                                                                                                                self,
                                                                                                                                                                                                                margins: datatypes.MarginsFType,
                                                                                                                                                                                                                unit: gui.pagelayout.UnitStr | gui.PageLayout.Unit | None = None,
                                                                                                                                                                                                            ) -> bool:
                                                                                                                                                                                                                margins = datatypes.to_marginsf(margins)
                                                                                                                                                                                                                if unit is None:
                                                                                                                                                                                                                    return self.setPageMargins(margins)
                                                                                                                                                                                                                return self.setPageMargins(margins, gui.pagelayout.UNITS.get_enum_value(unit))
                                                                                                                                                                                                        
                                                                                                                                                                                                            def get_pdf_version(self) -> gui.pagedpaintdevice.PdfVersionStr:
                                                                                                                                                                                                                return gui.pagedpaintdevice.PDF_VERSION.inverse[self.pdfVersion()]
                                                                                                                                                                                                        
                                                                                                                                                                                                            def set_pdf_version(
                                                                                                                                                                                                                self,
                                                                                                                                                                                                                version: gui.pagedpaintdevice.PdfVersionStr | gui.PagedPaintDevice.PdfVersion,
                                                                                                                                                                                                            ):
                                                                                                                                                                                                                """Set pdf version.
                                                                                                                                                                                                        
                                                                                                                                                                                                                Args:
                                                                                                                                                                                                                    version: pdf version
                                                                                                                                                                                                                """
                                                                                                                                                                                                                self.setPdfVersion(gui.pagedpaintdevice.PDF_VERSION.get_enum_value(version))
                                                                                                                                                                                                        

                                                                                                                                                                                                        set_pdf_version(version: gui.pagedpaintdevice.PdfVersionStr | gui.PagedPaintDevice.PdfVersion)

                                                                                                                                                                                                        Set pdf version.

                                                                                                                                                                                                        Parameters:

                                                                                                                                                                                                        Name Type Description Default
                                                                                                                                                                                                        version PdfVersionStr | PdfVersion

                                                                                                                                                                                                        pdf version

                                                                                                                                                                                                        required
                                                                                                                                                                                                        Source code in prettyqt/gui/pdfwriter.py
                                                                                                                                                                                                        def set_pdf_version(
                                                                                                                                                                                                            self,
                                                                                                                                                                                                            version: gui.pagedpaintdevice.PdfVersionStr | gui.PagedPaintDevice.PdfVersion,
                                                                                                                                                                                                        ):
                                                                                                                                                                                                            """Set pdf version.
                                                                                                                                                                                                        
                                                                                                                                                                                                            Args:
                                                                                                                                                                                                                version: pdf version
                                                                                                                                                                                                            """
                                                                                                                                                                                                            self.setPdfVersion(gui.pagedpaintdevice.PDF_VERSION.get_enum_value(version))
                                                                                                                                                                                                        

                                                                                                                                                                                                        Pen

                                                                                                                                                                                                        Bases: SerializeMixin, QPen

                                                                                                                                                                                                        Defines how a QPainter should draw lines and outlines of shapes.

                                                                                                                                                                                                        Source code in prettyqt/gui/pen.py
                                                                                                                                                                                                        class Pen(serializemixin.SerializeMixin, gui.QPen):
                                                                                                                                                                                                            """Defines how a QPainter should draw lines and outlines of shapes."""
                                                                                                                                                                                                        
                                                                                                                                                                                                            def __repr__(self):
                                                                                                                                                                                                                return get_repr(self, self.get_color())
                                                                                                                                                                                                        
                                                                                                                                                                                                            def set_color(self, color: datatypes.ColorType):
                                                                                                                                                                                                                color = colors.get_color(color)
                                                                                                                                                                                                                self.setColor(color)
                                                                                                                                                                                                        
                                                                                                                                                                                                            def get_color(self) -> gui.Color:
                                                                                                                                                                                                                return gui.Color(self.color())
                                                                                                                                                                                                        
                                                                                                                                                                                                            def get_brush(self) -> gui.Brush:
                                                                                                                                                                                                                return gui.Brush(self.brush())
                                                                                                                                                                                                        
                                                                                                                                                                                                            def set_cap_style(self, style: constants.CapStyleStr | constants.PenCapStyle):
                                                                                                                                                                                                                """Set cap style to use.
                                                                                                                                                                                                        
                                                                                                                                                                                                                Args:
                                                                                                                                                                                                                    style: cap style to use
                                                                                                                                                                                                                """
                                                                                                                                                                                                                self.setCapStyle(constants.CAP_STYLE.get_enum_value(style))
                                                                                                                                                                                                        
                                                                                                                                                                                                            def get_cap_style(self) -> constants.CapStyleStr:
                                                                                                                                                                                                                """Return current cap style.
                                                                                                                                                                                                        
                                                                                                                                                                                                                Returns:
                                                                                                                                                                                                                    cap style
                                                                                                                                                                                                                """
                                                                                                                                                                                                                return constants.CAP_STYLE.inverse[self.capStyle()]
                                                                                                                                                                                                        
                                                                                                                                                                                                            def set_join_style(self, style: constants.JoinStyleStr | constants.PenJoinStyle):
                                                                                                                                                                                                                """Set join style to use.
                                                                                                                                                                                                        
                                                                                                                                                                                                                Args:
                                                                                                                                                                                                                    style: join style to use
                                                                                                                                                                                                                """
                                                                                                                                                                                                                self.setJoinStyle(constants.JOIN_STYLE.get_enum_value(style))
                                                                                                                                                                                                        
                                                                                                                                                                                                            def get_join_style(self) -> constants.JoinStyleStr:
                                                                                                                                                                                                                """Return current join style.
                                                                                                                                                                                                        
                                                                                                                                                                                                                Returns:
                                                                                                                                                                                                                    join style
                                                                                                                                                                                                                """
                                                                                                                                                                                                                return constants.JOIN_STYLE.inverse[self.joinStyle()]
                                                                                                                                                                                                        
                                                                                                                                                                                                            def set_style(
                                                                                                                                                                                                                self, style: constants.PenStyleStr | constants.PenStyle | list[float] | None
                                                                                                                                                                                                            ):
                                                                                                                                                                                                                """Set pen style to use.
                                                                                                                                                                                                        
                                                                                                                                                                                                                Args:
                                                                                                                                                                                                                    style: pen style to use
                                                                                                                                                                                                                """
                                                                                                                                                                                                                if isinstance(style, list):
                                                                                                                                                                                                                    self.setDashPattern(style)
                                                                                                                                                                                                                else:
                                                                                                                                                                                                                    if style is None:
                                                                                                                                                                                                                        style = "none"
                                                                                                                                                                                                                    self.setStyle(constants.PEN_STYLE.get_enum_value(style))
                                                                                                                                                                                                        
                                                                                                                                                                                                            def get_style(self) -> constants.PenStyleStr:
                                                                                                                                                                                                                """Return current pen style.
                                                                                                                                                                                                        
                                                                                                                                                                                                                Returns:
                                                                                                                                                                                                                    pen style
                                                                                                                                                                                                                """
                                                                                                                                                                                                                return constants.PEN_STYLE.inverse[self.style()]
                                                                                                                                                                                                        

                                                                                                                                                                                                        get_cap_style() -> constants.CapStyleStr

                                                                                                                                                                                                        Return current cap style.

                                                                                                                                                                                                        Source code in prettyqt/gui/pen.py
                                                                                                                                                                                                        def get_cap_style(self) -> constants.CapStyleStr:
                                                                                                                                                                                                            """Return current cap style.
                                                                                                                                                                                                        
                                                                                                                                                                                                            Returns:
                                                                                                                                                                                                                cap style
                                                                                                                                                                                                            """
                                                                                                                                                                                                            return constants.CAP_STYLE.inverse[self.capStyle()]
                                                                                                                                                                                                        

                                                                                                                                                                                                        get_join_style() -> constants.JoinStyleStr

                                                                                                                                                                                                        Return current join style.

                                                                                                                                                                                                        Source code in prettyqt/gui/pen.py
                                                                                                                                                                                                        def get_join_style(self) -> constants.JoinStyleStr:
                                                                                                                                                                                                            """Return current join style.
                                                                                                                                                                                                        
                                                                                                                                                                                                            Returns:
                                                                                                                                                                                                                join style
                                                                                                                                                                                                            """
                                                                                                                                                                                                            return constants.JOIN_STYLE.inverse[self.joinStyle()]
                                                                                                                                                                                                        

                                                                                                                                                                                                        get_style() -> constants.PenStyleStr

                                                                                                                                                                                                        Return current pen style.

                                                                                                                                                                                                        Source code in prettyqt/gui/pen.py
                                                                                                                                                                                                        def get_style(self) -> constants.PenStyleStr:
                                                                                                                                                                                                            """Return current pen style.
                                                                                                                                                                                                        
                                                                                                                                                                                                            Returns:
                                                                                                                                                                                                                pen style
                                                                                                                                                                                                            """
                                                                                                                                                                                                            return constants.PEN_STYLE.inverse[self.style()]
                                                                                                                                                                                                        

                                                                                                                                                                                                        set_cap_style(style: constants.CapStyleStr | constants.PenCapStyle)

                                                                                                                                                                                                        Set cap style to use.

                                                                                                                                                                                                        Parameters:

                                                                                                                                                                                                        Name Type Description Default
                                                                                                                                                                                                        style CapStyleStr | PenCapStyle

                                                                                                                                                                                                        cap style to use

                                                                                                                                                                                                        required
                                                                                                                                                                                                        Source code in prettyqt/gui/pen.py
                                                                                                                                                                                                        def set_cap_style(self, style: constants.CapStyleStr | constants.PenCapStyle):
                                                                                                                                                                                                            """Set cap style to use.
                                                                                                                                                                                                        
                                                                                                                                                                                                            Args:
                                                                                                                                                                                                                style: cap style to use
                                                                                                                                                                                                            """
                                                                                                                                                                                                            self.setCapStyle(constants.CAP_STYLE.get_enum_value(style))
                                                                                                                                                                                                        

                                                                                                                                                                                                        set_join_style(style: constants.JoinStyleStr | constants.PenJoinStyle)

                                                                                                                                                                                                        Set join style to use.

                                                                                                                                                                                                        Parameters:

                                                                                                                                                                                                        Name Type Description Default
                                                                                                                                                                                                        style JoinStyleStr | PenJoinStyle

                                                                                                                                                                                                        join style to use

                                                                                                                                                                                                        required
                                                                                                                                                                                                        Source code in prettyqt/gui/pen.py
                                                                                                                                                                                                        def set_join_style(self, style: constants.JoinStyleStr | constants.PenJoinStyle):
                                                                                                                                                                                                            """Set join style to use.
                                                                                                                                                                                                        
                                                                                                                                                                                                            Args:
                                                                                                                                                                                                                style: join style to use
                                                                                                                                                                                                            """
                                                                                                                                                                                                            self.setJoinStyle(constants.JOIN_STYLE.get_enum_value(style))
                                                                                                                                                                                                        

                                                                                                                                                                                                        set_style(style: constants.PenStyleStr | constants.PenStyle | list[float] | None)

                                                                                                                                                                                                        Set pen style to use.

                                                                                                                                                                                                        Parameters:

                                                                                                                                                                                                        Name Type Description Default
                                                                                                                                                                                                        style PenStyleStr | PenStyle | list[float] | None

                                                                                                                                                                                                        pen style to use

                                                                                                                                                                                                        required
                                                                                                                                                                                                        Source code in prettyqt/gui/pen.py
                                                                                                                                                                                                        def set_style(
                                                                                                                                                                                                            self, style: constants.PenStyleStr | constants.PenStyle | list[float] | None
                                                                                                                                                                                                        ):
                                                                                                                                                                                                            """Set pen style to use.
                                                                                                                                                                                                        
                                                                                                                                                                                                            Args:
                                                                                                                                                                                                                style: pen style to use
                                                                                                                                                                                                            """
                                                                                                                                                                                                            if isinstance(style, list):
                                                                                                                                                                                                                self.setDashPattern(style)
                                                                                                                                                                                                            else:
                                                                                                                                                                                                                if style is None:
                                                                                                                                                                                                                    style = "none"
                                                                                                                                                                                                                self.setStyle(constants.PEN_STYLE.get_enum_value(style))
                                                                                                                                                                                                        

                                                                                                                                                                                                        Picture

                                                                                                                                                                                                        Bases: SerializeMixin, PaintDeviceMixin, QPicture

                                                                                                                                                                                                        Paint device that records and replays QPainter commands.

                                                                                                                                                                                                        Source code in prettyqt/gui/picture.py
                                                                                                                                                                                                        class Picture(serializemixin.SerializeMixin, gui.PaintDeviceMixin, gui.QPicture):
                                                                                                                                                                                                            """Paint device that records and replays QPainter commands."""
                                                                                                                                                                                                        

                                                                                                                                                                                                        PixmapCache

                                                                                                                                                                                                        Bases: QPixmapCache

                                                                                                                                                                                                        Application-wide cache for pixmaps.

                                                                                                                                                                                                        Source code in prettyqt/gui/pixmapcache.py
                                                                                                                                                                                                        class PixmapCache(QtGui.QPixmapCache):
                                                                                                                                                                                                            """Application-wide cache for pixmaps."""
                                                                                                                                                                                                        
                                                                                                                                                                                                            def __setitem__(self, key: str, value: QtGui.QPixmap):
                                                                                                                                                                                                                self.insert(key, value)
                                                                                                                                                                                                        
                                                                                                                                                                                                            def __getitem__(self, key: str) -> QtGui.QPixmap | None:
                                                                                                                                                                                                                return self.find(key)
                                                                                                                                                                                                        
                                                                                                                                                                                                            def __delitem__(self, key: str):
                                                                                                                                                                                                                self.remove(key)
                                                                                                                                                                                                        

                                                                                                                                                                                                        PixmapMixin

                                                                                                                                                                                                        Bases: SerializeMixin, PaintDeviceMixin, _PixmapBase

                                                                                                                                                                                                        Off-screen image representation that can be used as a paint device.

                                                                                                                                                                                                        Source code in prettyqt/gui/pixmap.py
                                                                                                                                                                                                        class PixmapMixin(serializemixin.SerializeMixin, gui.PaintDeviceMixin, _PixmapBase):
                                                                                                                                                                                                            """Off-screen image representation that can be used as a paint device."""
                                                                                                                                                                                                        
                                                                                                                                                                                                            def __bool__(self):
                                                                                                                                                                                                                return not self.isNull()
                                                                                                                                                                                                        
                                                                                                                                                                                                            def __eq__(self, other):
                                                                                                                                                                                                                return (
                                                                                                                                                                                                                    self.toImage() == other.toImage() if isinstance(other, gui.QPixmap) else False
                                                                                                                                                                                                                )
                                                                                                                                                                                                        
                                                                                                                                                                                                            def __hash__(self):
                                                                                                                                                                                                                return self.cacheKey()
                                                                                                                                                                                                        
                                                                                                                                                                                                            @classmethod
                                                                                                                                                                                                            def from_file(cls, path: datatypes.PathType) -> Self:
                                                                                                                                                                                                                path = pathlib.Path(path)
                                                                                                                                                                                                                with path.open(mode="rb") as f:
                                                                                                                                                                                                                    data = f.read()
                                                                                                                                                                                                                # Create widget
                                                                                                                                                                                                                pixmap = cls()
                                                                                                                                                                                                                pixmap.loadFromData(core.QByteArray(data))
                                                                                                                                                                                                                return pixmap
                                                                                                                                                                                                        
                                                                                                                                                                                                            @classmethod
                                                                                                                                                                                                            def from_image(
                                                                                                                                                                                                                cls,
                                                                                                                                                                                                                img: gui.QImage,
                                                                                                                                                                                                                color_preference: constants.ColorPreferenceStr = "auto",
                                                                                                                                                                                                                dithering: constants.DitherPreferenceStr = "diffuse",
                                                                                                                                                                                                                alpha_dithering: constants.AlphaDitherPreferenceStr = "threshold",
                                                                                                                                                                                                                mode_preference: constants.ModePreferenceStr = "auto_dither",
                                                                                                                                                                                                            ) -> Self:
                                                                                                                                                                                                                flag = constants.COLOR_PREFERENCE[color_preference]
                                                                                                                                                                                                                flag |= constants.DITHER_PREFERENCE[dithering]
                                                                                                                                                                                                                flag |= constants.ALPHA_DITHER_PREFERENCE[alpha_dithering]
                                                                                                                                                                                                                flag |= constants.MODE_PREFERENCE[mode_preference]
                                                                                                                                                                                                                return cls(cls.fromImage(img, flag))
                                                                                                                                                                                                        
                                                                                                                                                                                                            def save_to_file(
                                                                                                                                                                                                                self,
                                                                                                                                                                                                                path: str | os.PathLike[str],
                                                                                                                                                                                                                fmt: str = "png",
                                                                                                                                                                                                                quality: int | None = None,
                                                                                                                                                                                                            ) -> bool:
                                                                                                                                                                                                                return self.save(os.fspath(path), fmt, -1 if quality is None else quality)
                                                                                                                                                                                                        
                                                                                                                                                                                                            def get_size(self) -> core.Size:
                                                                                                                                                                                                                return core.Size(self.size())
                                                                                                                                                                                                        
                                                                                                                                                                                                            def get_rect(self) -> core.Rect:
                                                                                                                                                                                                                return core.Rect(self.rect())
                                                                                                                                                                                                        
                                                                                                                                                                                                            def to_image(self) -> gui.Image:
                                                                                                                                                                                                                return gui.Image(self.toImage())
                                                                                                                                                                                                        
                                                                                                                                                                                                            def rotated(self, rotation: int) -> Self:
                                                                                                                                                                                                                w, h = self.width(), self.height()
                                                                                                                                                                                                                pixmap = self.transformed(gui.Transform().rotate(rotation))
                                                                                                                                                                                                                x, y = (pixmap.width() - w) // 2, (pixmap.height() - h) // 2
                                                                                                                                                                                                                return type(self)(pixmap.copy(x, y, w, h))
                                                                                                                                                                                                        
                                                                                                                                                                                                            def get_image_data_url(self) -> str:
                                                                                                                                                                                                                """Render the contents of the pixmap as a data URL (RFC-2397).
                                                                                                                                                                                                        
                                                                                                                                                                                                                Returns:
                                                                                                                                                                                                                    datauri : str
                                                                                                                                                                                                                """
                                                                                                                                                                                                                device = core.Buffer()
                                                                                                                                                                                                                assert device.open_file("read_write")
                                                                                                                                                                                                                self.save(device, "png")
                                                                                                                                                                                                                device.close()
                                                                                                                                                                                                                data = bytes(device.data().data())
                                                                                                                                                                                                                payload = base64.b64encode(data).decode("ascii")
                                                                                                                                                                                                                return f"data:image/png;base64,{payload}"
                                                                                                                                                                                                        
                                                                                                                                                                                                            @classmethod
                                                                                                                                                                                                            def create_dot(cls, color: datatypes.ColorType = "black", size: int = 16) -> Self:
                                                                                                                                                                                                                col = colors.get_color(color)
                                                                                                                                                                                                                px = cls(size, size)
                                                                                                                                                                                                                px.fill(constants.GlobalColor.transparent)
                                                                                                                                                                                                                px_size = px.rect().adjusted(1, 1, -1, -1)
                                                                                                                                                                                                                with gui.Painter(px) as painter:
                                                                                                                                                                                                                    painter.use_antialiasing()
                                                                                                                                                                                                                    painter.setBrush(col)
                                                                                                                                                                                                                    pen_color = gui.Color(15, 15, 15)
                                                                                                                                                                                                                    painter.set_pen(color=pen_color, width=1)
                                                                                                                                                                                                                    painter.drawEllipse(px_size)
                                                                                                                                                                                                                return px
                                                                                                                                                                                                        
                                                                                                                                                                                                            @classmethod
                                                                                                                                                                                                            def create_checkerboard_pattern(
                                                                                                                                                                                                                cls, n: int, color_1: datatypes.ColorType, color_2: datatypes.ColorType
                                                                                                                                                                                                            ) -> Self:
                                                                                                                                                                                                                """Construct tileable checkerboard pattern for paint events."""
                                                                                                                                                                                                                # Brush will be an nxn checkerboard pattern
                                                                                                                                                                                                                pat = cls(2 * n, 2 * n)
                                                                                                                                                                                                                bg0 = colors.get_color(color_1)
                                                                                                                                                                                                                bg1 = colors.get_color(color_2)
                                                                                                                                                                                                                with gui.Painter(pat) as p:
                                                                                                                                                                                                                    p.setPen(constants.PenStyle.NoPen)
                                                                                                                                                                                                                    # Paint a checkerboard pattern for the color to be overlaid on
                                                                                                                                                                                                                    p.fillRect(pat.rect(), bg0)
                                                                                                                                                                                                                    p.fillRect(0, 0, n, n, bg1)
                                                                                                                                                                                                                    p.fillRect(n, n, 2 * n, 2 * n, bg1)
                                                                                                                                                                                                                return pat
                                                                                                                                                                                                        
                                                                                                                                                                                                            @classmethod
                                                                                                                                                                                                            def create_char(
                                                                                                                                                                                                                cls,
                                                                                                                                                                                                                char: str,
                                                                                                                                                                                                                size: int,
                                                                                                                                                                                                                background: datatypes.ColorType = "black",
                                                                                                                                                                                                                color: datatypes.ColorType = "white",
                                                                                                                                                                                                            ) -> Self:
                                                                                                                                                                                                                pixmap = cls(size, size)
                                                                                                                                                                                                                pixmap.fill(constants.GlobalColor.transparent)
                                                                                                                                                                                                                with gui.Painter(pixmap) as painter:
                                                                                                                                                                                                                    painter.setRenderHints(
                                                                                                                                                                                                                        painter.RenderHint.Antialiasing
                                                                                                                                                                                                                        | painter.RenderHint.TextAntialiasing
                                                                                                                                                                                                                        | painter.RenderHint.SmoothPixmapTransform
                                                                                                                                                                                                                    )
                                                                                                                                                                                                                    painter.set_pen(color=background)
                                                                                                                                                                                                                    painter.set_brush(background)
                                                                                                                                                                                                                    margin = 1 + size // 16
                                                                                                                                                                                                                    text_margin = size // 20
                                                                                                                                                                                                                    w = size - 2 * margin
                                                                                                                                                                                                                    rect = core.RectF(margin, margin, w, w)
                                                                                                                                                                                                                    painter.draw_rounded_rect(rect, 30, 30, relative=True)
                                                                                                                                                                                                                    painter.set_pen(color=color)
                                                                                                                                                                                                                    with painter.edit_font() as font:  # type: gui.QFont
                                                                                                                                                                                                                        font.setPixelSize(size - 2 * margin - 2 * text_margin)
                                                                                                                                                                                                                    painter.draw_text(rect, char, alignment="center")
                                                                                                                                                                                                                return pixmap
                                                                                                                                                                                                        

                                                                                                                                                                                                        create_checkerboard_pattern(n: int, color_1: datatypes.ColorType, color_2: datatypes.ColorType) -> Self classmethod

                                                                                                                                                                                                        Construct tileable checkerboard pattern for paint events.

                                                                                                                                                                                                        Source code in prettyqt/gui/pixmap.py
                                                                                                                                                                                                        @classmethod
                                                                                                                                                                                                        def create_checkerboard_pattern(
                                                                                                                                                                                                            cls, n: int, color_1: datatypes.ColorType, color_2: datatypes.ColorType
                                                                                                                                                                                                        ) -> Self:
                                                                                                                                                                                                            """Construct tileable checkerboard pattern for paint events."""
                                                                                                                                                                                                            # Brush will be an nxn checkerboard pattern
                                                                                                                                                                                                            pat = cls(2 * n, 2 * n)
                                                                                                                                                                                                            bg0 = colors.get_color(color_1)
                                                                                                                                                                                                            bg1 = colors.get_color(color_2)
                                                                                                                                                                                                            with gui.Painter(pat) as p:
                                                                                                                                                                                                                p.setPen(constants.PenStyle.NoPen)
                                                                                                                                                                                                                # Paint a checkerboard pattern for the color to be overlaid on
                                                                                                                                                                                                                p.fillRect(pat.rect(), bg0)
                                                                                                                                                                                                                p.fillRect(0, 0, n, n, bg1)
                                                                                                                                                                                                                p.fillRect(n, n, 2 * n, 2 * n, bg1)
                                                                                                                                                                                                            return pat
                                                                                                                                                                                                        

                                                                                                                                                                                                        get_image_data_url() -> str

                                                                                                                                                                                                        Render the contents of the pixmap as a data URL (RFC-2397).

                                                                                                                                                                                                        Source code in prettyqt/gui/pixmap.py
                                                                                                                                                                                                        def get_image_data_url(self) -> str:
                                                                                                                                                                                                            """Render the contents of the pixmap as a data URL (RFC-2397).
                                                                                                                                                                                                        
                                                                                                                                                                                                            Returns:
                                                                                                                                                                                                                datauri : str
                                                                                                                                                                                                            """
                                                                                                                                                                                                            device = core.Buffer()
                                                                                                                                                                                                            assert device.open_file("read_write")
                                                                                                                                                                                                            self.save(device, "png")
                                                                                                                                                                                                            device.close()
                                                                                                                                                                                                            data = bytes(device.data().data())
                                                                                                                                                                                                            payload = base64.b64encode(data).decode("ascii")
                                                                                                                                                                                                            return f"data:image/png;base64,{payload}"
                                                                                                                                                                                                        

                                                                                                                                                                                                        Polygon

                                                                                                                                                                                                        Bases: SerializeMixin, QPolygon

                                                                                                                                                                                                        List of points using integer precision.

                                                                                                                                                                                                        Source code in prettyqt/gui/polygon.py
                                                                                                                                                                                                        class Polygon(serializemixin.SerializeMixin, QtGui.QPolygon):
                                                                                                                                                                                                            """List of points using integer precision."""
                                                                                                                                                                                                        
                                                                                                                                                                                                            def __repr__(self):
                                                                                                                                                                                                                return f"{type(self).__name__}(<{len(self)} points>)"
                                                                                                                                                                                                        
                                                                                                                                                                                                            def __iter__(self) -> Iterator[core.Point]:
                                                                                                                                                                                                                return iter(self.get_point(i) for i in range(self.size()))
                                                                                                                                                                                                        
                                                                                                                                                                                                            def __len__(self) -> int:
                                                                                                                                                                                                                return self.size()
                                                                                                                                                                                                        
                                                                                                                                                                                                            def __bool__(self):
                                                                                                                                                                                                                return not self.isEmpty()
                                                                                                                                                                                                        
                                                                                                                                                                                                            def __contains__(self, point: datatypes.PointType) -> bool:
                                                                                                                                                                                                                if isinstance(point, tuple):
                                                                                                                                                                                                                    point = core.Point(*point)
                                                                                                                                                                                                                return self.containsPoint(point, constants.FillRule.OddEvenFill)
                                                                                                                                                                                                        
                                                                                                                                                                                                            def __getitem__(self, index: int) -> core.Point:
                                                                                                                                                                                                                size = self.size()
                                                                                                                                                                                                                if index < 0:
                                                                                                                                                                                                                    index += size
                                                                                                                                                                                                                if index < 0 or index >= size:
                                                                                                                                                                                                                    raise IndexError(index)
                                                                                                                                                                                                                return self.get_point(index)
                                                                                                                                                                                                        
                                                                                                                                                                                                            def __setitem__(self, index: int, value: datatypes.PointType):
                                                                                                                                                                                                                p = core.Point(*value) if isinstance(value, tuple) else value
                                                                                                                                                                                                                # PySide6 workaround: setPoint does not exist
                                                                                                                                                                                                                self.remove(index)
                                                                                                                                                                                                                self.insert(index, p)
                                                                                                                                                                                                        
                                                                                                                                                                                                            def __sub__(self, other: QtGui.QPolygon) -> Polygon:
                                                                                                                                                                                                                return Polygon(self.subtracted(other))
                                                                                                                                                                                                        
                                                                                                                                                                                                            def __and__(self, other: QtGui.QPolygon) -> Polygon:  # &
                                                                                                                                                                                                                return Polygon(self.intersected(other))
                                                                                                                                                                                                        
                                                                                                                                                                                                            def __xor__(self, other: QtGui.QPolygon) -> Polygon:  # ^
                                                                                                                                                                                                                union = self | other
                                                                                                                                                                                                                intersect = self & other
                                                                                                                                                                                                                return union - intersect
                                                                                                                                                                                                        
                                                                                                                                                                                                            def __or__(self, other: QtGui.QPolygon) -> Polygon:  # |
                                                                                                                                                                                                                return Polygon(self.united(other))
                                                                                                                                                                                                        
                                                                                                                                                                                                            def get_point(self, index: int) -> core.Point:
                                                                                                                                                                                                                # PySide6 doesnt have self.point method
                                                                                                                                                                                                                return core.Point(self.value(index))
                                                                                                                                                                                                        
                                                                                                                                                                                                            def get_points(self) -> list[core.Point]:
                                                                                                                                                                                                                return [self.get_point(i) for i in range(self.size())]
                                                                                                                                                                                                        
                                                                                                                                                                                                            def add_points(self, *points: datatypes.PointType):
                                                                                                                                                                                                                for p in points:
                                                                                                                                                                                                                    point = core.Point(*p) if isinstance(p, tuple) else p
                                                                                                                                                                                                                    self.append(point)
                                                                                                                                                                                                        
                                                                                                                                                                                                            def get_data_buffer(self, size: int):
                                                                                                                                                                                                                self.resize(size)
                                                                                                                                                                                                                if API == "pyside6":
                                                                                                                                                                                                                    import shiboken6
                                                                                                                                                                                                        
                                                                                                                                                                                                                    address = shiboken6.getCppPointer(self.data())
                                                                                                                                                                                                                    buffer = (ctypes.c_int * 2 * self.size()).from_address(address[0])
                                                                                                                                                                                                                else:
                                                                                                                                                                                                                    buffer = self.data()
                                                                                                                                                                                                                    buffer.setsize(8 * self.size())  # ty: ignore[missing-attribute]  # sip.voidptr
                                                                                                                                                                                                                return buffer
                                                                                                                                                                                                        
                                                                                                                                                                                                            @classmethod
                                                                                                                                                                                                            def from_xy(cls, xdata, ydata) -> Self:
                                                                                                                                                                                                                import numpy as np
                                                                                                                                                                                                        
                                                                                                                                                                                                                size = len(xdata)
                                                                                                                                                                                                                polyline = cls()
                                                                                                                                                                                                                buffer = polyline.get_data_buffer(size)
                                                                                                                                                                                                                # QPoint is two 32-bit ints
                                                                                                                                                                                                                memory = np.frombuffer(buffer, np.int32)
                                                                                                                                                                                                                memory[: (size - 1) * 2 + 1 : 2] = np.asarray(xdata, dtype=np.int32)
                                                                                                                                                                                                                memory[1 : (size - 1) * 2 + 2 : 2] = np.asarray(ydata, dtype=np.int32)
                                                                                                                                                                                                                return polyline
                                                                                                                                                                                                        

                                                                                                                                                                                                        PolygonF

                                                                                                                                                                                                        Bases: SerializeMixin, QPolygonF

                                                                                                                                                                                                        List of points using floating point precision.

                                                                                                                                                                                                        Source code in prettyqt/gui/polygonf.py
                                                                                                                                                                                                        class PolygonF(serializemixin.SerializeMixin, gui.QPolygonF):
                                                                                                                                                                                                            """List of points using floating point precision."""
                                                                                                                                                                                                        
                                                                                                                                                                                                            def __repr__(self):
                                                                                                                                                                                                                return f"{type(self).__name__}(<{len(self)} points>)"
                                                                                                                                                                                                        
                                                                                                                                                                                                            def __iter__(self) -> Iterator[core.PointF]:
                                                                                                                                                                                                                return iter(self.get_point(i) for i in range(self.size()))
                                                                                                                                                                                                        
                                                                                                                                                                                                            def __len__(self) -> int:
                                                                                                                                                                                                                return self.size()
                                                                                                                                                                                                        
                                                                                                                                                                                                            def __bool__(self):
                                                                                                                                                                                                                return not self.isEmpty()
                                                                                                                                                                                                        
                                                                                                                                                                                                            def __contains__(self, point: datatypes.PointFType) -> bool:
                                                                                                                                                                                                                if isinstance(point, tuple):
                                                                                                                                                                                                                    point = core.PointF(*point)
                                                                                                                                                                                                                return self.containsPoint(point, constants.FillRule.OddEvenFill)
                                                                                                                                                                                                        
                                                                                                                                                                                                            def __getitem__(self, index: int) -> core.PointF:
                                                                                                                                                                                                                size = self.size()
                                                                                                                                                                                                                if index < 0:
                                                                                                                                                                                                                    index += size
                                                                                                                                                                                                                if index < 0 or index >= size:
                                                                                                                                                                                                                    raise IndexError(index)
                                                                                                                                                                                                                return self.get_point(index)
                                                                                                                                                                                                        
                                                                                                                                                                                                            # def __setitem__(self, index: int, value: datatypes.PointType):
                                                                                                                                                                                                            #     if isinstance(value, tuple):
                                                                                                                                                                                                            #         self.setPoint(index, *value)
                                                                                                                                                                                                            #     else:
                                                                                                                                                                                                            #         self.setPoint(index, value)
                                                                                                                                                                                                        
                                                                                                                                                                                                            def __sub__(self, other: gui.QPolygonF) -> Self:
                                                                                                                                                                                                                return type(self)(self.subtracted(other))
                                                                                                                                                                                                        
                                                                                                                                                                                                            def __and__(self, other: gui.QPolygonF) -> Self:  # &
                                                                                                                                                                                                                return type(self)(self.intersected(other))
                                                                                                                                                                                                        
                                                                                                                                                                                                            def __xor__(self, other: gui.QPolygonF) -> Self:  # ^
                                                                                                                                                                                                                union = self | other
                                                                                                                                                                                                                intersect = self & other
                                                                                                                                                                                                                return union - intersect
                                                                                                                                                                                                        
                                                                                                                                                                                                            def __or__(self, other: gui.QPolygonF) -> Self:  # |
                                                                                                                                                                                                                return type(self)(self.united(other))
                                                                                                                                                                                                        
                                                                                                                                                                                                            def __eq__(self, other: object) -> bool:
                                                                                                                                                                                                                return (
                                                                                                                                                                                                                    list(self) == [other.at(i) for i in range(other.size())]
                                                                                                                                                                                                                    if isinstance(other, type(self))
                                                                                                                                                                                                                    else False
                                                                                                                                                                                                                )
                                                                                                                                                                                                        
                                                                                                                                                                                                            def get_point(self, index: int) -> core.PointF:
                                                                                                                                                                                                                return core.PointF(self.at(index))
                                                                                                                                                                                                        
                                                                                                                                                                                                            def get_points(self) -> list[core.PointF]:
                                                                                                                                                                                                                return [self.get_point(i) for i in range(self.size())]
                                                                                                                                                                                                        
                                                                                                                                                                                                            def add_points(self, *points: datatypes.PointFType):
                                                                                                                                                                                                                for p in points:
                                                                                                                                                                                                                    self.append(datatypes.to_pointf(p))
                                                                                                                                                                                                        
                                                                                                                                                                                                            def to_polygon(self) -> gui.Polygon:
                                                                                                                                                                                                                return gui.Polygon(self.toPolygon())
                                                                                                                                                                                                        
                                                                                                                                                                                                            @classmethod
                                                                                                                                                                                                            def create_star(cls, scale: float = 1) -> Self:
                                                                                                                                                                                                                poly = cls()
                                                                                                                                                                                                                poly.append(core.PointF(0.5 * scale, 0.0))
                                                                                                                                                                                                                for i in range(1, 5):
                                                                                                                                                                                                                    val = 0.8 * i * math.pi
                                                                                                                                                                                                                    point = core.PointF(0.5 * scale * math.cos(val), 0.5 * scale * math.sin(val))
                                                                                                                                                                                                                    poly.append(point)
                                                                                                                                                                                                                return poly
                                                                                                                                                                                                        
                                                                                                                                                                                                            @classmethod
                                                                                                                                                                                                            def create_diamond(cls, scale: float = 1) -> Self:
                                                                                                                                                                                                                points = [
                                                                                                                                                                                                                    core.PointF(-0.1 * scale, 0.0),
                                                                                                                                                                                                                    core.PointF(0.0, -0.1 * scale),
                                                                                                                                                                                                                    core.PointF(0.1 * scale, 0.0),
                                                                                                                                                                                                                    core.PointF(0.0, 0.1 * scale),
                                                                                                                                                                                                                    core.PointF(-0.1 * scale, 0.0),
                                                                                                                                                                                                                ]
                                                                                                                                                                                                                poly = cls()
                                                                                                                                                                                                                poly.add_points(*points)
                                                                                                                                                                                                                return poly
                                                                                                                                                                                                        
                                                                                                                                                                                                            def get_data_buffer(self, size: int):
                                                                                                                                                                                                                self.resize(size)
                                                                                                                                                                                                                if API == "pyside6":
                                                                                                                                                                                                                    import shiboken6
                                                                                                                                                                                                        
                                                                                                                                                                                                                    address = shiboken6.getCppPointer(self.data())
                                                                                                                                                                                                                    buffer = (ctypes.c_double * 2 * self.size()).from_address(address[0])
                                                                                                                                                                                                                else:
                                                                                                                                                                                                                    buffer = self.data()
                                                                                                                                                                                                                    buffer.setsize(16 * self.size())  # ty: ignore[missing-attribute]  # sip.voidptr
                                                                                                                                                                                                                return buffer
                                                                                                                                                                                                        
                                                                                                                                                                                                            @classmethod
                                                                                                                                                                                                            def from_xy(cls, xdata, ydata) -> Self:
                                                                                                                                                                                                                import numpy as np
                                                                                                                                                                                                        
                                                                                                                                                                                                                size = len(xdata)
                                                                                                                                                                                                                polyline = cls()
                                                                                                                                                                                                                buffer = polyline.get_data_buffer(size)
                                                                                                                                                                                                                memory = np.frombuffer(buffer, np.float64)
                                                                                                                                                                                                                memory[: (size - 1) * 2 + 1 : 2] = np.asarray(xdata, dtype=np.float64)
                                                                                                                                                                                                                memory[1 : (size - 1) * 2 + 2 : 2] = np.asarray(ydata, dtype=np.float64)
                                                                                                                                                                                                                return polyline
                                                                                                                                                                                                        

                                                                                                                                                                                                        Quaternion

                                                                                                                                                                                                        Bases: QQuaternion

                                                                                                                                                                                                        Represents a quaternion consisting of a vector and scalar.

                                                                                                                                                                                                        Source code in prettyqt/gui/quaternion.py
                                                                                                                                                                                                        class Quaternion(QtGui.QQuaternion):
                                                                                                                                                                                                            """Represents a quaternion consisting of a vector and scalar."""
                                                                                                                                                                                                        
                                                                                                                                                                                                            def __repr__(self):
                                                                                                                                                                                                                return get_repr(self, self.scalar(), self.x(), self.y(), self.z())
                                                                                                                                                                                                        
                                                                                                                                                                                                            def __bool__(self):
                                                                                                                                                                                                                return not self.isNull()
                                                                                                                                                                                                        
                                                                                                                                                                                                            def __abs__(self) -> float:
                                                                                                                                                                                                                return self.length()
                                                                                                                                                                                                        
                                                                                                                                                                                                            def __reduce__(self):
                                                                                                                                                                                                                return type(self), (self.scalar(), self.x(), self.y(), self.z())
                                                                                                                                                                                                        
                                                                                                                                                                                                            def get_vector(self) -> gui.Vector3D:
                                                                                                                                                                                                                return gui.Vector3D(self.vector())
                                                                                                                                                                                                        
                                                                                                                                                                                                            def to_euler_angles(self) -> gui.Vector3D:
                                                                                                                                                                                                                return gui.Vector3D(self.toEulerAngles())
                                                                                                                                                                                                        
                                                                                                                                                                                                            def to_vector4d(self) -> gui.Vector4D:
                                                                                                                                                                                                                return gui.Vector4D(self.toVector4D())
                                                                                                                                                                                                        
                                                                                                                                                                                                            def get_normalized(self) -> Self:
                                                                                                                                                                                                                return type(self)(self.normalized())
                                                                                                                                                                                                        
                                                                                                                                                                                                            def get_conjugated(self) -> Self:
                                                                                                                                                                                                                return type(self)(self.conjugated())
                                                                                                                                                                                                        
                                                                                                                                                                                                            def get_inverted(self) -> Self:
                                                                                                                                                                                                                return type(self)(self.inverted())
                                                                                                                                                                                                        

                                                                                                                                                                                                        RadialGradient

                                                                                                                                                                                                        Bases: GradientMixin, QRadialGradient

                                                                                                                                                                                                        Used in combination with QBrush to specify a radial gradient brush.

                                                                                                                                                                                                        Source code in prettyqt/gui/radialgradient.py
                                                                                                                                                                                                        class RadialGradient(gui.GradientMixin, gui.QRadialGradient):
                                                                                                                                                                                                            """Used in combination with QBrush to specify a radial gradient brush."""
                                                                                                                                                                                                        
                                                                                                                                                                                                            def __repr__(self):
                                                                                                                                                                                                                return get_repr(
                                                                                                                                                                                                                    self,
                                                                                                                                                                                                                    self.get_center(),
                                                                                                                                                                                                                    self.centerRadius(),
                                                                                                                                                                                                                    self.get_focal_point(),
                                                                                                                                                                                                                    self.focalRadius(),
                                                                                                                                                                                                                )
                                                                                                                                                                                                        
                                                                                                                                                                                                            def get_center(self) -> core.PointF:
                                                                                                                                                                                                                return core.PointF(self.center())
                                                                                                                                                                                                        
                                                                                                                                                                                                            def get_focal_point(self) -> core.PointF:
                                                                                                                                                                                                                return core.PointF(self.focalPoint())
                                                                                                                                                                                                        
                                                                                                                                                                                                            def get_css(self) -> str:
                                                                                                                                                                                                                """Convert gradient to a CSS string. Can be used for stylesheets."""
                                                                                                                                                                                                                cx, cy = self.center().x(), self.center().y()
                                                                                                                                                                                                                fx, fy = self.focalPoint().x(), self.focalPoint().y()
                                                                                                                                                                                                                stops = self.stops()
                                                                                                                                                                                                                stops = "\n".join(f"    stop: {stop:f} {color.name()}" for stop, color in stops)
                                                                                                                                                                                                                spread = self.get_spread()
                                                                                                                                                                                                                # couldnt find equivalent for focalRadius on first sight.
                                                                                                                                                                                                                return (
                                                                                                                                                                                                                    "qradialgradient(\n"
                                                                                                                                                                                                                    f"    cx: {cx}, cy: {cy}, radius: {self.radius()}, fx: {fx}, fy: {fy},\n"
                                                                                                                                                                                                                    f"    spread:{spread},\n"
                                                                                                                                                                                                                    f"{stops})"
                                                                                                                                                                                                                )
                                                                                                                                                                                                        

                                                                                                                                                                                                        get_css() -> str

                                                                                                                                                                                                        Convert gradient to a CSS string. Can be used for stylesheets.

                                                                                                                                                                                                        Source code in prettyqt/gui/radialgradient.py
                                                                                                                                                                                                        def get_css(self) -> str:
                                                                                                                                                                                                            """Convert gradient to a CSS string. Can be used for stylesheets."""
                                                                                                                                                                                                            cx, cy = self.center().x(), self.center().y()
                                                                                                                                                                                                            fx, fy = self.focalPoint().x(), self.focalPoint().y()
                                                                                                                                                                                                            stops = self.stops()
                                                                                                                                                                                                            stops = "\n".join(f"    stop: {stop:f} {color.name()}" for stop, color in stops)
                                                                                                                                                                                                            spread = self.get_spread()
                                                                                                                                                                                                            # couldnt find equivalent for focalRadius on first sight.
                                                                                                                                                                                                            return (
                                                                                                                                                                                                                "qradialgradient(\n"
                                                                                                                                                                                                                f"    cx: {cx}, cy: {cy}, radius: {self.radius()}, fx: {fx}, fy: {fy},\n"
                                                                                                                                                                                                                f"    spread:{spread},\n"
                                                                                                                                                                                                                f"{stops})"
                                                                                                                                                                                                            )
                                                                                                                                                                                                        

                                                                                                                                                                                                        RasterWindow

                                                                                                                                                                                                        Bases: PaintDeviceWindowMixin, QRasterWindow

                                                                                                                                                                                                        Convenience class for using QPainter on a QWindow.

                                                                                                                                                                                                        Source code in prettyqt/gui/rasterwindow.py
                                                                                                                                                                                                        class RasterWindow(gui.PaintDeviceWindowMixin, gui.QRasterWindow):
                                                                                                                                                                                                            """Convenience class for using QPainter on a QWindow."""
                                                                                                                                                                                                        

                                                                                                                                                                                                        RegularExpressionValidator

                                                                                                                                                                                                        Bases: ValidatorMixin, QRegularExpressionValidator

                                                                                                                                                                                                        Used to check a string against a regular expression.

                                                                                                                                                                                                        Source code in prettyqt/gui/regularexpressionvalidator.py
                                                                                                                                                                                                        class RegularExpressionValidator(gui.ValidatorMixin, gui.QRegularExpressionValidator):
                                                                                                                                                                                                            """Used to check a string against a regular expression."""
                                                                                                                                                                                                        
                                                                                                                                                                                                            ID = "regular_expression"
                                                                                                                                                                                                        
                                                                                                                                                                                                            def __init__(self, *args, **kwargs):
                                                                                                                                                                                                                # allow passing strings as well as re.Pattern to the ctor
                                                                                                                                                                                                                match args, kwargs:
                                                                                                                                                                                                                    case (str() as pat, *rest), _:
                                                                                                                                                                                                                        super().__init__(core.QRegularExpression(pat), *rest, **kwargs)
                                                                                                                                                                                                                    case _, {"regular_expression": str() as reg_str, **rest}:
                                                                                                                                                                                                                        pat = core.QRegularExpression(reg_str)
                                                                                                                                                                                                                        super().__init__(*args, regular_expression=pat, **rest)
                                                                                                                                                                                                                    case (re.Pattern() as pat,), _:
                                                                                                                                                                                                                        super().__init__(core.RegularExpression(pat))
                                                                                                                                                                                                                    case _, _:
                                                                                                                                                                                                                        super().__init__(*args, **kwargs)
                                                                                                                                                                                                        
                                                                                                                                                                                                            def __repr__(self):
                                                                                                                                                                                                                return get_repr(self, self.regularExpression())
                                                                                                                                                                                                        
                                                                                                                                                                                                            def __getstate__(self):
                                                                                                                                                                                                                return dict(pattern=core.RegularExpression(self.regularExpression()))
                                                                                                                                                                                                        
                                                                                                                                                                                                            def __setstate__(self, state):
                                                                                                                                                                                                                self.setRegularExpression(state["pattern"])
                                                                                                                                                                                                        
                                                                                                                                                                                                            def __reduce__(self):
                                                                                                                                                                                                                return type(self), (), self.__getstate__()
                                                                                                                                                                                                        
                                                                                                                                                                                                            def __eq__(self, other: object):
                                                                                                                                                                                                                return (
                                                                                                                                                                                                                    self.regularExpression() == other.regularExpression()
                                                                                                                                                                                                                    if isinstance(other, type(self))
                                                                                                                                                                                                                    else False
                                                                                                                                                                                                                )
                                                                                                                                                                                                        
                                                                                                                                                                                                            def set_regex(
                                                                                                                                                                                                                self,
                                                                                                                                                                                                                regex: datatypes.PatternAndStringType,
                                                                                                                                                                                                                flags=None,
                                                                                                                                                                                                            ):
                                                                                                                                                                                                                self.setRegularExpression(datatypes.to_regular_expression(regex))
                                                                                                                                                                                                        
                                                                                                                                                                                                            def get_regex(self) -> str:
                                                                                                                                                                                                                val = self.regularExpression()
                                                                                                                                                                                                                return val.pattern()
                                                                                                                                                                                                        

                                                                                                                                                                                                        Screen

                                                                                                                                                                                                        Used to query screen properties.

                                                                                                                                                                                                        Source code in prettyqt/gui/screen.py
                                                                                                                                                                                                        class Screen:
                                                                                                                                                                                                            """Used to query screen properties."""
                                                                                                                                                                                                        
                                                                                                                                                                                                            def __init__(self, item: gui.QScreen):
                                                                                                                                                                                                                self.item = item
                                                                                                                                                                                                        
                                                                                                                                                                                                            def __getattr__(self, val):
                                                                                                                                                                                                                return getattr(self.item, val)
                                                                                                                                                                                                        
                                                                                                                                                                                                            def get_geometry(self) -> core.Rect:
                                                                                                                                                                                                                return core.Rect(self.geometry())
                                                                                                                                                                                                        
                                                                                                                                                                                                            def get_size(self) -> core.Size:
                                                                                                                                                                                                                return core.Size(self.size())
                                                                                                                                                                                                        
                                                                                                                                                                                                            def get_available_geometry(self) -> core.Rect:
                                                                                                                                                                                                                return core.Rect(self.availableGeometry())
                                                                                                                                                                                                        
                                                                                                                                                                                                            def get_available_size(self) -> core.Size:
                                                                                                                                                                                                                return core.Size(self.availableSize())
                                                                                                                                                                                                        
                                                                                                                                                                                                            def get_available_virtual_geometry(self) -> core.Rect:
                                                                                                                                                                                                                return core.Rect(self.availableVirtualGeometry())
                                                                                                                                                                                                        
                                                                                                                                                                                                            def get_available_virtual_size(self) -> core.Size:
                                                                                                                                                                                                                return core.Size(self.availableVirtualSize())
                                                                                                                                                                                                        
                                                                                                                                                                                                            def get_virtual_geometry(self) -> core.Rect:
                                                                                                                                                                                                                return core.Rect(self.virtualGeometry())
                                                                                                                                                                                                        
                                                                                                                                                                                                            def get_virtual_size(self) -> core.Size:
                                                                                                                                                                                                                return core.Size(self.virtualSize())
                                                                                                                                                                                                        
                                                                                                                                                                                                            def get_native_orientation(self) -> constants.ScreenOrientationStr:
                                                                                                                                                                                                                return constants.SCREEN_ORIENTATION.inverse[self.nativeOrientation()]
                                                                                                                                                                                                        
                                                                                                                                                                                                            def get_orientation(self) -> constants.ScreenOrientationStr:
                                                                                                                                                                                                                return constants.SCREEN_ORIENTATION.inverse[self.orientation()]
                                                                                                                                                                                                        
                                                                                                                                                                                                            def get_primary_orientation(self) -> constants.ScreenOrientationStr:
                                                                                                                                                                                                                return constants.SCREEN_ORIENTATION.inverse[self.primaryOrientation()]
                                                                                                                                                                                                        
                                                                                                                                                                                                            def get_physical_size(self) -> core.SizeF:
                                                                                                                                                                                                                return core.SizeF(self.physicalSize())
                                                                                                                                                                                                        
                                                                                                                                                                                                            def get_angle_between(
                                                                                                                                                                                                                self,
                                                                                                                                                                                                                orientation_1: constants.ScreenOrientationStr | constants.ScreenOrientation,
                                                                                                                                                                                                                orientation_2: constants.ScreenOrientationStr | constants.ScreenOrientation,
                                                                                                                                                                                                            ) -> int:
                                                                                                                                                                                                                return self.angleBetween(
                                                                                                                                                                                                                    constants.SCREEN_ORIENTATION.get_enum_value(orientation_1),
                                                                                                                                                                                                                    constants.SCREEN_ORIENTATION.get_enum_value(orientation_2),
                                                                                                                                                                                                                )
                                                                                                                                                                                                        
                                                                                                                                                                                                            def grab_window(
                                                                                                                                                                                                                self,
                                                                                                                                                                                                                window: int = 0,
                                                                                                                                                                                                                x: int = 0,
                                                                                                                                                                                                                y: int = 0,
                                                                                                                                                                                                                width: int | None = None,
                                                                                                                                                                                                                height: int | None = None,
                                                                                                                                                                                                            ) -> gui.Pixmap:
                                                                                                                                                                                                                if width is None:
                                                                                                                                                                                                                    width = -1
                                                                                                                                                                                                                if height is None:
                                                                                                                                                                                                                    height = -1
                                                                                                                                                                                                                px = self.grabWindow(window, x, y, width, height)
                                                                                                                                                                                                                return gui.Pixmap(px)
                                                                                                                                                                                                        
                                                                                                                                                                                                            def get_virtual_siblings(self) -> list[Screen]:
                                                                                                                                                                                                                return [Screen(i) for i in self.virtualSiblings()]
                                                                                                                                                                                                        

                                                                                                                                                                                                        SessionManager

                                                                                                                                                                                                        Bases: ObjectMixin

                                                                                                                                                                                                        Source code in prettyqt/gui/sessionmanager.py
                                                                                                                                                                                                        class SessionManager(core.ObjectMixin):
                                                                                                                                                                                                            def __init__(self, item: QtGui.QSessionManager):
                                                                                                                                                                                                                self.item = item
                                                                                                                                                                                                        
                                                                                                                                                                                                            def __getattr__(self, val):
                                                                                                                                                                                                                return getattr(self.item, val)
                                                                                                                                                                                                        
                                                                                                                                                                                                            def set_restart_hint(self, style: RestartHintStr | QtGui.QSessionManager.RestartHint):
                                                                                                                                                                                                                """Set the restart hint.
                                                                                                                                                                                                        
                                                                                                                                                                                                                Args:
                                                                                                                                                                                                                    style: restart hint
                                                                                                                                                                                                                """
                                                                                                                                                                                                                self.setRestartHint(RESTART_HINT.get_enum_value(style))
                                                                                                                                                                                                        
                                                                                                                                                                                                            def get_restart_hint(self) -> RestartHintStr:
                                                                                                                                                                                                                """Return current restart hint.
                                                                                                                                                                                                        
                                                                                                                                                                                                                Returns:
                                                                                                                                                                                                                    restart hint
                                                                                                                                                                                                                """
                                                                                                                                                                                                                return RESTART_HINT.inverse[self.restartHint()]
                                                                                                                                                                                                        

                                                                                                                                                                                                        get_restart_hint() -> RestartHintStr

                                                                                                                                                                                                        Return current restart hint.

                                                                                                                                                                                                        Source code in prettyqt/gui/sessionmanager.py
                                                                                                                                                                                                        def get_restart_hint(self) -> RestartHintStr:
                                                                                                                                                                                                            """Return current restart hint.
                                                                                                                                                                                                        
                                                                                                                                                                                                            Returns:
                                                                                                                                                                                                                restart hint
                                                                                                                                                                                                            """
                                                                                                                                                                                                            return RESTART_HINT.inverse[self.restartHint()]
                                                                                                                                                                                                        

                                                                                                                                                                                                        set_restart_hint(style: RestartHintStr | QtGui.QSessionManager.RestartHint)

                                                                                                                                                                                                        Set the restart hint.

                                                                                                                                                                                                        Parameters:

                                                                                                                                                                                                        Name Type Description Default
                                                                                                                                                                                                        style RestartHintStr | RestartHint

                                                                                                                                                                                                        restart hint

                                                                                                                                                                                                        required
                                                                                                                                                                                                        Source code in prettyqt/gui/sessionmanager.py
                                                                                                                                                                                                        def set_restart_hint(self, style: RestartHintStr | QtGui.QSessionManager.RestartHint):
                                                                                                                                                                                                            """Set the restart hint.
                                                                                                                                                                                                        
                                                                                                                                                                                                            Args:
                                                                                                                                                                                                                style: restart hint
                                                                                                                                                                                                            """
                                                                                                                                                                                                            self.setRestartHint(RESTART_HINT.get_enum_value(style))
                                                                                                                                                                                                        

                                                                                                                                                                                                        Shortcut

                                                                                                                                                                                                        Bases: ObjectMixin, QShortcut

                                                                                                                                                                                                        Source code in prettyqt/gui/shortcut.py
                                                                                                                                                                                                        class Shortcut(core.ObjectMixin, gui.QShortcut):
                                                                                                                                                                                                            def __init__(self, *args, **kwargs):
                                                                                                                                                                                                                match args:
                                                                                                                                                                                                                    case (str(), *rest):
                                                                                                                                                                                                                        args = (gui.KeySequence(args[0]), *rest)
                                                                                                                                                                                                                super().__init__(*args, **kwargs)
                                                                                                                                                                                                        
                                                                                                                                                                                                            def __str__(self):
                                                                                                                                                                                                                return self.key().toString()
                                                                                                                                                                                                        
                                                                                                                                                                                                            def _get_map(self):
                                                                                                                                                                                                                maps = super()._get_map()
                                                                                                                                                                                                                maps |= {"context": constants.SHORTCUT_CONTEXT}
                                                                                                                                                                                                                return maps
                                                                                                                                                                                                        
                                                                                                                                                                                                            def set_context(
                                                                                                                                                                                                                self, context: constants.ShortcutContextStr | constants.ShortcutContext
                                                                                                                                                                                                            ):
                                                                                                                                                                                                                """Set shortcut context.
                                                                                                                                                                                                        
                                                                                                                                                                                                                Args:
                                                                                                                                                                                                                    context: shortcut context
                                                                                                                                                                                                                """
                                                                                                                                                                                                                self.setContext(constants.SHORTCUT_CONTEXT.get_enum_value(context))
                                                                                                                                                                                                        
                                                                                                                                                                                                            def get_context(self) -> constants.ShortcutContextStr:
                                                                                                                                                                                                                """Return shortcut context.
                                                                                                                                                                                                        
                                                                                                                                                                                                                Returns:
                                                                                                                                                                                                                    shortcut context
                                                                                                                                                                                                                """
                                                                                                                                                                                                                return constants.SHORTCUT_CONTEXT.inverse[self.context()]
                                                                                                                                                                                                        
                                                                                                                                                                                                            def set_key(
                                                                                                                                                                                                                self,
                                                                                                                                                                                                                key: datatypes.KeyCombinationType,
                                                                                                                                                                                                            ):
                                                                                                                                                                                                                keysequence = gui.KeySequence(key)
                                                                                                                                                                                                                self.setKey(keysequence)
                                                                                                                                                                                                        
                                                                                                                                                                                                            def set_keys(self, keys: Iterable[datatypes.KeyCombinationType]):
                                                                                                                                                                                                                keysequences = [gui.KeySequence(key) for key in keys]
                                                                                                                                                                                                                self.setKeys(keysequences)
                                                                                                                                                                                                        
                                                                                                                                                                                                            def get_key(self) -> gui.KeySequence:
                                                                                                                                                                                                                """Return the shortcut's key sequence.
                                                                                                                                                                                                        
                                                                                                                                                                                                                Returns:
                                                                                                                                                                                                                    Key sequence
                                                                                                                                                                                                                """
                                                                                                                                                                                                                return gui.KeySequence(self.key())
                                                                                                                                                                                                        
                                                                                                                                                                                                            def get_keys(self) -> list[gui.KeySequence]:
                                                                                                                                                                                                                return [gui.KeySequence(i) for i in self.keys()]
                                                                                                                                                                                                        

                                                                                                                                                                                                        get_context() -> constants.ShortcutContextStr

                                                                                                                                                                                                        Return shortcut context.

                                                                                                                                                                                                        Source code in prettyqt/gui/shortcut.py
                                                                                                                                                                                                        def get_context(self) -> constants.ShortcutContextStr:
                                                                                                                                                                                                            """Return shortcut context.
                                                                                                                                                                                                        
                                                                                                                                                                                                            Returns:
                                                                                                                                                                                                                shortcut context
                                                                                                                                                                                                            """
                                                                                                                                                                                                            return constants.SHORTCUT_CONTEXT.inverse[self.context()]
                                                                                                                                                                                                        

                                                                                                                                                                                                        get_key() -> gui.KeySequence

                                                                                                                                                                                                        Return the shortcut's key sequence.

                                                                                                                                                                                                        Source code in prettyqt/gui/shortcut.py
                                                                                                                                                                                                        def get_key(self) -> gui.KeySequence:
                                                                                                                                                                                                            """Return the shortcut's key sequence.
                                                                                                                                                                                                        
                                                                                                                                                                                                            Returns:
                                                                                                                                                                                                                Key sequence
                                                                                                                                                                                                            """
                                                                                                                                                                                                            return gui.KeySequence(self.key())
                                                                                                                                                                                                        

                                                                                                                                                                                                        set_context(context: constants.ShortcutContextStr | constants.ShortcutContext)

                                                                                                                                                                                                        Set shortcut context.

                                                                                                                                                                                                        Parameters:

                                                                                                                                                                                                        Name Type Description Default
                                                                                                                                                                                                        context ShortcutContextStr | ShortcutContext

                                                                                                                                                                                                        shortcut context

                                                                                                                                                                                                        required
                                                                                                                                                                                                        Source code in prettyqt/gui/shortcut.py
                                                                                                                                                                                                        def set_context(
                                                                                                                                                                                                            self, context: constants.ShortcutContextStr | constants.ShortcutContext
                                                                                                                                                                                                        ):
                                                                                                                                                                                                            """Set shortcut context.
                                                                                                                                                                                                        
                                                                                                                                                                                                            Args:
                                                                                                                                                                                                                context: shortcut context
                                                                                                                                                                                                            """
                                                                                                                                                                                                            self.setContext(constants.SHORTCUT_CONTEXT.get_enum_value(context))
                                                                                                                                                                                                        

                                                                                                                                                                                                        StandardItem

                                                                                                                                                                                                        Bases: SerializeMixin, QStandardItem

                                                                                                                                                                                                        Source code in prettyqt/gui/standarditem.py
                                                                                                                                                                                                        class StandardItem(serializemixin.SerializeMixin, gui.QStandardItem):
                                                                                                                                                                                                            def __repr__(self):
                                                                                                                                                                                                                return get_repr(self, self.get_icon(), self.text())
                                                                                                                                                                                                        
                                                                                                                                                                                                            def __getitem__(
                                                                                                                                                                                                                self, index: int | slice | tuple[int | slice, int | slice] | core.QModelIndex
                                                                                                                                                                                                            ) -> gui.QStandardItem | listdelegators.ListDelegator[gui.QStandardItem]:
                                                                                                                                                                                                                match index:
                                                                                                                                                                                                                    case int():
                                                                                                                                                                                                                        if index >= self.rowCount():
                                                                                                                                                                                                                            raise IndexError(index)
                                                                                                                                                                                                                        return self.child(index)
                                                                                                                                                                                                                    case slice():
                                                                                                                                                                                                                        return self.__getitem__((index, 0))
                                                                                                                                                                                                                    case int() as row, int() as col:
                                                                                                                                                                                                                        return self.child(row, col)
                                                                                                                                                                                                                    case (int() | slice() as row, int() | slice() as col):
                                                                                                                                                                                                                        rowcount = self.rowCount()
                                                                                                                                                                                                                        colcount = self.columnCount()
                                                                                                                                                                                                                        children = [
                                                                                                                                                                                                                            self.child(i, j)
                                                                                                                                                                                                                            for i, j in helpers.iter_positions(row, col, rowcount, colcount)
                                                                                                                                                                                                                        ]
                                                                                                                                                                                                                        return listdelegators.ListDelegator(children)
                                                                                                                                                                                                                    case _:
                                                                                                                                                                                                                        raise TypeError(index)
                                                                                                                                                                                                        
                                                                                                                                                                                                            def __delitem__(self, index: int | tuple[int, int]):
                                                                                                                                                                                                                item = self.takeRow(index) if isinstance(index, int) else self.takeChild(*index)
                                                                                                                                                                                                                if not item:
                                                                                                                                                                                                                    raise KeyError(index)
                                                                                                                                                                                                                return item
                                                                                                                                                                                                        
                                                                                                                                                                                                            def __iter__(self) -> Iterator[gui.QStandardItem]:
                                                                                                                                                                                                                return iter(self.get_children())
                                                                                                                                                                                                        
                                                                                                                                                                                                            def __add__(self, other: str | gui.QStandardItem) -> StandardItem:
                                                                                                                                                                                                                match other:
                                                                                                                                                                                                                    case gui.QStandardItem() | str():
                                                                                                                                                                                                                        self.add(other)
                                                                                                                                                                                                                        return self
                                                                                                                                                                                                                    case _:
                                                                                                                                                                                                                        msg = "wrong type for addition"
                                                                                                                                                                                                                        raise TypeError(msg)
                                                                                                                                                                                                        
                                                                                                                                                                                                            def get_children(self) -> listdelegators.ListDelegator[gui.QStandardItem]:
                                                                                                                                                                                                                items = [self.child(index) for index in range(self.rowCount())]
                                                                                                                                                                                                                return listdelegators.ListDelegator(items)
                                                                                                                                                                                                        
                                                                                                                                                                                                            def add(self, *item: str | gui.QStandardItem):
                                                                                                                                                                                                                for i in item:
                                                                                                                                                                                                                    new_item = type(self)(i) if isinstance(i, str) else i
                                                                                                                                                                                                                    self.appendRow([new_item])
                                                                                                                                                                                                        
                                                                                                                                                                                                            def clone(self) -> Self:
                                                                                                                                                                                                                item = type(self)()
                                                                                                                                                                                                                core.DataStream.copy_data(self, item)
                                                                                                                                                                                                                return item
                                                                                                                                                                                                        
                                                                                                                                                                                                            def set_icon(self, icon: datatypes.IconType):
                                                                                                                                                                                                                """Set the icon for the action.
                                                                                                                                                                                                        
                                                                                                                                                                                                                Args:
                                                                                                                                                                                                                    icon: icon to use
                                                                                                                                                                                                                """
                                                                                                                                                                                                                icon = iconprovider.get_icon(icon)
                                                                                                                                                                                                                self.setIcon(icon)
                                                                                                                                                                                                        
                                                                                                                                                                                                            def set_checkstate(
                                                                                                                                                                                                                self, state: constants.CheckStateStr | constants.CheckState | bool
                                                                                                                                                                                                            ):
                                                                                                                                                                                                                """Set checkstate of the checkbox.
                                                                                                                                                                                                        
                                                                                                                                                                                                                Args:
                                                                                                                                                                                                                    state: checkstate to use
                                                                                                                                                                                                                """
                                                                                                                                                                                                                if isinstance(state, bool):
                                                                                                                                                                                                                    state = (
                                                                                                                                                                                                                        constants.CheckState.Checked if state else constants.CheckState.Unchecked
                                                                                                                                                                                                                    )
                                                                                                                                                                                                                self.setCheckState(constants.CHECK_STATE.get_enum_value(state))
                                                                                                                                                                                                        
                                                                                                                                                                                                            def is_checked(self):
                                                                                                                                                                                                                return self.checkState() == constants.CheckState.Checked
                                                                                                                                                                                                        
                                                                                                                                                                                                            def toggle_checkstate(self):
                                                                                                                                                                                                                if self.checkState() == constants.CheckState.Checked:
                                                                                                                                                                                                                    self.setCheckState(constants.CheckState.Unchecked)
                                                                                                                                                                                                                else:
                                                                                                                                                                                                                    self.setCheckState(constants.CheckState.Checked)
                                                                                                                                                                                                        
                                                                                                                                                                                                            def get_checkstate(self) -> constants.CheckStateStr:
                                                                                                                                                                                                                """Return checkstate.
                                                                                                                                                                                                        
                                                                                                                                                                                                                Returns:
                                                                                                                                                                                                                    checkstate
                                                                                                                                                                                                                """
                                                                                                                                                                                                                return constants.CHECK_STATE.inverse[self.checkState()]
                                                                                                                                                                                                        
                                                                                                                                                                                                            def set_text_alignment(
                                                                                                                                                                                                                self, alignment: constants.AlignmentStr | constants.AlignmentFlag
                                                                                                                                                                                                            ):
                                                                                                                                                                                                                """Set the alignment of the text.
                                                                                                                                                                                                        
                                                                                                                                                                                                                Args:
                                                                                                                                                                                                                    alignment: alignment for the format
                                                                                                                                                                                                                """
                                                                                                                                                                                                                self.setTextAlignment(constants.ALIGNMENTS.get_enum_value(alignment))
                                                                                                                                                                                                        
                                                                                                                                                                                                            def get_text_alignment(self) -> constants.AlignmentStr:
                                                                                                                                                                                                                """Return current text alignment.
                                                                                                                                                                                                        
                                                                                                                                                                                                                Returns:
                                                                                                                                                                                                                    alignment
                                                                                                                                                                                                                """
                                                                                                                                                                                                                return constants.ALIGNMENTS.inverse[self.textAlignment()]
                                                                                                                                                                                                        
                                                                                                                                                                                                            def get_background(self) -> gui.Brush:
                                                                                                                                                                                                                return gui.Brush(self.background())
                                                                                                                                                                                                        
                                                                                                                                                                                                            def get_foreground(self) -> gui.Brush:
                                                                                                                                                                                                                return gui.Brush(self.foreground())
                                                                                                                                                                                                        
                                                                                                                                                                                                            def get_font(self) -> gui.Font:
                                                                                                                                                                                                                return gui.Font(self.font())
                                                                                                                                                                                                        
                                                                                                                                                                                                            def get_icon(self) -> gui.Icon | None:
                                                                                                                                                                                                                icon = self.icon()
                                                                                                                                                                                                                return None if icon.isNull() else gui.Icon(icon)
                                                                                                                                                                                                        
                                                                                                                                                                                                            def set_data(self, data: Any, role: constants.ItemDataRoleStr | int):
                                                                                                                                                                                                                item_role = constants.ITEM_DATA_ROLE[role] if isinstance(role, str) else role
                                                                                                                                                                                                                super().setData(data, item_role)
                                                                                                                                                                                                        
                                                                                                                                                                                                            def get_data(self, role: constants.ItemDataRoleStr | int):
                                                                                                                                                                                                                item_role = constants.ITEM_DATA_ROLE[role] if isinstance(role, str) else role
                                                                                                                                                                                                                return super().data(item_role)
                                                                                                                                                                                                        
                                                                                                                                                                                                            def set_tooltip(
                                                                                                                                                                                                                self,
                                                                                                                                                                                                                tooltip: str | datatypes.PathType,
                                                                                                                                                                                                                size: datatypes.SizeType | None = None,
                                                                                                                                                                                                                rich_text: bool = False,
                                                                                                                                                                                                            ):
                                                                                                                                                                                                                if isinstance(tooltip, os.PathLike):
                                                                                                                                                                                                                    path = os.fspath(tooltip)
                                                                                                                                                                                                                    if size is None:
                                                                                                                                                                                                                        tooltip = f"<img src={path!r}>"
                                                                                                                                                                                                                    else:
                                                                                                                                                                                                                        s = datatypes.to_size(size)
                                                                                                                                                                                                                        tooltip = f'<img src={path!r} width="{s.width()}" height="{s.height()}">'
                                                                                                                                                                                                                if rich_text:
                                                                                                                                                                                                                    tooltip = f"<html>{html.escape(tooltip)}</html>"
                                                                                                                                                                                                                super().setToolTip(tooltip)
                                                                                                                                                                                                        
                                                                                                                                                                                                            def set_size_hint(self, hint: datatypes.SizeType):
                                                                                                                                                                                                                self.setSizeHint(datatypes.to_size(hint))
                                                                                                                                                                                                        
                                                                                                                                                                                                            def add_item(
                                                                                                                                                                                                                self,
                                                                                                                                                                                                                name: str = "",
                                                                                                                                                                                                                icon: datatypes.IconType = None,
                                                                                                                                                                                                                data: dict | None = None,
                                                                                                                                                                                                                foreground: gui.QBrush | None = None,
                                                                                                                                                                                                                background: gui.QBrush | None = None,
                                                                                                                                                                                                                font: gui.QFont | None = None,
                                                                                                                                                                                                                selectable: bool | None = None,
                                                                                                                                                                                                                enabled: bool | None = None,
                                                                                                                                                                                                                editable: bool | None = None,
                                                                                                                                                                                                                status_tip: str = "",
                                                                                                                                                                                                                tool_tip: str = "",
                                                                                                                                                                                                                whats_this: str | None = None,
                                                                                                                                                                                                                # text_alignment: Optional[str] = None,
                                                                                                                                                                                                                checkstate: constants.CheckStateStr | None = None,
                                                                                                                                                                                                                flags: constants.ItemFlag | None = None,
                                                                                                                                                                                                                size_hint: datatypes.SizeType | None = None,
                                                                                                                                                                                                                is_user_type: bool = False,
                                                                                                                                                                                                            ) -> Self:
                                                                                                                                                                                                                item = type(self)(name)
                                                                                                                                                                                                                if icon is not None:
                                                                                                                                                                                                                    icon = iconprovider.get_icon(icon)
                                                                                                                                                                                                                    item.setIcon(icon)
                                                                                                                                                                                                                if data is not None:
                                                                                                                                                                                                                    for k, v in data.items():
                                                                                                                                                                                                                        item.set_data(v, k)
                                                                                                                                                                                                                if foreground is not None:
                                                                                                                                                                                                                    item.setForeground(foreground)
                                                                                                                                                                                                                if background is not None:
                                                                                                                                                                                                                    item.setBackground(background)
                                                                                                                                                                                                                if font is not None:
                                                                                                                                                                                                                    item.setFont(font)
                                                                                                                                                                                                                if flags is not None:
                                                                                                                                                                                                                    item.setFlags(flags)
                                                                                                                                                                                                                if enabled is not None:
                                                                                                                                                                                                                    item.setEnabled(enabled)
                                                                                                                                                                                                                if editable is not None:
                                                                                                                                                                                                                    item.setEditable(editable)
                                                                                                                                                                                                                if selectable is not None:
                                                                                                                                                                                                                    item.setSelectable(selectable)
                                                                                                                                                                                                                if status_tip:
                                                                                                                                                                                                                    item.setStatusTip(status_tip)
                                                                                                                                                                                                                if tool_tip:
                                                                                                                                                                                                                    item.setToolTip(tool_tip)
                                                                                                                                                                                                                if whats_this:
                                                                                                                                                                                                                    item.setWhatsThis(whats_this)
                                                                                                                                                                                                                if size_hint is not None:
                                                                                                                                                                                                                    item.set_size_hint(size_hint)
                                                                                                                                                                                                                if checkstate is not None:
                                                                                                                                                                                                                    item.set_checkstate(checkstate)
                                                                                                                                                                                                                self.appendRow([item])
                                                                                                                                                                                                                return item
                                                                                                                                                                                                        

                                                                                                                                                                                                        get_checkstate() -> constants.CheckStateStr

                                                                                                                                                                                                        Return checkstate.

                                                                                                                                                                                                        Source code in prettyqt/gui/standarditem.py
                                                                                                                                                                                                        def get_checkstate(self) -> constants.CheckStateStr:
                                                                                                                                                                                                            """Return checkstate.
                                                                                                                                                                                                        
                                                                                                                                                                                                            Returns:
                                                                                                                                                                                                                checkstate
                                                                                                                                                                                                            """
                                                                                                                                                                                                            return constants.CHECK_STATE.inverse[self.checkState()]
                                                                                                                                                                                                        

                                                                                                                                                                                                        get_text_alignment() -> constants.AlignmentStr

                                                                                                                                                                                                        Return current text alignment.

                                                                                                                                                                                                        Source code in prettyqt/gui/standarditem.py
                                                                                                                                                                                                        def get_text_alignment(self) -> constants.AlignmentStr:
                                                                                                                                                                                                            """Return current text alignment.
                                                                                                                                                                                                        
                                                                                                                                                                                                            Returns:
                                                                                                                                                                                                                alignment
                                                                                                                                                                                                            """
                                                                                                                                                                                                            return constants.ALIGNMENTS.inverse[self.textAlignment()]
                                                                                                                                                                                                        

                                                                                                                                                                                                        set_checkstate(state: constants.CheckStateStr | constants.CheckState | bool)

                                                                                                                                                                                                        Set checkstate of the checkbox.

                                                                                                                                                                                                        Parameters:

                                                                                                                                                                                                        Name Type Description Default
                                                                                                                                                                                                        state CheckStateStr | CheckState | bool

                                                                                                                                                                                                        checkstate to use

                                                                                                                                                                                                        required
                                                                                                                                                                                                        Source code in prettyqt/gui/standarditem.py
                                                                                                                                                                                                        def set_checkstate(
                                                                                                                                                                                                            self, state: constants.CheckStateStr | constants.CheckState | bool
                                                                                                                                                                                                        ):
                                                                                                                                                                                                            """Set checkstate of the checkbox.
                                                                                                                                                                                                        
                                                                                                                                                                                                            Args:
                                                                                                                                                                                                                state: checkstate to use
                                                                                                                                                                                                            """
                                                                                                                                                                                                            if isinstance(state, bool):
                                                                                                                                                                                                                state = (
                                                                                                                                                                                                                    constants.CheckState.Checked if state else constants.CheckState.Unchecked
                                                                                                                                                                                                                )
                                                                                                                                                                                                            self.setCheckState(constants.CHECK_STATE.get_enum_value(state))
                                                                                                                                                                                                        

                                                                                                                                                                                                        set_icon(icon: datatypes.IconType)

                                                                                                                                                                                                        Set the icon for the action.

                                                                                                                                                                                                        Parameters:

                                                                                                                                                                                                        Name Type Description Default
                                                                                                                                                                                                        icon IconType

                                                                                                                                                                                                        icon to use

                                                                                                                                                                                                        required
                                                                                                                                                                                                        Source code in prettyqt/gui/standarditem.py
                                                                                                                                                                                                        def set_icon(self, icon: datatypes.IconType):
                                                                                                                                                                                                            """Set the icon for the action.
                                                                                                                                                                                                        
                                                                                                                                                                                                            Args:
                                                                                                                                                                                                                icon: icon to use
                                                                                                                                                                                                            """
                                                                                                                                                                                                            icon = iconprovider.get_icon(icon)
                                                                                                                                                                                                            self.setIcon(icon)
                                                                                                                                                                                                        

                                                                                                                                                                                                        set_text_alignment(alignment: constants.AlignmentStr | constants.AlignmentFlag)

                                                                                                                                                                                                        Set the alignment of the text.

                                                                                                                                                                                                        Parameters:

                                                                                                                                                                                                        Name Type Description Default
                                                                                                                                                                                                        alignment AlignmentStr | AlignmentFlag

                                                                                                                                                                                                        alignment for the format

                                                                                                                                                                                                        required
                                                                                                                                                                                                        Source code in prettyqt/gui/standarditem.py
                                                                                                                                                                                                        def set_text_alignment(
                                                                                                                                                                                                            self, alignment: constants.AlignmentStr | constants.AlignmentFlag
                                                                                                                                                                                                        ):
                                                                                                                                                                                                            """Set the alignment of the text.
                                                                                                                                                                                                        
                                                                                                                                                                                                            Args:
                                                                                                                                                                                                                alignment: alignment for the format
                                                                                                                                                                                                            """
                                                                                                                                                                                                            self.setTextAlignment(constants.ALIGNMENTS.get_enum_value(alignment))
                                                                                                                                                                                                        

                                                                                                                                                                                                        StaticText

                                                                                                                                                                                                        Bases: QStaticText

                                                                                                                                                                                                        Source code in prettyqt/gui/statictext.py
                                                                                                                                                                                                        class StaticText(QtGui.QStaticText):
                                                                                                                                                                                                            def __repr__(self):
                                                                                                                                                                                                                return get_repr(self, self.text())
                                                                                                                                                                                                        
                                                                                                                                                                                                            def __str__(self):
                                                                                                                                                                                                                return self.text()
                                                                                                                                                                                                        
                                                                                                                                                                                                            def get_size(self) -> core.SizeF:
                                                                                                                                                                                                                return core.SizeF(self.size())
                                                                                                                                                                                                        
                                                                                                                                                                                                            def set_text_format(
                                                                                                                                                                                                                self, text_format: constants.TextFormatStr | constants.TextFormat
                                                                                                                                                                                                            ):
                                                                                                                                                                                                                """Set the text format.
                                                                                                                                                                                                        
                                                                                                                                                                                                                Allowed values are "rich", "plain", "auto", "markdown"
                                                                                                                                                                                                        
                                                                                                                                                                                                                Args:
                                                                                                                                                                                                                    text_format: text format to use
                                                                                                                                                                                                                """
                                                                                                                                                                                                                self.setTextFormat(constants.TEXT_FORMAT.get_enum_value(text_format))
                                                                                                                                                                                                        
                                                                                                                                                                                                            def get_text_format(self) -> constants.TextFormatStr:
                                                                                                                                                                                                                """Return current text format.
                                                                                                                                                                                                        
                                                                                                                                                                                                                Possible values: "rich", "plain", "auto", "markdown"
                                                                                                                                                                                                        
                                                                                                                                                                                                                Returns:
                                                                                                                                                                                                                    text format
                                                                                                                                                                                                                """
                                                                                                                                                                                                                return constants.TEXT_FORMAT.inverse[self.textFormat()]
                                                                                                                                                                                                        
                                                                                                                                                                                                            def set_performance_hint(
                                                                                                                                                                                                                self, hint: PerformanceHintStr | QtGui.QStaticText.PerformanceHint
                                                                                                                                                                                                            ):
                                                                                                                                                                                                                """Set the performance hint.
                                                                                                                                                                                                        
                                                                                                                                                                                                                Args:
                                                                                                                                                                                                                    hint: performance hint to use
                                                                                                                                                                                                                """
                                                                                                                                                                                                                self.setPerformanceHint(PERFORMANCE_HINT.get_enum_value(hint))
                                                                                                                                                                                                        
                                                                                                                                                                                                            def get_performance_hint(self) -> PerformanceHintStr:
                                                                                                                                                                                                                """Return current performance hint.
                                                                                                                                                                                                        
                                                                                                                                                                                                                Returns:
                                                                                                                                                                                                                    performance hint
                                                                                                                                                                                                                """
                                                                                                                                                                                                                return PERFORMANCE_HINT.inverse[self.performanceHint()]
                                                                                                                                                                                                        

                                                                                                                                                                                                        get_performance_hint() -> PerformanceHintStr

                                                                                                                                                                                                        Return current performance hint.

                                                                                                                                                                                                        Source code in prettyqt/gui/statictext.py
                                                                                                                                                                                                        def get_performance_hint(self) -> PerformanceHintStr:
                                                                                                                                                                                                            """Return current performance hint.
                                                                                                                                                                                                        
                                                                                                                                                                                                            Returns:
                                                                                                                                                                                                                performance hint
                                                                                                                                                                                                            """
                                                                                                                                                                                                            return PERFORMANCE_HINT.inverse[self.performanceHint()]
                                                                                                                                                                                                        

                                                                                                                                                                                                        get_text_format() -> constants.TextFormatStr

                                                                                                                                                                                                        Return current text format.

                                                                                                                                                                                                        Possible values: "rich", "plain", "auto", "markdown"

                                                                                                                                                                                                        Source code in prettyqt/gui/statictext.py
                                                                                                                                                                                                        def get_text_format(self) -> constants.TextFormatStr:
                                                                                                                                                                                                            """Return current text format.
                                                                                                                                                                                                        
                                                                                                                                                                                                            Possible values: "rich", "plain", "auto", "markdown"
                                                                                                                                                                                                        
                                                                                                                                                                                                            Returns:
                                                                                                                                                                                                                text format
                                                                                                                                                                                                            """
                                                                                                                                                                                                            return constants.TEXT_FORMAT.inverse[self.textFormat()]
                                                                                                                                                                                                        

                                                                                                                                                                                                        set_performance_hint(hint: PerformanceHintStr | QtGui.QStaticText.PerformanceHint)

                                                                                                                                                                                                        Set the performance hint.

                                                                                                                                                                                                        Parameters:

                                                                                                                                                                                                        Name Type Description Default
                                                                                                                                                                                                        hint PerformanceHintStr | PerformanceHint

                                                                                                                                                                                                        performance hint to use

                                                                                                                                                                                                        required
                                                                                                                                                                                                        Source code in prettyqt/gui/statictext.py
                                                                                                                                                                                                        def set_performance_hint(
                                                                                                                                                                                                            self, hint: PerformanceHintStr | QtGui.QStaticText.PerformanceHint
                                                                                                                                                                                                        ):
                                                                                                                                                                                                            """Set the performance hint.
                                                                                                                                                                                                        
                                                                                                                                                                                                            Args:
                                                                                                                                                                                                                hint: performance hint to use
                                                                                                                                                                                                            """
                                                                                                                                                                                                            self.setPerformanceHint(PERFORMANCE_HINT.get_enum_value(hint))
                                                                                                                                                                                                        

                                                                                                                                                                                                        set_text_format(text_format: constants.TextFormatStr | constants.TextFormat)

                                                                                                                                                                                                        Set the text format.

                                                                                                                                                                                                        Allowed values are "rich", "plain", "auto", "markdown"

                                                                                                                                                                                                        Parameters:

                                                                                                                                                                                                        Name Type Description Default
                                                                                                                                                                                                        text_format TextFormatStr | TextFormat

                                                                                                                                                                                                        text format to use

                                                                                                                                                                                                        required
                                                                                                                                                                                                        Source code in prettyqt/gui/statictext.py
                                                                                                                                                                                                        def set_text_format(
                                                                                                                                                                                                            self, text_format: constants.TextFormatStr | constants.TextFormat
                                                                                                                                                                                                        ):
                                                                                                                                                                                                            """Set the text format.
                                                                                                                                                                                                        
                                                                                                                                                                                                            Allowed values are "rich", "plain", "auto", "markdown"
                                                                                                                                                                                                        
                                                                                                                                                                                                            Args:
                                                                                                                                                                                                                text_format: text format to use
                                                                                                                                                                                                            """
                                                                                                                                                                                                            self.setTextFormat(constants.TEXT_FORMAT.get_enum_value(text_format))
                                                                                                                                                                                                        

                                                                                                                                                                                                        StyleHintsMixin

                                                                                                                                                                                                        Bases: ObjectMixin, _StyleHintsBase

                                                                                                                                                                                                        Source code in prettyqt/gui/stylehints.py
                                                                                                                                                                                                        class StyleHintsMixin(core.ObjectMixin, _StyleHintsBase):
                                                                                                                                                                                                            def get_color_scheme(self) -> constants.ColorSchemeStr:
                                                                                                                                                                                                                """Return current color scheme of the system.
                                                                                                                                                                                                        
                                                                                                                                                                                                                Returns:
                                                                                                                                                                                                                    color scheme
                                                                                                                                                                                                                """
                                                                                                                                                                                                                return constants.COLOR_SCHEME.inverse[self.colorScheme()]
                                                                                                                                                                                                        
                                                                                                                                                                                                            def set_color_scheme(self, scheme: constants.ColorSchemeStr | constants.ColorScheme):
                                                                                                                                                                                                                """Set color scheme override.
                                                                                                                                                                                                        
                                                                                                                                                                                                                Args:
                                                                                                                                                                                                                    scheme: color scheme
                                                                                                                                                                                                                """
                                                                                                                                                                                                                self.setColorScheme(constants.COLOR_SCHEME.get_enum_value(scheme))
                                                                                                                                                                                                        
                                                                                                                                                                                                            def unset_color_scheme(self):
                                                                                                                                                                                                                """Reset color scheme override to platform default."""
                                                                                                                                                                                                                self.unsetColorScheme()
                                                                                                                                                                                                        
                                                                                                                                                                                                            def get_accessibility(self) -> gui.AccessibilityHints:
                                                                                                                                                                                                                """Return accessibility hints."""
                                                                                                                                                                                                                return gui.AccessibilityHints(self.accessibility())
                                                                                                                                                                                                        
                                                                                                                                                                                                            def get_context_menu_trigger(self) -> ContextMenuTriggerStr:
                                                                                                                                                                                                                """Return current context menu trigger."""
                                                                                                                                                                                                                return CONTEXT_MENU_TRIGGER.inverse[self.contextMenuTrigger()]
                                                                                                                                                                                                        
                                                                                                                                                                                                            def set_context_menu_trigger(
                                                                                                                                                                                                                self, trigger: ContextMenuTriggerStr | QtCore.Qt.ContextMenuTrigger
                                                                                                                                                                                                            ):
                                                                                                                                                                                                                """Set context menu trigger.
                                                                                                                                                                                                        
                                                                                                                                                                                                                Args:
                                                                                                                                                                                                                    trigger: context menu trigger
                                                                                                                                                                                                                """
                                                                                                                                                                                                                self.setContextMenuTrigger(CONTEXT_MENU_TRIGGER.get_enum_value(trigger))
                                                                                                                                                                                                        
                                                                                                                                                                                                            def get_tab_focus_behavior(self) -> constants.TabFocusBehaviorStr:
                                                                                                                                                                                                                """Return current focus behavior on press of the tab key.
                                                                                                                                                                                                        
                                                                                                                                                                                                                Returns:
                                                                                                                                                                                                                    focus behavior
                                                                                                                                                                                                                """
                                                                                                                                                                                                                return constants.TAB_FOCUS_BEHAVIOR.inverse[self.tabFocusBehavior()]
                                                                                                                                                                                                        

                                                                                                                                                                                                        get_accessibility() -> gui.AccessibilityHints

                                                                                                                                                                                                        Return accessibility hints.

                                                                                                                                                                                                        Source code in prettyqt/gui/stylehints.py
                                                                                                                                                                                                        def get_accessibility(self) -> gui.AccessibilityHints:
                                                                                                                                                                                                            """Return accessibility hints."""
                                                                                                                                                                                                            return gui.AccessibilityHints(self.accessibility())
                                                                                                                                                                                                        

                                                                                                                                                                                                        get_color_scheme() -> constants.ColorSchemeStr

                                                                                                                                                                                                        Return current color scheme of the system.

                                                                                                                                                                                                        Source code in prettyqt/gui/stylehints.py
                                                                                                                                                                                                        def get_color_scheme(self) -> constants.ColorSchemeStr:
                                                                                                                                                                                                            """Return current color scheme of the system.
                                                                                                                                                                                                        
                                                                                                                                                                                                            Returns:
                                                                                                                                                                                                                color scheme
                                                                                                                                                                                                            """
                                                                                                                                                                                                            return constants.COLOR_SCHEME.inverse[self.colorScheme()]
                                                                                                                                                                                                        

                                                                                                                                                                                                        get_context_menu_trigger() -> ContextMenuTriggerStr

                                                                                                                                                                                                        Return current context menu trigger.

                                                                                                                                                                                                        Source code in prettyqt/gui/stylehints.py
                                                                                                                                                                                                        def get_context_menu_trigger(self) -> ContextMenuTriggerStr:
                                                                                                                                                                                                            """Return current context menu trigger."""
                                                                                                                                                                                                            return CONTEXT_MENU_TRIGGER.inverse[self.contextMenuTrigger()]
                                                                                                                                                                                                        

                                                                                                                                                                                                        get_tab_focus_behavior() -> constants.TabFocusBehaviorStr

                                                                                                                                                                                                        Return current focus behavior on press of the tab key.

                                                                                                                                                                                                        Source code in prettyqt/gui/stylehints.py
                                                                                                                                                                                                        def get_tab_focus_behavior(self) -> constants.TabFocusBehaviorStr:
                                                                                                                                                                                                            """Return current focus behavior on press of the tab key.
                                                                                                                                                                                                        
                                                                                                                                                                                                            Returns:
                                                                                                                                                                                                                focus behavior
                                                                                                                                                                                                            """
                                                                                                                                                                                                            return constants.TAB_FOCUS_BEHAVIOR.inverse[self.tabFocusBehavior()]
                                                                                                                                                                                                        

                                                                                                                                                                                                        set_color_scheme(scheme: constants.ColorSchemeStr | constants.ColorScheme)

                                                                                                                                                                                                        Set color scheme override.

                                                                                                                                                                                                        Parameters:

                                                                                                                                                                                                        Name Type Description Default
                                                                                                                                                                                                        scheme ColorSchemeStr | ColorScheme

                                                                                                                                                                                                        color scheme

                                                                                                                                                                                                        required
                                                                                                                                                                                                        Source code in prettyqt/gui/stylehints.py
                                                                                                                                                                                                        def set_color_scheme(self, scheme: constants.ColorSchemeStr | constants.ColorScheme):
                                                                                                                                                                                                            """Set color scheme override.
                                                                                                                                                                                                        
                                                                                                                                                                                                            Args:
                                                                                                                                                                                                                scheme: color scheme
                                                                                                                                                                                                            """
                                                                                                                                                                                                            self.setColorScheme(constants.COLOR_SCHEME.get_enum_value(scheme))
                                                                                                                                                                                                        

                                                                                                                                                                                                        set_context_menu_trigger(trigger: ContextMenuTriggerStr | QtCore.Qt.ContextMenuTrigger)

                                                                                                                                                                                                        Set context menu trigger.

                                                                                                                                                                                                        Parameters:

                                                                                                                                                                                                        Name Type Description Default
                                                                                                                                                                                                        trigger ContextMenuTriggerStr | ContextMenuTrigger

                                                                                                                                                                                                        context menu trigger

                                                                                                                                                                                                        required
                                                                                                                                                                                                        Source code in prettyqt/gui/stylehints.py
                                                                                                                                                                                                        def set_context_menu_trigger(
                                                                                                                                                                                                            self, trigger: ContextMenuTriggerStr | QtCore.Qt.ContextMenuTrigger
                                                                                                                                                                                                        ):
                                                                                                                                                                                                            """Set context menu trigger.
                                                                                                                                                                                                        
                                                                                                                                                                                                            Args:
                                                                                                                                                                                                                trigger: context menu trigger
                                                                                                                                                                                                            """
                                                                                                                                                                                                            self.setContextMenuTrigger(CONTEXT_MENU_TRIGGER.get_enum_value(trigger))
                                                                                                                                                                                                        

                                                                                                                                                                                                        unset_color_scheme()

                                                                                                                                                                                                        Reset color scheme override to platform default.

                                                                                                                                                                                                        Source code in prettyqt/gui/stylehints.py
                                                                                                                                                                                                        def unset_color_scheme(self):
                                                                                                                                                                                                            """Reset color scheme override to platform default."""
                                                                                                                                                                                                            self.unsetColorScheme()
                                                                                                                                                                                                        

                                                                                                                                                                                                        SurfaceMixin

                                                                                                                                                                                                        Bases: _SurfaceBase

                                                                                                                                                                                                        Source code in prettyqt/gui/surface.py
                                                                                                                                                                                                        class SurfaceMixin(_SurfaceBase):
                                                                                                                                                                                                            def __repr__(self):
                                                                                                                                                                                                                return get_repr(self)
                                                                                                                                                                                                        
                                                                                                                                                                                                            def get_surface_class(self) -> SurfaceClassStr:
                                                                                                                                                                                                                """Get the current surface class.
                                                                                                                                                                                                        
                                                                                                                                                                                                                Returns:
                                                                                                                                                                                                                    surface class
                                                                                                                                                                                                                """
                                                                                                                                                                                                                return SURFACE_CLASS.inverse[self.surfaceClass()]
                                                                                                                                                                                                        
                                                                                                                                                                                                            def get_surface_type(self) -> SurfaceTypeStr:
                                                                                                                                                                                                                """Get the current surface type.
                                                                                                                                                                                                        
                                                                                                                                                                                                                Returns:
                                                                                                                                                                                                                    surface type
                                                                                                                                                                                                                """
                                                                                                                                                                                                                return SURFACE_TYPES.inverse[self.surfaceType()]
                                                                                                                                                                                                        

                                                                                                                                                                                                        get_surface_class() -> SurfaceClassStr

                                                                                                                                                                                                        Get the current surface class.

                                                                                                                                                                                                        Source code in prettyqt/gui/surface.py
                                                                                                                                                                                                        def get_surface_class(self) -> SurfaceClassStr:
                                                                                                                                                                                                            """Get the current surface class.
                                                                                                                                                                                                        
                                                                                                                                                                                                            Returns:
                                                                                                                                                                                                                surface class
                                                                                                                                                                                                            """
                                                                                                                                                                                                            return SURFACE_CLASS.inverse[self.surfaceClass()]
                                                                                                                                                                                                        

                                                                                                                                                                                                        get_surface_type() -> SurfaceTypeStr

                                                                                                                                                                                                        Get the current surface type.

                                                                                                                                                                                                        Source code in prettyqt/gui/surface.py
                                                                                                                                                                                                        def get_surface_type(self) -> SurfaceTypeStr:
                                                                                                                                                                                                            """Get the current surface type.
                                                                                                                                                                                                        
                                                                                                                                                                                                            Returns:
                                                                                                                                                                                                                surface type
                                                                                                                                                                                                            """
                                                                                                                                                                                                            return SURFACE_TYPES.inverse[self.surfaceType()]
                                                                                                                                                                                                        

                                                                                                                                                                                                        TextBlock

                                                                                                                                                                                                        Bases: QTextBlock

                                                                                                                                                                                                        Source code in prettyqt/gui/textblock.py
                                                                                                                                                                                                        class TextBlock(QtGui.QTextBlock):
                                                                                                                                                                                                            def __repr__(self):
                                                                                                                                                                                                                return get_repr(self, self.text())
                                                                                                                                                                                                        
                                                                                                                                                                                                            def __contains__(self, position: int):
                                                                                                                                                                                                                return self.contains(position)
                                                                                                                                                                                                        
                                                                                                                                                                                                            def __bool__(self):
                                                                                                                                                                                                                return self.isValid()
                                                                                                                                                                                                        
                                                                                                                                                                                                            def __str__(self):
                                                                                                                                                                                                                return self.text()
                                                                                                                                                                                                        
                                                                                                                                                                                                            def get_previous(self) -> TextBlock:
                                                                                                                                                                                                                return TextBlock(self.previous())
                                                                                                                                                                                                        
                                                                                                                                                                                                            def get_next(self) -> TextBlock:
                                                                                                                                                                                                                return TextBlock(self.next())
                                                                                                                                                                                                        
                                                                                                                                                                                                            def get_text_direction(self) -> constants.LayoutDirectionStr:
                                                                                                                                                                                                                return constants.LAYOUT_DIRECTION.inverse[self.textDirection()]
                                                                                                                                                                                                        
                                                                                                                                                                                                            def set_user_data(self, data):
                                                                                                                                                                                                                if isinstance(data, QtGui.QTextBlockUserData):
                                                                                                                                                                                                                    self.setUserData(data)
                                                                                                                                                                                                                    return
                                                                                                                                                                                                                user_data = UserData(data)
                                                                                                                                                                                                                self.setUserData(user_data)
                                                                                                                                                                                                        
                                                                                                                                                                                                            def get_user_data(self):
                                                                                                                                                                                                                user_data = self.userData()
                                                                                                                                                                                                                return user_data.data if isinstance(user_data, UserData) else user_data
                                                                                                                                                                                                        
                                                                                                                                                                                                            @contextlib.contextmanager
                                                                                                                                                                                                            def edit_user_state(self):
                                                                                                                                                                                                                state = self.userState()
                                                                                                                                                                                                                try:
                                                                                                                                                                                                                    yield state
                                                                                                                                                                                                                finally:
                                                                                                                                                                                                                    self.setUserState(state)
                                                                                                                                                                                                        
                                                                                                                                                                                                            def get_state(self) -> int:
                                                                                                                                                                                                                """Get the user state, generally used for syntax highlighting.
                                                                                                                                                                                                        
                                                                                                                                                                                                                :return: The block state
                                                                                                                                                                                                                """
                                                                                                                                                                                                                state = self.userState()
                                                                                                                                                                                                                return state if state == -1 else state & 0x0000FFFF
                                                                                                                                                                                                        
                                                                                                                                                                                                            def set_state(self, state: int):
                                                                                                                                                                                                                """Set the user state, generally used for syntax highlighting.
                                                                                                                                                                                                        
                                                                                                                                                                                                                :param state: new state value.
                                                                                                                                                                                                                """
                                                                                                                                                                                                                user_state = self.userState()
                                                                                                                                                                                                                if user_state == -1:
                                                                                                                                                                                                                    user_state = 0
                                                                                                                                                                                                                higher_part = user_state & 0x7FFF0000
                                                                                                                                                                                                                state &= 0x0000FFFF
                                                                                                                                                                                                                state |= higher_part
                                                                                                                                                                                                                self.setUserState(state)
                                                                                                                                                                                                        
                                                                                                                                                                                                            def get_fold_level(self) -> int:
                                                                                                                                                                                                                """Get the block fold level.
                                                                                                                                                                                                        
                                                                                                                                                                                                                :return: The block fold level
                                                                                                                                                                                                                """
                                                                                                                                                                                                                state = self.userState()
                                                                                                                                                                                                                if state == -1:
                                                                                                                                                                                                                    state = 0
                                                                                                                                                                                                                return (state & 0x03FF0000) >> 16
                                                                                                                                                                                                        
                                                                                                                                                                                                            def set_fold_level(self, val: int):
                                                                                                                                                                                                                """Set the block fold level.
                                                                                                                                                                                                        
                                                                                                                                                                                                                :param val: The new fold level [0-7]
                                                                                                                                                                                                                """
                                                                                                                                                                                                                state = self.userState()
                                                                                                                                                                                                                if state == -1:
                                                                                                                                                                                                                    state = 0
                                                                                                                                                                                                                val = min(val, 0x3FF)
                                                                                                                                                                                                                state &= 0x7C00FFFF
                                                                                                                                                                                                                state |= val << 16
                                                                                                                                                                                                                self.setUserState(state)
                                                                                                                                                                                                        
                                                                                                                                                                                                            def is_fold_trigger(self) -> bool:
                                                                                                                                                                                                                """Check if the block is a fold trigger.
                                                                                                                                                                                                        
                                                                                                                                                                                                                :return: True if the block is a fold trigger (represented as a node in
                                                                                                                                                                                                                    the fold panel)
                                                                                                                                                                                                                """
                                                                                                                                                                                                                state = self.userState()
                                                                                                                                                                                                                if state == -1:
                                                                                                                                                                                                                    state = 0
                                                                                                                                                                                                                return bool(state & 0x04000000)
                                                                                                                                                                                                        
                                                                                                                                                                                                            def set_fold_trigger(self, val: int):
                                                                                                                                                                                                                """Set the block fold trigger flag (True means the block is a fold trigger).
                                                                                                                                                                                                        
                                                                                                                                                                                                                :param val: value to set
                                                                                                                                                                                                                """
                                                                                                                                                                                                                state = self.userState()
                                                                                                                                                                                                                if state == -1:
                                                                                                                                                                                                                    state = 0
                                                                                                                                                                                                                state &= 0x7BFFFFFF
                                                                                                                                                                                                                state |= val << 26
                                                                                                                                                                                                                self.setUserState(state)
                                                                                                                                                                                                        
                                                                                                                                                                                                            def is_collapsed(self) -> bool:
                                                                                                                                                                                                                """Check if the block is expanded or collased.
                                                                                                                                                                                                        
                                                                                                                                                                                                                :return: False for an open trigger, True for for closed trigger
                                                                                                                                                                                                                """
                                                                                                                                                                                                                state = self.userState()
                                                                                                                                                                                                                if state == -1:
                                                                                                                                                                                                                    state = 0
                                                                                                                                                                                                                return bool(state & 0x08000000)
                                                                                                                                                                                                        
                                                                                                                                                                                                            def set_collapsed(self, val: int):
                                                                                                                                                                                                                """Set the fold trigger state (collapsed or expanded).
                                                                                                                                                                                                        
                                                                                                                                                                                                                :param val: The new trigger state (True=collapsed, False=expanded)
                                                                                                                                                                                                                """
                                                                                                                                                                                                                state = self.userState()
                                                                                                                                                                                                                if state == -1:
                                                                                                                                                                                                                    state = 0
                                                                                                                                                                                                                state &= 0x77FFFFFF
                                                                                                                                                                                                                state |= val << 27
                                                                                                                                                                                                                self.setUserState(state)
                                                                                                                                                                                                        
                                                                                                                                                                                                            def find_parent_scope(self, limit: int = 5000) -> TextBlock | None:
                                                                                                                                                                                                                """Find parent scope, if the block is not a fold trigger."""
                                                                                                                                                                                                                # if we moved up for more than n lines, just give up otherwise this
                                                                                                                                                                                                                # would take too much time.
                                                                                                                                                                                                                counter = 0
                                                                                                                                                                                                                original = TextBlock(self)
                                                                                                                                                                                                                start = TextBlock(self)
                                                                                                                                                                                                                if not self.is_fold_trigger():
                                                                                                                                                                                                                    # search level of next non blank line
                                                                                                                                                                                                                    while not start.text().strip() and start.isValid():
                                                                                                                                                                                                                        start = TextBlock(start.next())
                                                                                                                                                                                                                    ref_level = self.get_fold_level() - 1
                                                                                                                                                                                                                    start = original
                                                                                                                                                                                                                    while (
                                                                                                                                                                                                                        start.blockNumber()
                                                                                                                                                                                                                        and counter < limit
                                                                                                                                                                                                                        and (not start.is_fold_trigger() or start.get_fold_level() > ref_level)
                                                                                                                                                                                                                    ):
                                                                                                                                                                                                                        counter += 1
                                                                                                                                                                                                                        start = TextBlock(start.previous())
                                                                                                                                                                                                                return TextBlock(start) if counter < limit else None
                                                                                                                                                                                                        

                                                                                                                                                                                                        find_parent_scope(limit: int = 5000) -> TextBlock | None

                                                                                                                                                                                                        Find parent scope, if the block is not a fold trigger.

                                                                                                                                                                                                        Source code in prettyqt/gui/textblock.py
                                                                                                                                                                                                        def find_parent_scope(self, limit: int = 5000) -> TextBlock | None:
                                                                                                                                                                                                            """Find parent scope, if the block is not a fold trigger."""
                                                                                                                                                                                                            # if we moved up for more than n lines, just give up otherwise this
                                                                                                                                                                                                            # would take too much time.
                                                                                                                                                                                                            counter = 0
                                                                                                                                                                                                            original = TextBlock(self)
                                                                                                                                                                                                            start = TextBlock(self)
                                                                                                                                                                                                            if not self.is_fold_trigger():
                                                                                                                                                                                                                # search level of next non blank line
                                                                                                                                                                                                                while not start.text().strip() and start.isValid():
                                                                                                                                                                                                                    start = TextBlock(start.next())
                                                                                                                                                                                                                ref_level = self.get_fold_level() - 1
                                                                                                                                                                                                                start = original
                                                                                                                                                                                                                while (
                                                                                                                                                                                                                    start.blockNumber()
                                                                                                                                                                                                                    and counter < limit
                                                                                                                                                                                                                    and (not start.is_fold_trigger() or start.get_fold_level() > ref_level)
                                                                                                                                                                                                                ):
                                                                                                                                                                                                                    counter += 1
                                                                                                                                                                                                                    start = TextBlock(start.previous())
                                                                                                                                                                                                            return TextBlock(start) if counter < limit else None
                                                                                                                                                                                                        

                                                                                                                                                                                                        get_fold_level() -> int

                                                                                                                                                                                                        Get the block fold level.

                                                                                                                                                                                                        :return: The block fold level

                                                                                                                                                                                                        Source code in prettyqt/gui/textblock.py
                                                                                                                                                                                                        def get_fold_level(self) -> int:
                                                                                                                                                                                                            """Get the block fold level.
                                                                                                                                                                                                        
                                                                                                                                                                                                            :return: The block fold level
                                                                                                                                                                                                            """
                                                                                                                                                                                                            state = self.userState()
                                                                                                                                                                                                            if state == -1:
                                                                                                                                                                                                                state = 0
                                                                                                                                                                                                            return (state & 0x03FF0000) >> 16
                                                                                                                                                                                                        

                                                                                                                                                                                                        get_state() -> int

                                                                                                                                                                                                        Get the user state, generally used for syntax highlighting.

                                                                                                                                                                                                        :return: The block state

                                                                                                                                                                                                        Source code in prettyqt/gui/textblock.py
                                                                                                                                                                                                        def get_state(self) -> int:
                                                                                                                                                                                                            """Get the user state, generally used for syntax highlighting.
                                                                                                                                                                                                        
                                                                                                                                                                                                            :return: The block state
                                                                                                                                                                                                            """
                                                                                                                                                                                                            state = self.userState()
                                                                                                                                                                                                            return state if state == -1 else state & 0x0000FFFF
                                                                                                                                                                                                        

                                                                                                                                                                                                        is_collapsed() -> bool

                                                                                                                                                                                                        Check if the block is expanded or collased.

                                                                                                                                                                                                        :return: False for an open trigger, True for for closed trigger

                                                                                                                                                                                                        Source code in prettyqt/gui/textblock.py
                                                                                                                                                                                                        def is_collapsed(self) -> bool:
                                                                                                                                                                                                            """Check if the block is expanded or collased.
                                                                                                                                                                                                        
                                                                                                                                                                                                            :return: False for an open trigger, True for for closed trigger
                                                                                                                                                                                                            """
                                                                                                                                                                                                            state = self.userState()
                                                                                                                                                                                                            if state == -1:
                                                                                                                                                                                                                state = 0
                                                                                                                                                                                                            return bool(state & 0x08000000)
                                                                                                                                                                                                        

                                                                                                                                                                                                        is_fold_trigger() -> bool

                                                                                                                                                                                                        Check if the block is a fold trigger.

                                                                                                                                                                                                        :return: True if the block is a fold trigger (represented as a node in the fold panel)

                                                                                                                                                                                                        Source code in prettyqt/gui/textblock.py
                                                                                                                                                                                                        def is_fold_trigger(self) -> bool:
                                                                                                                                                                                                            """Check if the block is a fold trigger.
                                                                                                                                                                                                        
                                                                                                                                                                                                            :return: True if the block is a fold trigger (represented as a node in
                                                                                                                                                                                                                the fold panel)
                                                                                                                                                                                                            """
                                                                                                                                                                                                            state = self.userState()
                                                                                                                                                                                                            if state == -1:
                                                                                                                                                                                                                state = 0
                                                                                                                                                                                                            return bool(state & 0x04000000)
                                                                                                                                                                                                        

                                                                                                                                                                                                        set_collapsed(val: int)

                                                                                                                                                                                                        Set the fold trigger state (collapsed or expanded).

                                                                                                                                                                                                        :param val: The new trigger state (True=collapsed, False=expanded)

                                                                                                                                                                                                        Source code in prettyqt/gui/textblock.py
                                                                                                                                                                                                        def set_collapsed(self, val: int):
                                                                                                                                                                                                            """Set the fold trigger state (collapsed or expanded).
                                                                                                                                                                                                        
                                                                                                                                                                                                            :param val: The new trigger state (True=collapsed, False=expanded)
                                                                                                                                                                                                            """
                                                                                                                                                                                                            state = self.userState()
                                                                                                                                                                                                            if state == -1:
                                                                                                                                                                                                                state = 0
                                                                                                                                                                                                            state &= 0x77FFFFFF
                                                                                                                                                                                                            state |= val << 27
                                                                                                                                                                                                            self.setUserState(state)
                                                                                                                                                                                                        

                                                                                                                                                                                                        set_fold_level(val: int)

                                                                                                                                                                                                        Set the block fold level.

                                                                                                                                                                                                        :param val: The new fold level [0-7]

                                                                                                                                                                                                        Source code in prettyqt/gui/textblock.py
                                                                                                                                                                                                        def set_fold_level(self, val: int):
                                                                                                                                                                                                            """Set the block fold level.
                                                                                                                                                                                                        
                                                                                                                                                                                                            :param val: The new fold level [0-7]
                                                                                                                                                                                                            """
                                                                                                                                                                                                            state = self.userState()
                                                                                                                                                                                                            if state == -1:
                                                                                                                                                                                                                state = 0
                                                                                                                                                                                                            val = min(val, 0x3FF)
                                                                                                                                                                                                            state &= 0x7C00FFFF
                                                                                                                                                                                                            state |= val << 16
                                                                                                                                                                                                            self.setUserState(state)
                                                                                                                                                                                                        

                                                                                                                                                                                                        set_fold_trigger(val: int)

                                                                                                                                                                                                        Set the block fold trigger flag (True means the block is a fold trigger).

                                                                                                                                                                                                        :param val: value to set

                                                                                                                                                                                                        Source code in prettyqt/gui/textblock.py
                                                                                                                                                                                                        def set_fold_trigger(self, val: int):
                                                                                                                                                                                                            """Set the block fold trigger flag (True means the block is a fold trigger).
                                                                                                                                                                                                        
                                                                                                                                                                                                            :param val: value to set
                                                                                                                                                                                                            """
                                                                                                                                                                                                            state = self.userState()
                                                                                                                                                                                                            if state == -1:
                                                                                                                                                                                                                state = 0
                                                                                                                                                                                                            state &= 0x7BFFFFFF
                                                                                                                                                                                                            state |= val << 26
                                                                                                                                                                                                            self.setUserState(state)
                                                                                                                                                                                                        

                                                                                                                                                                                                        set_state(state: int)

                                                                                                                                                                                                        Set the user state, generally used for syntax highlighting.

                                                                                                                                                                                                        :param state: new state value.

                                                                                                                                                                                                        Source code in prettyqt/gui/textblock.py
                                                                                                                                                                                                        def set_state(self, state: int):
                                                                                                                                                                                                            """Set the user state, generally used for syntax highlighting.
                                                                                                                                                                                                        
                                                                                                                                                                                                            :param state: new state value.
                                                                                                                                                                                                            """
                                                                                                                                                                                                            user_state = self.userState()
                                                                                                                                                                                                            if user_state == -1:
                                                                                                                                                                                                                user_state = 0
                                                                                                                                                                                                            higher_part = user_state & 0x7FFF0000
                                                                                                                                                                                                            state &= 0x0000FFFF
                                                                                                                                                                                                            state |= higher_part
                                                                                                                                                                                                            self.setUserState(state)
                                                                                                                                                                                                        

                                                                                                                                                                                                        TextBlockFormat

                                                                                                                                                                                                        Bases: TextFormatMixin, QTextBlockFormat

                                                                                                                                                                                                        Source code in prettyqt/gui/textblockformat.py
                                                                                                                                                                                                        class TextBlockFormat(gui.TextFormatMixin, gui.QTextBlockFormat):
                                                                                                                                                                                                            def set_marker(self, marker: MarkerTypeStr | gui.QTextBlockFormat.MarkerType):
                                                                                                                                                                                                                """Set the marker.
                                                                                                                                                                                                        
                                                                                                                                                                                                                Args:
                                                                                                                                                                                                                    marker: marker
                                                                                                                                                                                                                """
                                                                                                                                                                                                                self.setMarker(MARKER_TYPE.get_enum_value(marker))
                                                                                                                                                                                                        
                                                                                                                                                                                                            def get_marker(self) -> MarkerTypeStr:
                                                                                                                                                                                                                """Get current marker.
                                                                                                                                                                                                        
                                                                                                                                                                                                                Returns:
                                                                                                                                                                                                                    current marker
                                                                                                                                                                                                                """
                                                                                                                                                                                                                return MARKER_TYPE.inverse[self.marker()]
                                                                                                                                                                                                        
                                                                                                                                                                                                            def set_alignment(self, alignment: constants.AlignmentStr | constants.AlignmentFlag):
                                                                                                                                                                                                                """Set the alignment of the format.
                                                                                                                                                                                                        
                                                                                                                                                                                                                Args:
                                                                                                                                                                                                                    alignment: alignment for the format
                                                                                                                                                                                                                """
                                                                                                                                                                                                                self.setAlignment(constants.ALIGNMENTS.get_enum_value(alignment))
                                                                                                                                                                                                        
                                                                                                                                                                                                            def get_alignment(self) -> constants.AlignmentStr:
                                                                                                                                                                                                                """Return current alignment.
                                                                                                                                                                                                        
                                                                                                                                                                                                                Returns:
                                                                                                                                                                                                                    alignment
                                                                                                                                                                                                                """
                                                                                                                                                                                                                return constants.ALIGNMENTS.inverse[self.alignment()]
                                                                                                                                                                                                        
                                                                                                                                                                                                            def set_page_break_policy(
                                                                                                                                                                                                                self, policy: gui.textformat.PageBreakFlagStr | gui.QTextFormat.PageBreakFlag
                                                                                                                                                                                                            ):
                                                                                                                                                                                                                """Set page break policy.
                                                                                                                                                                                                        
                                                                                                                                                                                                                Args:
                                                                                                                                                                                                                    policy: page break policy
                                                                                                                                                                                                                """
                                                                                                                                                                                                                self.setPageBreakPolicy(gui.textformat.PAGE_BREAK_FLAG.get_enum_value(policy))
                                                                                                                                                                                                        
                                                                                                                                                                                                            def get_page_break_policy(self) -> gui.textformat.PageBreakFlagStr:
                                                                                                                                                                                                                """Get the current page break policy.
                                                                                                                                                                                                        
                                                                                                                                                                                                                Returns:
                                                                                                                                                                                                                    page break policy
                                                                                                                                                                                                                """
                                                                                                                                                                                                                return gui.textformat.PAGE_BREAK_FLAG.inverse[self.pageBreakPolicy()]
                                                                                                                                                                                                        

                                                                                                                                                                                                        get_alignment() -> constants.AlignmentStr

                                                                                                                                                                                                        Return current alignment.

                                                                                                                                                                                                        Source code in prettyqt/gui/textblockformat.py
                                                                                                                                                                                                        def get_alignment(self) -> constants.AlignmentStr:
                                                                                                                                                                                                            """Return current alignment.
                                                                                                                                                                                                        
                                                                                                                                                                                                            Returns:
                                                                                                                                                                                                                alignment
                                                                                                                                                                                                            """
                                                                                                                                                                                                            return constants.ALIGNMENTS.inverse[self.alignment()]
                                                                                                                                                                                                        

                                                                                                                                                                                                        get_marker() -> MarkerTypeStr

                                                                                                                                                                                                        Get current marker.

                                                                                                                                                                                                        Source code in prettyqt/gui/textblockformat.py
                                                                                                                                                                                                        def get_marker(self) -> MarkerTypeStr:
                                                                                                                                                                                                            """Get current marker.
                                                                                                                                                                                                        
                                                                                                                                                                                                            Returns:
                                                                                                                                                                                                                current marker
                                                                                                                                                                                                            """
                                                                                                                                                                                                            return MARKER_TYPE.inverse[self.marker()]
                                                                                                                                                                                                        

                                                                                                                                                                                                        get_page_break_policy() -> gui.textformat.PageBreakFlagStr

                                                                                                                                                                                                        Get the current page break policy.

                                                                                                                                                                                                        Source code in prettyqt/gui/textblockformat.py
                                                                                                                                                                                                        def get_page_break_policy(self) -> gui.textformat.PageBreakFlagStr:
                                                                                                                                                                                                            """Get the current page break policy.
                                                                                                                                                                                                        
                                                                                                                                                                                                            Returns:
                                                                                                                                                                                                                page break policy
                                                                                                                                                                                                            """
                                                                                                                                                                                                            return gui.textformat.PAGE_BREAK_FLAG.inverse[self.pageBreakPolicy()]
                                                                                                                                                                                                        

                                                                                                                                                                                                        set_alignment(alignment: constants.AlignmentStr | constants.AlignmentFlag)

                                                                                                                                                                                                        Set the alignment of the format.

                                                                                                                                                                                                        Parameters:

                                                                                                                                                                                                        Name Type Description Default
                                                                                                                                                                                                        alignment AlignmentStr | AlignmentFlag

                                                                                                                                                                                                        alignment for the format

                                                                                                                                                                                                        required
                                                                                                                                                                                                        Source code in prettyqt/gui/textblockformat.py
                                                                                                                                                                                                        def set_alignment(self, alignment: constants.AlignmentStr | constants.AlignmentFlag):
                                                                                                                                                                                                            """Set the alignment of the format.
                                                                                                                                                                                                        
                                                                                                                                                                                                            Args:
                                                                                                                                                                                                                alignment: alignment for the format
                                                                                                                                                                                                            """
                                                                                                                                                                                                            self.setAlignment(constants.ALIGNMENTS.get_enum_value(alignment))
                                                                                                                                                                                                        

                                                                                                                                                                                                        set_marker(marker: MarkerTypeStr | gui.QTextBlockFormat.MarkerType)

                                                                                                                                                                                                        Set the marker.

                                                                                                                                                                                                        Parameters:

                                                                                                                                                                                                        Name Type Description Default
                                                                                                                                                                                                        marker MarkerTypeStr | MarkerType

                                                                                                                                                                                                        marker

                                                                                                                                                                                                        required
                                                                                                                                                                                                        Source code in prettyqt/gui/textblockformat.py
                                                                                                                                                                                                        def set_marker(self, marker: MarkerTypeStr | gui.QTextBlockFormat.MarkerType):
                                                                                                                                                                                                            """Set the marker.
                                                                                                                                                                                                        
                                                                                                                                                                                                            Args:
                                                                                                                                                                                                                marker: marker
                                                                                                                                                                                                            """
                                                                                                                                                                                                            self.setMarker(MARKER_TYPE.get_enum_value(marker))
                                                                                                                                                                                                        

                                                                                                                                                                                                        set_page_break_policy(policy: gui.textformat.PageBreakFlagStr | gui.QTextFormat.PageBreakFlag)

                                                                                                                                                                                                        Set page break policy.

                                                                                                                                                                                                        Parameters:

                                                                                                                                                                                                        Name Type Description Default
                                                                                                                                                                                                        policy PageBreakFlagStr | PageBreakFlag

                                                                                                                                                                                                        page break policy

                                                                                                                                                                                                        required
                                                                                                                                                                                                        Source code in prettyqt/gui/textblockformat.py
                                                                                                                                                                                                        def set_page_break_policy(
                                                                                                                                                                                                            self, policy: gui.textformat.PageBreakFlagStr | gui.QTextFormat.PageBreakFlag
                                                                                                                                                                                                        ):
                                                                                                                                                                                                            """Set page break policy.
                                                                                                                                                                                                        
                                                                                                                                                                                                            Args:
                                                                                                                                                                                                                policy: page break policy
                                                                                                                                                                                                            """
                                                                                                                                                                                                            self.setPageBreakPolicy(gui.textformat.PAGE_BREAK_FLAG.get_enum_value(policy))
                                                                                                                                                                                                        

                                                                                                                                                                                                        TextBlockUserData

                                                                                                                                                                                                        Bases: QTextBlockUserData

                                                                                                                                                                                                        Storage for the user data associated with each line.

                                                                                                                                                                                                        Source code in prettyqt/gui/textblockuserdata.py
                                                                                                                                                                                                        class TextBlockUserData(QtGui.QTextBlockUserData):
                                                                                                                                                                                                            """Storage for the user data associated with each line."""
                                                                                                                                                                                                        
                                                                                                                                                                                                            def __init__(self, **kwds):
                                                                                                                                                                                                                for key, value in kwds.items():
                                                                                                                                                                                                                    setattr(self, key, value)
                                                                                                                                                                                                                super().__init__()
                                                                                                                                                                                                        
                                                                                                                                                                                                            def __repr__(self):
                                                                                                                                                                                                                kwargs = {i: getattr(self, i) for i in dir(self) if not i.startswith("__")}
                                                                                                                                                                                                                return get_repr(self, **kwargs)
                                                                                                                                                                                                        

                                                                                                                                                                                                        TextCharFormatMixin

                                                                                                                                                                                                        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))
                                                                                                                                                                                                        

                                                                                                                                                                                                        TextCursor

                                                                                                                                                                                                        Bases: QTextCursor

                                                                                                                                                                                                        Source code in prettyqt/gui/textcursor.py
                                                                                                                                                                                                        class TextCursor(gui.QTextCursor):
                                                                                                                                                                                                            def __str__(self):
                                                                                                                                                                                                                return self.selectedText().replace("\u2029", "\n")
                                                                                                                                                                                                        
                                                                                                                                                                                                            def __contains__(self, other):
                                                                                                                                                                                                                return (
                                                                                                                                                                                                                    self.selectionStart() <= other.selectionStart()
                                                                                                                                                                                                                    and self.selectionEnd() >= other.selectionEnd()
                                                                                                                                                                                                                )
                                                                                                                                                                                                        
                                                                                                                                                                                                            def move_position(
                                                                                                                                                                                                                self,
                                                                                                                                                                                                                operation: MoveOperationStr | gui.QTextCursor.MoveOperation,
                                                                                                                                                                                                                mode: MoveModeStr | gui.QTextCursor.MoveMode = "move",
                                                                                                                                                                                                                n: int = 1,
                                                                                                                                                                                                            ) -> bool:
                                                                                                                                                                                                                if n < 0:
                                                                                                                                                                                                                    raise ValueError(n)
                                                                                                                                                                                                                return self.movePosition(
                                                                                                                                                                                                                    MOVE_OPERATION.get_enum_value(operation), MOVE_MODE.get_enum_value(mode), n
                                                                                                                                                                                                                )
                                                                                                                                                                                                        
                                                                                                                                                                                                            def set_position(
                                                                                                                                                                                                                self,
                                                                                                                                                                                                                pos: int | tuple[int, int],
                                                                                                                                                                                                                mode: MoveModeStr | gui.QTextCursor.MoveMode = "move",
                                                                                                                                                                                                            ):
                                                                                                                                                                                                                """Set cursor to given position.
                                                                                                                                                                                                        
                                                                                                                                                                                                                0-indexed.
                                                                                                                                                                                                        
                                                                                                                                                                                                                Args:
                                                                                                                                                                                                                    pos: Cursor position
                                                                                                                                                                                                                    mode: Move mode
                                                                                                                                                                                                                """
                                                                                                                                                                                                                match pos:
                                                                                                                                                                                                                    case int():
                                                                                                                                                                                                                        self.setPosition(pos, MOVE_MODE.get_enum_value(mode))
                                                                                                                                                                                                                    case (int() as row, int() as col):
                                                                                                                                                                                                                        position = self.document().findBlockByNumber(row).position()
                                                                                                                                                                                                                        position += col
                                                                                                                                                                                                                        self.set_position(position, mode=mode)
                                                                                                                                                                                                                    case _:
                                                                                                                                                                                                                        raise TypeError(pos)
                                                                                                                                                                                                        
                                                                                                                                                                                                            def select(self, selection: SelectionTypeStr | gui.QTextCursor.SelectionType):
                                                                                                                                                                                                                super().select(SELECTION_TYPE.get_enum_value(selection))
                                                                                                                                                                                                        
                                                                                                                                                                                                            def span(self) -> tuple[int, int]:
                                                                                                                                                                                                                return (self.anchor(), self.position())
                                                                                                                                                                                                        
                                                                                                                                                                                                            def get_cursor_position(self) -> tuple[int, int]:
                                                                                                                                                                                                                """Return the QTextCursor position.
                                                                                                                                                                                                        
                                                                                                                                                                                                                The position is a tuple made up of
                                                                                                                                                                                                                the line number (0 based) and the column number (0 based).
                                                                                                                                                                                                                :return: tuple(line, column)
                                                                                                                                                                                                                """
                                                                                                                                                                                                                return (self.blockNumber(), self.positionInBlock())
                                                                                                                                                                                                        
                                                                                                                                                                                                            def get_selection(self) -> gui.TextDocumentFragment:
                                                                                                                                                                                                                return gui.TextDocumentFragment(self.selection())
                                                                                                                                                                                                        
                                                                                                                                                                                                            def select_text(
                                                                                                                                                                                                                self,
                                                                                                                                                                                                                start_pos: int | tuple[int, int] | MoveOperationStr,
                                                                                                                                                                                                                end_pos: int | tuple[int, int] | MoveOperationStr,
                                                                                                                                                                                                            ) -> str:
                                                                                                                                                                                                                """Select text from start position to end position.
                                                                                                                                                                                                        
                                                                                                                                                                                                                Positions can be either an integer index or a move operation
                                                                                                                                                                                                        
                                                                                                                                                                                                                Args:
                                                                                                                                                                                                                    start_pos: Start position
                                                                                                                                                                                                                    end_pos: End position
                                                                                                                                                                                                                """
                                                                                                                                                                                                                match start_pos:
                                                                                                                                                                                                                    case int() | (int(), int()):
                                                                                                                                                                                                                        self.set_position(start_pos)
                                                                                                                                                                                                                    case str():
                                                                                                                                                                                                                        self.move_position(start_pos)
                                                                                                                                                                                                                    case _:
                                                                                                                                                                                                                        raise TypeError(start_pos)
                                                                                                                                                                                                                match end_pos:
                                                                                                                                                                                                                    case int() | (int(), int()):
                                                                                                                                                                                                                        self.set_position(end_pos, mode="keep")
                                                                                                                                                                                                                    case str():
                                                                                                                                                                                                                        self.move_position(end_pos, mode="keep")
                                                                                                                                                                                                                    case _:
                                                                                                                                                                                                                        raise TypeError(end_pos)
                                                                                                                                                                                                                return self.selectedText()
                                                                                                                                                                                                        
                                                                                                                                                                                                            def replace_text(
                                                                                                                                                                                                                self,
                                                                                                                                                                                                                start_pos: int,
                                                                                                                                                                                                                end_pos: MoveOperationStr | int,
                                                                                                                                                                                                                to_replace: str,
                                                                                                                                                                                                            ):
                                                                                                                                                                                                                self.set_position(start_pos)
                                                                                                                                                                                                                if isinstance(end_pos, int):
                                                                                                                                                                                                                    self.set_position(end_pos, mode="keep")
                                                                                                                                                                                                                else:
                                                                                                                                                                                                                    self.move_position(end_pos, mode="keep")
                                                                                                                                                                                                                self.insertText(to_replace)
                                                                                                                                                                                                                self.select_text(start_pos, start_pos + len(to_replace))
                                                                                                                                                                                                        
                                                                                                                                                                                                            @contextlib.contextmanager
                                                                                                                                                                                                            def edit_block(self, join_previous: bool = False):
                                                                                                                                                                                                                """Context manager for edit blocks. Can be used for undo actions."""
                                                                                                                                                                                                                self.joinPreviousEditBlock() if join_previous else self.beginEditBlock()
                                                                                                                                                                                                                try:
                                                                                                                                                                                                                    yield
                                                                                                                                                                                                                finally:
                                                                                                                                                                                                                    self.endEditBlock()
                                                                                                                                                                                                        

                                                                                                                                                                                                        edit_block(join_previous: bool = False)

                                                                                                                                                                                                        Context manager for edit blocks. Can be used for undo actions.

                                                                                                                                                                                                        Source code in prettyqt/gui/textcursor.py
                                                                                                                                                                                                        @contextlib.contextmanager
                                                                                                                                                                                                        def edit_block(self, join_previous: bool = False):
                                                                                                                                                                                                            """Context manager for edit blocks. Can be used for undo actions."""
                                                                                                                                                                                                            self.joinPreviousEditBlock() if join_previous else self.beginEditBlock()
                                                                                                                                                                                                            try:
                                                                                                                                                                                                                yield
                                                                                                                                                                                                            finally:
                                                                                                                                                                                                                self.endEditBlock()
                                                                                                                                                                                                        

                                                                                                                                                                                                        get_cursor_position() -> tuple[int, int]

                                                                                                                                                                                                        Return the QTextCursor position.

                                                                                                                                                                                                        The position is a tuple made up of the line number (0 based) and the column number (0 based). :return: tuple(line, column)

                                                                                                                                                                                                        Source code in prettyqt/gui/textcursor.py
                                                                                                                                                                                                        def get_cursor_position(self) -> tuple[int, int]:
                                                                                                                                                                                                            """Return the QTextCursor position.
                                                                                                                                                                                                        
                                                                                                                                                                                                            The position is a tuple made up of
                                                                                                                                                                                                            the line number (0 based) and the column number (0 based).
                                                                                                                                                                                                            :return: tuple(line, column)
                                                                                                                                                                                                            """
                                                                                                                                                                                                            return (self.blockNumber(), self.positionInBlock())
                                                                                                                                                                                                        

                                                                                                                                                                                                        select_text(start_pos: int | tuple[int, int] | MoveOperationStr, end_pos: int | tuple[int, int] | MoveOperationStr) -> str

                                                                                                                                                                                                        Select text from start position to end position.

                                                                                                                                                                                                        Positions can be either an integer index or a move operation

                                                                                                                                                                                                        Parameters:

                                                                                                                                                                                                        Name Type Description Default
                                                                                                                                                                                                        start_pos int | tuple[int, int] | MoveOperationStr

                                                                                                                                                                                                        Start position

                                                                                                                                                                                                        required
                                                                                                                                                                                                        end_pos int | tuple[int, int] | MoveOperationStr

                                                                                                                                                                                                        End position

                                                                                                                                                                                                        required
                                                                                                                                                                                                        Source code in prettyqt/gui/textcursor.py
                                                                                                                                                                                                        def select_text(
                                                                                                                                                                                                            self,
                                                                                                                                                                                                            start_pos: int | tuple[int, int] | MoveOperationStr,
                                                                                                                                                                                                            end_pos: int | tuple[int, int] | MoveOperationStr,
                                                                                                                                                                                                        ) -> str:
                                                                                                                                                                                                            """Select text from start position to end position.
                                                                                                                                                                                                        
                                                                                                                                                                                                            Positions can be either an integer index or a move operation
                                                                                                                                                                                                        
                                                                                                                                                                                                            Args:
                                                                                                                                                                                                                start_pos: Start position
                                                                                                                                                                                                                end_pos: End position
                                                                                                                                                                                                            """
                                                                                                                                                                                                            match start_pos:
                                                                                                                                                                                                                case int() | (int(), int()):
                                                                                                                                                                                                                    self.set_position(start_pos)
                                                                                                                                                                                                                case str():
                                                                                                                                                                                                                    self.move_position(start_pos)
                                                                                                                                                                                                                case _:
                                                                                                                                                                                                                    raise TypeError(start_pos)
                                                                                                                                                                                                            match end_pos:
                                                                                                                                                                                                                case int() | (int(), int()):
                                                                                                                                                                                                                    self.set_position(end_pos, mode="keep")
                                                                                                                                                                                                                case str():
                                                                                                                                                                                                                    self.move_position(end_pos, mode="keep")
                                                                                                                                                                                                                case _:
                                                                                                                                                                                                                    raise TypeError(end_pos)
                                                                                                                                                                                                            return self.selectedText()
                                                                                                                                                                                                        

                                                                                                                                                                                                        set_position(pos: int | tuple[int, int], mode: MoveModeStr | gui.QTextCursor.MoveMode = 'move')

                                                                                                                                                                                                        Set cursor to given position.

                                                                                                                                                                                                        0-indexed.

                                                                                                                                                                                                        Parameters:

                                                                                                                                                                                                        Name Type Description Default
                                                                                                                                                                                                        pos int | tuple[int, int]

                                                                                                                                                                                                        Cursor position

                                                                                                                                                                                                        required
                                                                                                                                                                                                        mode MoveModeStr | MoveMode

                                                                                                                                                                                                        Move mode

                                                                                                                                                                                                        'move'
                                                                                                                                                                                                        Source code in prettyqt/gui/textcursor.py
                                                                                                                                                                                                        def set_position(
                                                                                                                                                                                                            self,
                                                                                                                                                                                                            pos: int | tuple[int, int],
                                                                                                                                                                                                            mode: MoveModeStr | gui.QTextCursor.MoveMode = "move",
                                                                                                                                                                                                        ):
                                                                                                                                                                                                            """Set cursor to given position.
                                                                                                                                                                                                        
                                                                                                                                                                                                            0-indexed.
                                                                                                                                                                                                        
                                                                                                                                                                                                            Args:
                                                                                                                                                                                                                pos: Cursor position
                                                                                                                                                                                                                mode: Move mode
                                                                                                                                                                                                            """
                                                                                                                                                                                                            match pos:
                                                                                                                                                                                                                case int():
                                                                                                                                                                                                                    self.setPosition(pos, MOVE_MODE.get_enum_value(mode))
                                                                                                                                                                                                                case (int() as row, int() as col):
                                                                                                                                                                                                                    position = self.document().findBlockByNumber(row).position()
                                                                                                                                                                                                                    position += col
                                                                                                                                                                                                                    self.set_position(position, mode=mode)
                                                                                                                                                                                                                case _:
                                                                                                                                                                                                                    raise TypeError(pos)
                                                                                                                                                                                                        

                                                                                                                                                                                                        TextFormatMixin

                                                                                                                                                                                                        Bases: _TextFormatBase

                                                                                                                                                                                                        Source code in prettyqt/gui/textformat.py
                                                                                                                                                                                                        class TextFormatMixin(_TextFormatBase):
                                                                                                                                                                                                            def __getitem__(self, key: int):
                                                                                                                                                                                                                return self.property(key)
                                                                                                                                                                                                        
                                                                                                                                                                                                            def __setitem__(self, key: int, value):
                                                                                                                                                                                                                self.setProperty(key, value)
                                                                                                                                                                                                        
                                                                                                                                                                                                            def __contains__(self, key: int):
                                                                                                                                                                                                                return self.hasProperty(key)
                                                                                                                                                                                                        
                                                                                                                                                                                                            def __bool__(self):
                                                                                                                                                                                                                return self.isValid()
                                                                                                                                                                                                        
                                                                                                                                                                                                            def __repr__(self):
                                                                                                                                                                                                                return get_repr(self, self.type())
                                                                                                                                                                                                        
                                                                                                                                                                                                            def get_background(self) -> gui.Brush:
                                                                                                                                                                                                                return gui.Brush(self.background())
                                                                                                                                                                                                        
                                                                                                                                                                                                            def get_foreground(self) -> gui.Brush:
                                                                                                                                                                                                                return gui.Brush(self.foreground())
                                                                                                                                                                                                        
                                                                                                                                                                                                            def get_brush_property(self, property_id: int) -> gui.Brush:
                                                                                                                                                                                                                return gui.Brush(self.brushProperty(property_id))
                                                                                                                                                                                                        
                                                                                                                                                                                                            def get_color_property(self, property_id: int) -> gui.Color:
                                                                                                                                                                                                                return gui.Color(self.colorProperty(property_id))
                                                                                                                                                                                                        
                                                                                                                                                                                                            def get_pen_property(self, property_id: int) -> gui.Pen:
                                                                                                                                                                                                                return gui.Pen(self.penProperty(property_id))
                                                                                                                                                                                                        
                                                                                                                                                                                                            def set_layout_direction(
                                                                                                                                                                                                                self, direction: constants.LayoutDirectionStr | constants.LayoutDirection
                                                                                                                                                                                                            ):
                                                                                                                                                                                                                """Set layout direction.
                                                                                                                                                                                                        
                                                                                                                                                                                                                Args:
                                                                                                                                                                                                                    direction: layout direction
                                                                                                                                                                                                                """
                                                                                                                                                                                                                self.setLayoutDirection(constants.LAYOUT_DIRECTION.get_enum_value(direction))
                                                                                                                                                                                                        
                                                                                                                                                                                                            def get_layout_direction(self) -> constants.LayoutDirectionStr:
                                                                                                                                                                                                                """Get the current layout direction.
                                                                                                                                                                                                        
                                                                                                                                                                                                                Returns:
                                                                                                                                                                                                                    layout direction
                                                                                                                                                                                                                """
                                                                                                                                                                                                                return constants.LAYOUT_DIRECTION.inverse[self.layoutDirection()]
                                                                                                                                                                                                        
                                                                                                                                                                                                            def select_full_width(self, value: bool = True):
                                                                                                                                                                                                                prop = gui.QTextFormat.Property.FullWidthSelection
                                                                                                                                                                                                                self.setProperty(prop, value)
                                                                                                                                                                                                        

                                                                                                                                                                                                        get_layout_direction() -> constants.LayoutDirectionStr

                                                                                                                                                                                                        Get the current layout direction.

                                                                                                                                                                                                        Source code in prettyqt/gui/textformat.py
                                                                                                                                                                                                        def get_layout_direction(self) -> constants.LayoutDirectionStr:
                                                                                                                                                                                                            """Get the current layout direction.
                                                                                                                                                                                                        
                                                                                                                                                                                                            Returns:
                                                                                                                                                                                                                layout direction
                                                                                                                                                                                                            """
                                                                                                                                                                                                            return constants.LAYOUT_DIRECTION.inverse[self.layoutDirection()]
                                                                                                                                                                                                        

                                                                                                                                                                                                        set_layout_direction(direction: constants.LayoutDirectionStr | constants.LayoutDirection)

                                                                                                                                                                                                        Set layout direction.

                                                                                                                                                                                                        Parameters:

                                                                                                                                                                                                        Name Type Description Default
                                                                                                                                                                                                        direction LayoutDirectionStr | LayoutDirection

                                                                                                                                                                                                        layout direction

                                                                                                                                                                                                        required
                                                                                                                                                                                                        Source code in prettyqt/gui/textformat.py
                                                                                                                                                                                                        def set_layout_direction(
                                                                                                                                                                                                            self, direction: constants.LayoutDirectionStr | constants.LayoutDirection
                                                                                                                                                                                                        ):
                                                                                                                                                                                                            """Set layout direction.
                                                                                                                                                                                                        
                                                                                                                                                                                                            Args:
                                                                                                                                                                                                                direction: layout direction
                                                                                                                                                                                                            """
                                                                                                                                                                                                            self.setLayoutDirection(constants.LAYOUT_DIRECTION.get_enum_value(direction))
                                                                                                                                                                                                        

                                                                                                                                                                                                        TextLength

                                                                                                                                                                                                        Bases: QTextLength

                                                                                                                                                                                                        Source code in prettyqt/gui/textlength.py
                                                                                                                                                                                                        class TextLength(QtGui.QTextLength):
                                                                                                                                                                                                            def __repr__(self):
                                                                                                                                                                                                                return get_repr(self, self.type(), self.rawValue())
                                                                                                                                                                                                        
                                                                                                                                                                                                            def get_type(self) -> TypeStr:
                                                                                                                                                                                                                """Return type of this length object.
                                                                                                                                                                                                        
                                                                                                                                                                                                                Returns:
                                                                                                                                                                                                                    timer type
                                                                                                                                                                                                                """
                                                                                                                                                                                                                return TYPES.inverse[self.type()]
                                                                                                                                                                                                        

                                                                                                                                                                                                        get_type() -> TypeStr

                                                                                                                                                                                                        Return type of this length object.

                                                                                                                                                                                                        Source code in prettyqt/gui/textlength.py
                                                                                                                                                                                                        def get_type(self) -> TypeStr:
                                                                                                                                                                                                            """Return type of this length object.
                                                                                                                                                                                                        
                                                                                                                                                                                                            Returns:
                                                                                                                                                                                                                timer type
                                                                                                                                                                                                            """
                                                                                                                                                                                                            return TYPES.inverse[self.type()]
                                                                                                                                                                                                        

                                                                                                                                                                                                        TextListFormat

                                                                                                                                                                                                        Bases: TextFormatMixin, QTextListFormat

                                                                                                                                                                                                        Source code in prettyqt/gui/textlistformat.py
                                                                                                                                                                                                        class TextListFormat(gui.TextFormatMixin, gui.QTextListFormat):
                                                                                                                                                                                                            def set_style(self, style: StyleStr | gui.QTextListFormat.Style):
                                                                                                                                                                                                                """Set the style.
                                                                                                                                                                                                        
                                                                                                                                                                                                                Args:
                                                                                                                                                                                                                    style: style
                                                                                                                                                                                                                """
                                                                                                                                                                                                                self.setStyle(STYLES.get_enum_value(style))
                                                                                                                                                                                                        
                                                                                                                                                                                                            def get_style(self) -> StyleStr:
                                                                                                                                                                                                                """Get current style.
                                                                                                                                                                                                        
                                                                                                                                                                                                                Returns:
                                                                                                                                                                                                                    current style
                                                                                                                                                                                                                """
                                                                                                                                                                                                                return STYLES.inverse[self.style()]
                                                                                                                                                                                                        

                                                                                                                                                                                                        get_style() -> StyleStr

                                                                                                                                                                                                        Get current style.

                                                                                                                                                                                                        Source code in prettyqt/gui/textlistformat.py
                                                                                                                                                                                                        def get_style(self) -> StyleStr:
                                                                                                                                                                                                            """Get current style.
                                                                                                                                                                                                        
                                                                                                                                                                                                            Returns:
                                                                                                                                                                                                                current style
                                                                                                                                                                                                            """
                                                                                                                                                                                                            return STYLES.inverse[self.style()]
                                                                                                                                                                                                        

                                                                                                                                                                                                        set_style(style: StyleStr | gui.QTextListFormat.Style)

                                                                                                                                                                                                        Set the style.

                                                                                                                                                                                                        Parameters:

                                                                                                                                                                                                        Name Type Description Default
                                                                                                                                                                                                        style StyleStr | Style

                                                                                                                                                                                                        style

                                                                                                                                                                                                        required
                                                                                                                                                                                                        Source code in prettyqt/gui/textlistformat.py
                                                                                                                                                                                                        def set_style(self, style: StyleStr | gui.QTextListFormat.Style):
                                                                                                                                                                                                            """Set the style.
                                                                                                                                                                                                        
                                                                                                                                                                                                            Args:
                                                                                                                                                                                                                style: style
                                                                                                                                                                                                            """
                                                                                                                                                                                                            self.setStyle(STYLES.get_enum_value(style))
                                                                                                                                                                                                        

                                                                                                                                                                                                        TextTableCellFormat

                                                                                                                                                                                                        Bases: TextCharFormatMixin, QTextTableCellFormat

                                                                                                                                                                                                        Source code in prettyqt/gui/texttablecellformat.py
                                                                                                                                                                                                        class TextTableCellFormat(gui.TextCharFormatMixin, gui.QTextTableCellFormat):
                                                                                                                                                                                                            def get_bottom_border_brush(self) -> gui.Brush:
                                                                                                                                                                                                                return gui.Brush(self.bottomBorderBrush())
                                                                                                                                                                                                        
                                                                                                                                                                                                            def set_border_style(
                                                                                                                                                                                                                self, style: gui.textframeformat.BorderStyleStr | gui.QTextFrameFormat.BorderStyle
                                                                                                                                                                                                            ):
                                                                                                                                                                                                                """Set border style.
                                                                                                                                                                                                        
                                                                                                                                                                                                                Args:
                                                                                                                                                                                                                    style: border style
                                                                                                                                                                                                                """
                                                                                                                                                                                                                self.setBorderStyle(gui.textframeformat.BORDER_STYLES.get_enum_value(style))
                                                                                                                                                                                                        
                                                                                                                                                                                                            def set_bottom_border_style(
                                                                                                                                                                                                                self, style: gui.textframeformat.BorderStyleStr | gui.QTextFrameFormat.BorderStyle
                                                                                                                                                                                                            ):
                                                                                                                                                                                                                """Set bottom border style.
                                                                                                                                                                                                        
                                                                                                                                                                                                                Args:
                                                                                                                                                                                                                    style: bottom border style
                                                                                                                                                                                                                """
                                                                                                                                                                                                                self.setBottomBorderStyle(gui.textframeformat.BORDER_STYLES.get_enum_value(style))
                                                                                                                                                                                                        
                                                                                                                                                                                                            def get_bottom_border_style(self) -> gui.textframeformat.BorderStyleStr:
                                                                                                                                                                                                                """Get the current bottom border style.
                                                                                                                                                                                                        
                                                                                                                                                                                                                Returns:
                                                                                                                                                                                                                    bottom border style
                                                                                                                                                                                                                """
                                                                                                                                                                                                                return gui.textframeformat.BORDER_STYLES.inverse[self.bottomBorderStyle()]
                                                                                                                                                                                                        
                                                                                                                                                                                                            def get_left_border_brush(self) -> gui.Brush:
                                                                                                                                                                                                                return gui.Brush(self.leftBorderBrush())
                                                                                                                                                                                                        
                                                                                                                                                                                                            def set_left_border_style(
                                                                                                                                                                                                                self, style: gui.textframeformat.BorderStyleStr | gui.QTextFrameFormat.BorderStyle
                                                                                                                                                                                                            ):
                                                                                                                                                                                                                """Set left border style.
                                                                                                                                                                                                        
                                                                                                                                                                                                                Args:
                                                                                                                                                                                                                    style: left border style
                                                                                                                                                                                                                """
                                                                                                                                                                                                                self.setLeftBorderStyle(gui.textframeformat.BORDER_STYLES.get_enum_value(style))
                                                                                                                                                                                                        
                                                                                                                                                                                                            def get_left_border_style(self) -> gui.textframeformat.BorderStyleStr:
                                                                                                                                                                                                                """Get the current left border style.
                                                                                                                                                                                                        
                                                                                                                                                                                                                Returns:
                                                                                                                                                                                                                    left border style
                                                                                                                                                                                                                """
                                                                                                                                                                                                                return gui.textframeformat.BORDER_STYLES.inverse[self.leftBorderStyle()]
                                                                                                                                                                                                        
                                                                                                                                                                                                            def get_right_border_brush(self) -> gui.Brush:
                                                                                                                                                                                                                return gui.Brush(self.rightBorderBrush())
                                                                                                                                                                                                        
                                                                                                                                                                                                            def set_right_border_style(
                                                                                                                                                                                                                self, style: gui.textframeformat.BorderStyleStr | gui.QTextFrameFormat.BorderStyle
                                                                                                                                                                                                            ):
                                                                                                                                                                                                                """Set right border style.
                                                                                                                                                                                                        
                                                                                                                                                                                                                Args:
                                                                                                                                                                                                                    style: right border style
                                                                                                                                                                                                                """
                                                                                                                                                                                                                self.setRightBorderStyle(gui.textframeformat.BORDER_STYLES.get_enum_value(style))
                                                                                                                                                                                                        
                                                                                                                                                                                                            def get_right_border_style(self) -> gui.textframeformat.BorderStyleStr:
                                                                                                                                                                                                                """Get the current right border style.
                                                                                                                                                                                                        
                                                                                                                                                                                                                Returns:
                                                                                                                                                                                                                    right border style
                                                                                                                                                                                                                """
                                                                                                                                                                                                                return gui.textframeformat.BORDER_STYLES.inverse[self.rightBorderStyle()]
                                                                                                                                                                                                        
                                                                                                                                                                                                            def get_top_border_brush(self) -> gui.Brush:
                                                                                                                                                                                                                return gui.Brush(self.topBorderBrush())
                                                                                                                                                                                                        
                                                                                                                                                                                                            def set_top_border_style(
                                                                                                                                                                                                                self, style: gui.textframeformat.BorderStyleStr | gui.QTextFrameFormat.BorderStyle
                                                                                                                                                                                                            ):
                                                                                                                                                                                                                """Set top border style.
                                                                                                                                                                                                        
                                                                                                                                                                                                                Args:
                                                                                                                                                                                                                    style: top border style
                                                                                                                                                                                                                """
                                                                                                                                                                                                                self.setTopBorderStyle(gui.textframeformat.BORDER_STYLES.get_enum_value(style))
                                                                                                                                                                                                        
                                                                                                                                                                                                            def get_top_border_style(self) -> gui.textframeformat.BorderStyleStr:
                                                                                                                                                                                                                """Get the current top border style.
                                                                                                                                                                                                        
                                                                                                                                                                                                                Returns:
                                                                                                                                                                                                                    top border style
                                                                                                                                                                                                                """
                                                                                                                                                                                                                return gui.textframeformat.BORDER_STYLES.inverse[self.topBorderStyle()]
                                                                                                                                                                                                        

                                                                                                                                                                                                        get_bottom_border_style() -> gui.textframeformat.BorderStyleStr

                                                                                                                                                                                                        Get the current bottom border style.

                                                                                                                                                                                                        Source code in prettyqt/gui/texttablecellformat.py
                                                                                                                                                                                                        def get_bottom_border_style(self) -> gui.textframeformat.BorderStyleStr:
                                                                                                                                                                                                            """Get the current bottom border style.
                                                                                                                                                                                                        
                                                                                                                                                                                                            Returns:
                                                                                                                                                                                                                bottom border style
                                                                                                                                                                                                            """
                                                                                                                                                                                                            return gui.textframeformat.BORDER_STYLES.inverse[self.bottomBorderStyle()]
                                                                                                                                                                                                        

                                                                                                                                                                                                        get_left_border_style() -> gui.textframeformat.BorderStyleStr

                                                                                                                                                                                                        Get the current left border style.

                                                                                                                                                                                                        Source code in prettyqt/gui/texttablecellformat.py
                                                                                                                                                                                                        def get_left_border_style(self) -> gui.textframeformat.BorderStyleStr:
                                                                                                                                                                                                            """Get the current left border style.
                                                                                                                                                                                                        
                                                                                                                                                                                                            Returns:
                                                                                                                                                                                                                left border style
                                                                                                                                                                                                            """
                                                                                                                                                                                                            return gui.textframeformat.BORDER_STYLES.inverse[self.leftBorderStyle()]
                                                                                                                                                                                                        

                                                                                                                                                                                                        get_right_border_style() -> gui.textframeformat.BorderStyleStr

                                                                                                                                                                                                        Get the current right border style.

                                                                                                                                                                                                        Source code in prettyqt/gui/texttablecellformat.py
                                                                                                                                                                                                        def get_right_border_style(self) -> gui.textframeformat.BorderStyleStr:
                                                                                                                                                                                                            """Get the current right border style.
                                                                                                                                                                                                        
                                                                                                                                                                                                            Returns:
                                                                                                                                                                                                                right border style
                                                                                                                                                                                                            """
                                                                                                                                                                                                            return gui.textframeformat.BORDER_STYLES.inverse[self.rightBorderStyle()]
                                                                                                                                                                                                        

                                                                                                                                                                                                        get_top_border_style() -> gui.textframeformat.BorderStyleStr

                                                                                                                                                                                                        Get the current top border style.

                                                                                                                                                                                                        Source code in prettyqt/gui/texttablecellformat.py
                                                                                                                                                                                                        def get_top_border_style(self) -> gui.textframeformat.BorderStyleStr:
                                                                                                                                                                                                            """Get the current top border style.
                                                                                                                                                                                                        
                                                                                                                                                                                                            Returns:
                                                                                                                                                                                                                top border style
                                                                                                                                                                                                            """
                                                                                                                                                                                                            return gui.textframeformat.BORDER_STYLES.inverse[self.topBorderStyle()]
                                                                                                                                                                                                        

                                                                                                                                                                                                        set_border_style(style: gui.textframeformat.BorderStyleStr | gui.QTextFrameFormat.BorderStyle)

                                                                                                                                                                                                        Set border style.

                                                                                                                                                                                                        Parameters:

                                                                                                                                                                                                        Name Type Description Default
                                                                                                                                                                                                        style BorderStyleStr | BorderStyle

                                                                                                                                                                                                        border style

                                                                                                                                                                                                        required
                                                                                                                                                                                                        Source code in prettyqt/gui/texttablecellformat.py
                                                                                                                                                                                                        def set_border_style(
                                                                                                                                                                                                            self, style: gui.textframeformat.BorderStyleStr | gui.QTextFrameFormat.BorderStyle
                                                                                                                                                                                                        ):
                                                                                                                                                                                                            """Set border style.
                                                                                                                                                                                                        
                                                                                                                                                                                                            Args:
                                                                                                                                                                                                                style: border style
                                                                                                                                                                                                            """
                                                                                                                                                                                                            self.setBorderStyle(gui.textframeformat.BORDER_STYLES.get_enum_value(style))
                                                                                                                                                                                                        

                                                                                                                                                                                                        set_bottom_border_style(style: gui.textframeformat.BorderStyleStr | gui.QTextFrameFormat.BorderStyle)

                                                                                                                                                                                                        Set bottom border style.

                                                                                                                                                                                                        Parameters:

                                                                                                                                                                                                        Name Type Description Default
                                                                                                                                                                                                        style BorderStyleStr | BorderStyle

                                                                                                                                                                                                        bottom border style

                                                                                                                                                                                                        required
                                                                                                                                                                                                        Source code in prettyqt/gui/texttablecellformat.py
                                                                                                                                                                                                        def set_bottom_border_style(
                                                                                                                                                                                                            self, style: gui.textframeformat.BorderStyleStr | gui.QTextFrameFormat.BorderStyle
                                                                                                                                                                                                        ):
                                                                                                                                                                                                            """Set bottom border style.
                                                                                                                                                                                                        
                                                                                                                                                                                                            Args:
                                                                                                                                                                                                                style: bottom border style
                                                                                                                                                                                                            """
                                                                                                                                                                                                            self.setBottomBorderStyle(gui.textframeformat.BORDER_STYLES.get_enum_value(style))
                                                                                                                                                                                                        

                                                                                                                                                                                                        set_left_border_style(style: gui.textframeformat.BorderStyleStr | gui.QTextFrameFormat.BorderStyle)

                                                                                                                                                                                                        Set left border style.

                                                                                                                                                                                                        Parameters:

                                                                                                                                                                                                        Name Type Description Default
                                                                                                                                                                                                        style BorderStyleStr | BorderStyle

                                                                                                                                                                                                        left border style

                                                                                                                                                                                                        required
                                                                                                                                                                                                        Source code in prettyqt/gui/texttablecellformat.py
                                                                                                                                                                                                        def set_left_border_style(
                                                                                                                                                                                                            self, style: gui.textframeformat.BorderStyleStr | gui.QTextFrameFormat.BorderStyle
                                                                                                                                                                                                        ):
                                                                                                                                                                                                            """Set left border style.
                                                                                                                                                                                                        
                                                                                                                                                                                                            Args:
                                                                                                                                                                                                                style: left border style
                                                                                                                                                                                                            """
                                                                                                                                                                                                            self.setLeftBorderStyle(gui.textframeformat.BORDER_STYLES.get_enum_value(style))
                                                                                                                                                                                                        

                                                                                                                                                                                                        set_right_border_style(style: gui.textframeformat.BorderStyleStr | gui.QTextFrameFormat.BorderStyle)

                                                                                                                                                                                                        Set right border style.

                                                                                                                                                                                                        Parameters:

                                                                                                                                                                                                        Name Type Description Default
                                                                                                                                                                                                        style BorderStyleStr | BorderStyle

                                                                                                                                                                                                        right border style

                                                                                                                                                                                                        required
                                                                                                                                                                                                        Source code in prettyqt/gui/texttablecellformat.py
                                                                                                                                                                                                        def set_right_border_style(
                                                                                                                                                                                                            self, style: gui.textframeformat.BorderStyleStr | gui.QTextFrameFormat.BorderStyle
                                                                                                                                                                                                        ):
                                                                                                                                                                                                            """Set right border style.
                                                                                                                                                                                                        
                                                                                                                                                                                                            Args:
                                                                                                                                                                                                                style: right border style
                                                                                                                                                                                                            """
                                                                                                                                                                                                            self.setRightBorderStyle(gui.textframeformat.BORDER_STYLES.get_enum_value(style))
                                                                                                                                                                                                        

                                                                                                                                                                                                        set_top_border_style(style: gui.textframeformat.BorderStyleStr | gui.QTextFrameFormat.BorderStyle)

                                                                                                                                                                                                        Set top border style.

                                                                                                                                                                                                        Parameters:

                                                                                                                                                                                                        Name Type Description Default
                                                                                                                                                                                                        style BorderStyleStr | BorderStyle

                                                                                                                                                                                                        top border style

                                                                                                                                                                                                        required
                                                                                                                                                                                                        Source code in prettyqt/gui/texttablecellformat.py
                                                                                                                                                                                                        def set_top_border_style(
                                                                                                                                                                                                            self, style: gui.textframeformat.BorderStyleStr | gui.QTextFrameFormat.BorderStyle
                                                                                                                                                                                                        ):
                                                                                                                                                                                                            """Set top border style.
                                                                                                                                                                                                        
                                                                                                                                                                                                            Args:
                                                                                                                                                                                                                style: top border style
                                                                                                                                                                                                            """
                                                                                                                                                                                                            self.setTopBorderStyle(gui.textframeformat.BORDER_STYLES.get_enum_value(style))
                                                                                                                                                                                                        

                                                                                                                                                                                                        TextTableFormat

                                                                                                                                                                                                        Bases: TextFrameFormatMixin, QTextTableFormat

                                                                                                                                                                                                        Source code in prettyqt/gui/texttableformat.py
                                                                                                                                                                                                        class TextTableFormat(gui.textframeformat.TextFrameFormatMixin, gui.QTextTableFormat):
                                                                                                                                                                                                            def __bool__(self):
                                                                                                                                                                                                                return self.isValid()
                                                                                                                                                                                                        
                                                                                                                                                                                                            def set_alignment(self, alignment: constants.AlignmentStr | constants.AlignmentFlag):
                                                                                                                                                                                                                """Set the alignment of the format.
                                                                                                                                                                                                        
                                                                                                                                                                                                                Args:
                                                                                                                                                                                                                    alignment: alignment for the format
                                                                                                                                                                                                                """
                                                                                                                                                                                                                self.setAlignment(constants.ALIGNMENTS.get_enum_value(alignment))
                                                                                                                                                                                                        
                                                                                                                                                                                                            def get_alignment(self) -> constants.AlignmentStr:
                                                                                                                                                                                                                """Return current alignment.
                                                                                                                                                                                                        
                                                                                                                                                                                                                Returns:
                                                                                                                                                                                                                    alignment
                                                                                                                                                                                                                """
                                                                                                                                                                                                                return constants.ALIGNMENTS.inverse[self.alignment()]
                                                                                                                                                                                                        
                                                                                                                                                                                                            def get_column_width_constraints(self) -> list[gui.TextLength]:
                                                                                                                                                                                                                return [gui.TextLength(i) for i in self.columnWidthConstraints()]
                                                                                                                                                                                                        

                                                                                                                                                                                                        get_alignment() -> constants.AlignmentStr

                                                                                                                                                                                                        Return current alignment.

                                                                                                                                                                                                        Source code in prettyqt/gui/texttableformat.py
                                                                                                                                                                                                        def get_alignment(self) -> constants.AlignmentStr:
                                                                                                                                                                                                            """Return current alignment.
                                                                                                                                                                                                        
                                                                                                                                                                                                            Returns:
                                                                                                                                                                                                                alignment
                                                                                                                                                                                                            """
                                                                                                                                                                                                            return constants.ALIGNMENTS.inverse[self.alignment()]
                                                                                                                                                                                                        

                                                                                                                                                                                                        set_alignment(alignment: constants.AlignmentStr | constants.AlignmentFlag)

                                                                                                                                                                                                        Set the alignment of the format.

                                                                                                                                                                                                        Parameters:

                                                                                                                                                                                                        Name Type Description Default
                                                                                                                                                                                                        alignment AlignmentStr | AlignmentFlag

                                                                                                                                                                                                        alignment for the format

                                                                                                                                                                                                        required
                                                                                                                                                                                                        Source code in prettyqt/gui/texttableformat.py
                                                                                                                                                                                                        def set_alignment(self, alignment: constants.AlignmentStr | constants.AlignmentFlag):
                                                                                                                                                                                                            """Set the alignment of the format.
                                                                                                                                                                                                        
                                                                                                                                                                                                            Args:
                                                                                                                                                                                                                alignment: alignment for the format
                                                                                                                                                                                                            """
                                                                                                                                                                                                            self.setAlignment(constants.ALIGNMENTS.get_enum_value(alignment))
                                                                                                                                                                                                        

                                                                                                                                                                                                        Vector2D

                                                                                                                                                                                                        Bases: QVector2D

                                                                                                                                                                                                        Represents a vector or vertex in 2D space.

                                                                                                                                                                                                        Source code in prettyqt/gui/vector2d.py
                                                                                                                                                                                                        class Vector2D(QtGui.QVector2D):
                                                                                                                                                                                                            """Represents a vector or vertex in 2D space."""
                                                                                                                                                                                                        
                                                                                                                                                                                                            def __bool__(self):
                                                                                                                                                                                                                return not self.isNull()
                                                                                                                                                                                                        
                                                                                                                                                                                                            def __abs__(self) -> float:
                                                                                                                                                                                                                return self.length()
                                                                                                                                                                                                        
                                                                                                                                                                                                            @property
                                                                                                                                                                                                            def _x(self) -> float:
                                                                                                                                                                                                                return self.x()
                                                                                                                                                                                                        
                                                                                                                                                                                                            @property
                                                                                                                                                                                                            def _y(self) -> float:
                                                                                                                                                                                                                return self.y()
                                                                                                                                                                                                        
                                                                                                                                                                                                            __match_args__ = ("_x", "_y")
                                                                                                                                                                                                        
                                                                                                                                                                                                            def __reduce__(self):
                                                                                                                                                                                                                return type(self), (self.x(), self.y())
                                                                                                                                                                                                        
                                                                                                                                                                                                            def to_point(self) -> core.Point:
                                                                                                                                                                                                                return core.Point(self.toPoint())
                                                                                                                                                                                                        
                                                                                                                                                                                                            def to_pointf(self) -> core.PointF:
                                                                                                                                                                                                                return core.PointF(self.toPointF())
                                                                                                                                                                                                        
                                                                                                                                                                                                            def to_vector3d(self) -> gui.Vector3D:
                                                                                                                                                                                                                return gui.Vector3D(self.toVector3D())
                                                                                                                                                                                                        
                                                                                                                                                                                                            def to_vector4d(self) -> gui.Vector4D:
                                                                                                                                                                                                                return gui.Vector4D(self.toVector4D())
                                                                                                                                                                                                        

                                                                                                                                                                                                        WindowMixin

                                                                                                                                                                                                        Bases: ObjectMixin, SurfaceMixin, _WindowBase

                                                                                                                                                                                                        Source code in prettyqt/gui/window.py
                                                                                                                                                                                                        class WindowMixin(core.ObjectMixin, gui.SurfaceMixin, _WindowBase):
                                                                                                                                                                                                            def __repr__(self):
                                                                                                                                                                                                                return get_repr(self)
                                                                                                                                                                                                        
                                                                                                                                                                                                            def _get_map(self):
                                                                                                                                                                                                                maps = super()._get_map()
                                                                                                                                                                                                                maps |= {
                                                                                                                                                                                                                    "modality": constants.WINDOW_MODALITY,
                                                                                                                                                                                                                    "flags": constants.WINDOW_TYPE,
                                                                                                                                                                                                                    "visibility": VISIBILITY,
                                                                                                                                                                                                                    "contentOrientation": constants.SCREEN_ORIENTATION,
                                                                                                                                                                                                                }
                                                                                                                                                                                                                return maps
                                                                                                                                                                                                        
                                                                                                                                                                                                            def add_shortcut(
                                                                                                                                                                                                                self,
                                                                                                                                                                                                                keysequence: datatypes.KeyCombinationType,
                                                                                                                                                                                                                callback: Callable | None = None,
                                                                                                                                                                                                                context: constants.ShortcutContextStr | constants.ShortcutContext = "window",
                                                                                                                                                                                                            ) -> gui.Shortcut:
                                                                                                                                                                                                                if not isinstance(keysequence, gui.QKeySequence):
                                                                                                                                                                                                                    keysequence = gui.KeySequence(keysequence)
                                                                                                                                                                                                                context = constants.SHORTCUT_CONTEXT.get_enum_value(context)
                                                                                                                                                                                                                if callback is not None:
                                                                                                                                                                                                                    return gui.Shortcut(keysequence, self, callback, context=context)
                                                                                                                                                                                                                return gui.Shortcut(keysequence, self, context=context)
                                                                                                                                                                                                        
                                                                                                                                                                                                            def set_visibility(self, visibility: VisibilityStr | gui.QWindow.Visibility):
                                                                                                                                                                                                                """Set window visibility.
                                                                                                                                                                                                        
                                                                                                                                                                                                                Args:
                                                                                                                                                                                                                    visibility: window visibility
                                                                                                                                                                                                                """
                                                                                                                                                                                                                self.setVisibility(VISIBILITY.get_enum_value(visibility))
                                                                                                                                                                                                        
                                                                                                                                                                                                            def get_visibility(self) -> VisibilityStr:
                                                                                                                                                                                                                """Get the current window visibility.
                                                                                                                                                                                                        
                                                                                                                                                                                                                Returns:
                                                                                                                                                                                                                    window visibility
                                                                                                                                                                                                                """
                                                                                                                                                                                                                return VISIBILITY.inverse[self.visibility()]
                                                                                                                                                                                                        
                                                                                                                                                                                                            def start_system_resize(self, edge: constants.EdgeStr | constants.Edge) -> bool:
                                                                                                                                                                                                                """Start system resize.
                                                                                                                                                                                                        
                                                                                                                                                                                                                Args:
                                                                                                                                                                                                                    edge: edge to resize
                                                                                                                                                                                                                """
                                                                                                                                                                                                                return self.startSystemResize(constants.EDGES.get_enum_value(edge))
                                                                                                                                                                                                        
                                                                                                                                                                                                            def get_screen(self) -> gui.Screen:
                                                                                                                                                                                                                return gui.Screen(self.screen())
                                                                                                                                                                                                        
                                                                                                                                                                                                            def get_cursor(self) -> gui.Cursor:
                                                                                                                                                                                                                return gui.Cursor(self.cursor())
                                                                                                                                                                                                        
                                                                                                                                                                                                            def get_icon(self) -> gui.Icon | None:
                                                                                                                                                                                                                icon = self.icon()
                                                                                                                                                                                                                return None if icon.isNull() else gui.Icon(icon)
                                                                                                                                                                                                        
                                                                                                                                                                                                            def set_modality(
                                                                                                                                                                                                                self, modality: constants.WindowModalityStr | constants.WindowModality
                                                                                                                                                                                                            ) -> None:
                                                                                                                                                                                                                """Set modality for the window.
                                                                                                                                                                                                        
                                                                                                                                                                                                                Args:
                                                                                                                                                                                                                    modality: modality for the window
                                                                                                                                                                                                                """
                                                                                                                                                                                                                self.setModality(constants.WINDOW_MODALITY.get_enum_value(modality))
                                                                                                                                                                                                        
                                                                                                                                                                                                            def get_modality(self) -> constants.WindowModalityStr:
                                                                                                                                                                                                                return constants.WINDOW_MODALITY.inverse[self.modality()]
                                                                                                                                                                                                        
                                                                                                                                                                                                            def set_file_path(self, file_path: str | os.PathLike[str]):
                                                                                                                                                                                                                path = os.fspath(file_path)
                                                                                                                                                                                                                self.setFilePath(path)
                                                                                                                                                                                                        
                                                                                                                                                                                                            def get_file_path(self) -> pathlib.Path:
                                                                                                                                                                                                                return pathlib.Path(self.filePath())
                                                                                                                                                                                                        
                                                                                                                                                                                                            def get_type(self) -> constants.WindowTypeStr:
                                                                                                                                                                                                                return constants.WINDOW_TYPE.inverse[self.type()]
                                                                                                                                                                                                        
                                                                                                                                                                                                            def get_window_state(self) -> constants.WindowStateStr:
                                                                                                                                                                                                                return constants.WINDOW_STATES.inverse[self.windowState()]
                                                                                                                                                                                                        
                                                                                                                                                                                                            def get_window_states(self) -> list[constants.WindowStateStr]:
                                                                                                                                                                                                                return constants.WINDOW_STATES.get_list(self.windowStates())
                                                                                                                                                                                                        

                                                                                                                                                                                                        get_visibility() -> VisibilityStr

                                                                                                                                                                                                        Get the current window visibility.

                                                                                                                                                                                                        Source code in prettyqt/gui/window.py
                                                                                                                                                                                                        def get_visibility(self) -> VisibilityStr:
                                                                                                                                                                                                            """Get the current window visibility.
                                                                                                                                                                                                        
                                                                                                                                                                                                            Returns:
                                                                                                                                                                                                                window visibility
                                                                                                                                                                                                            """
                                                                                                                                                                                                            return VISIBILITY.inverse[self.visibility()]
                                                                                                                                                                                                        

                                                                                                                                                                                                        set_modality(modality: constants.WindowModalityStr | constants.WindowModality) -> None

                                                                                                                                                                                                        Set modality for the window.

                                                                                                                                                                                                        Parameters:

                                                                                                                                                                                                        Name Type Description Default
                                                                                                                                                                                                        modality WindowModalityStr | WindowModality

                                                                                                                                                                                                        modality for the window

                                                                                                                                                                                                        required
                                                                                                                                                                                                        Source code in prettyqt/gui/window.py
                                                                                                                                                                                                        def set_modality(
                                                                                                                                                                                                            self, modality: constants.WindowModalityStr | constants.WindowModality
                                                                                                                                                                                                        ) -> None:
                                                                                                                                                                                                            """Set modality for the window.
                                                                                                                                                                                                        
                                                                                                                                                                                                            Args:
                                                                                                                                                                                                                modality: modality for the window
                                                                                                                                                                                                            """
                                                                                                                                                                                                            self.setModality(constants.WINDOW_MODALITY.get_enum_value(modality))
                                                                                                                                                                                                        

                                                                                                                                                                                                        set_visibility(visibility: VisibilityStr | gui.QWindow.Visibility)

                                                                                                                                                                                                        Set window visibility.

                                                                                                                                                                                                        Parameters:

                                                                                                                                                                                                        Name Type Description Default
                                                                                                                                                                                                        visibility VisibilityStr | Visibility

                                                                                                                                                                                                        window visibility

                                                                                                                                                                                                        required
                                                                                                                                                                                                        Source code in prettyqt/gui/window.py
                                                                                                                                                                                                        def set_visibility(self, visibility: VisibilityStr | gui.QWindow.Visibility):
                                                                                                                                                                                                            """Set window visibility.
                                                                                                                                                                                                        
                                                                                                                                                                                                            Args:
                                                                                                                                                                                                                visibility: window visibility
                                                                                                                                                                                                            """
                                                                                                                                                                                                            self.setVisibility(VISIBILITY.get_enum_value(visibility))
                                                                                                                                                                                                        

                                                                                                                                                                                                        start_system_resize(edge: constants.EdgeStr | constants.Edge) -> bool

                                                                                                                                                                                                        Start system resize.

                                                                                                                                                                                                        Parameters:

                                                                                                                                                                                                        Name Type Description Default
                                                                                                                                                                                                        edge EdgeStr | Edge

                                                                                                                                                                                                        edge to resize

                                                                                                                                                                                                        required
                                                                                                                                                                                                        Source code in prettyqt/gui/window.py
                                                                                                                                                                                                        def start_system_resize(self, edge: constants.EdgeStr | constants.Edge) -> bool:
                                                                                                                                                                                                            """Start system resize.
                                                                                                                                                                                                        
                                                                                                                                                                                                            Args:
                                                                                                                                                                                                                edge: edge to resize
                                                                                                                                                                                                            """
                                                                                                                                                                                                            return self.startSystemResize(constants.EDGES.get_enum_value(edge))
                                                                                                                                                                                                        

                                                                                                                                                                                                        get_repr(_obj: Any, *args: Any, **kwargs: Any) -> str

                                                                                                                                                                                                        Get a suitable repr string for an object.

                                                                                                                                                                                                        Parameters:

                                                                                                                                                                                                        Name Type Description Default
                                                                                                                                                                                                        _obj Any

                                                                                                                                                                                                        The object to get a repr for.

                                                                                                                                                                                                        required
                                                                                                                                                                                                        *args Any

                                                                                                                                                                                                        Arguments for the repr

                                                                                                                                                                                                        ()
                                                                                                                                                                                                        **kwargs Any

                                                                                                                                                                                                        Keyword arguments for the repr

                                                                                                                                                                                                        {}
                                                                                                                                                                                                        Source code in prettyqt/utils/__init__.py
                                                                                                                                                                                                        def get_repr(_obj: Any, *args: Any, **kwargs: Any) -> str:
                                                                                                                                                                                                            """Get a suitable __repr__ string for an object.
                                                                                                                                                                                                        
                                                                                                                                                                                                            Args:
                                                                                                                                                                                                                _obj: The object to get a repr for.
                                                                                                                                                                                                                *args: Arguments for the repr
                                                                                                                                                                                                                **kwargs: Keyword arguments for the repr
                                                                                                                                                                                                            """
                                                                                                                                                                                                            classname = type(_obj).__name__
                                                                                                                                                                                                            parts = [repr(val) for val in args]
                                                                                                                                                                                                            kw_parts = [f"{name}={val!r}" for name, val in kwargs.items()]
                                                                                                                                                                                                            return f"{classname}({', '.join(parts + kw_parts)})"