Class: QgsCodeEditorColorScheme

Defines a color scheme for use in QgsCodeEditor widgets.

Added in version 3.16.

class qgis.gui.QgsCodeEditorColorScheme[source]

Bases: object

__init__(id: str | None = '', name: str | None = '')

Constructor for QgsCodeEditorColorScheme.

The id argument must be set to a unique, non-translated identifier for the color scheme.

The name argument must be set to a translated, user-visible descriptive name of the scheme.

Parameters:
  • id (Optional[str] = '')

  • name (Optional[str] = '')

__init__(a0: QgsCodeEditorColorScheme)
Parameters:

a0 (QgsCodeEditorColorScheme)

class ColorRole(*values)

Bases: IntEnum

Color roles.

  • Default: Default text color

  • Keyword: Keyword color

  • Class: Class color

  • Method: Method color

  • Decoration: Decoration color

  • Number: Number color

  • Comment: Comment color

  • CommentLine: Line comment color

  • CommentBlock: Comment block color

  • Background: Background color

  • Cursor: Cursor color

  • CaretLine: Caret line color

  • SingleQuote: Single quote color

  • DoubleQuote: Double quote color

  • TripleSingleQuote: Triple single quote color

  • TripleDoubleQuote: Triple double quote color

  • Operator: Operator color

  • QuotedOperator: Quoted operator color

  • Identifier: Identifier color

  • QuotedIdentifier: Quoted identifier color

  • Tag: Tag color

  • UnknownTag: Unknown tag

  • MarginBackground: Margin background color

  • MarginForeground: Margin foreground color

  • SelectionBackground: Selection background color

  • SelectionForeground: Selection foreground color

  • MatchedBraceBackground: Matched brace background color

  • MatchedBraceForeground: Matched brace foreground color

  • Edge: Edge color

  • Fold: Fold color

  • Error: Error color

  • ErrorBackground: Error background color

  • FoldIconForeground: Fold icon foreground color

  • FoldIconHalo: Fold icon halo color

  • IndentationGuide: Indentation guide line

  • SearchMatchBackground: Background color for search matches

    Added in version 3.38.

Background = 9
CaretLine = 11
Class = 2
Comment = 6
CommentBlock = 8
CommentLine = 7
Cursor = 10
Decoration = 4
Default = 0
DoubleQuote = 13
Edge = 28
Error = 30
ErrorBackground = 31
Fold = 29
FoldIconForeground = 32
FoldIconHalo = 33
Identifier = 18
IndentationGuide = 34
Keyword = 1
MarginBackground = 22
MarginForeground = 23
MatchedBraceBackground = 26
MatchedBraceForeground = 27
Method = 3
Number = 5
Operator = 16
QuotedIdentifier = 19
QuotedOperator = 17
SearchMatchBackground = 35
SelectionBackground = 24
SelectionForeground = 25
SingleQuote = 12
Tag = 20
TripleDoubleQuote = 15
TripleSingleQuote = 14
UnknownTag = 21
color(self, role: QgsCodeEditorColorScheme.ColorRole) QColor[source]

Returns the color to use in the editor for the specified role.

See also

setColor()

Parameters:

role (QgsCodeEditorColorScheme.ColorRole)

Return type:

QColor

id(self) str[source]

Returns the ID of the color scheme, which is a unique, non-translated identifier for the scheme.

Return type:

str

name(self) str[source]

Returns the name of the color scheme, which is the translated, user-visible name of the scheme.

Return type:

str

setColor(self, role: QgsCodeEditorColorScheme.ColorRole, color: QColor | Qt.GlobalColor)[source]

Sets the color to use in the editor for the specified role.

See also

color()

Parameters: