Class: QgsColorSchemeRegistry

class qgis.core.QgsColorSchemeRegistry

Bases: sip.wrapper

Registry of color schemes

A registry of QgsColorScheme color schemes. This class can be created directly, or accessed via a QgsApplication.colorSchemeRegistry().

New in version 2.5.

QgsColorSchemeRegistry() Constructor for an empty color scheme registry

QgsColorSchemeRegistry(QgsColorSchemeRegistry)

Methods

addColorScheme

Adds a color scheme to the registry.

addDefaultSchemes

Adds all default color schemes to this color scheme.

addUserSchemes

Creates schemes for all gpl palettes in the user's palettes folder.

fetchRandomStyleColor

Returns a random color for use with a new symbol style (e.g.

initStyleScheme

Initializes the default random style color scheme for the user.

populateFromInstance

Adds all color schemes from the global instance to this color scheme.

randomStyleColorScheme

Returns the color scheme used when fetching random colors to use for symbol styles.

removeColorScheme

Removes all matching color schemes from the registry

schemes

Returns all color schemes in the registry

setRandomStyleColorScheme

Sets the color scheme to use when fetching random colors to use for symbol styles.

addColorScheme(self, scheme: QgsColorScheme)

Adds a color scheme to the registry. Ownership of the scheme is transferred to the registry.

Parameters

scheme (QgsColorScheme) – color scheme to add

addDefaultSchemes(self)

Adds all default color schemes to this color scheme.

See also

addColorScheme()

See also

addUserSchemes()

addUserSchemes(self)

Creates schemes for all gpl palettes in the user’s palettes folder.

See also

addColorScheme()

fetchRandomStyleColor(self) QColor

Returns a random color for use with a new symbol style (e.g. for a newly created map layer).

If a randomStyleColorScheme() is set then this color will be randomly taken from that color scheme. If no randomStyleColorScheme() is set then a totally random color will be generated.

Note that calling setRandomStyleColorScheme() takes a snapshot of the colors from the scheme’s QgsColorScheme.fetchColors() list. Accordingly, any future changes to the colors in the scheme are not automatically reflected by calls to fetchRandomStyleColor(). If the scheme is updated, then another call to setRandomStyleColorScheme() must be made in order to update the cached list of available style colors from which fetchRandomStyleColor() selects colors.

This method is thread safe.

New in version 3.2.

Return type

QColor

initStyleScheme(self)

Initializes the default random style color scheme for the user.

New in version 3.2.

populateFromInstance(self)

Adds all color schemes from the global instance to this color scheme.

See also

addColorScheme()

randomStyleColorScheme(self) QgsColorScheme

Returns the color scheme used when fetching random colors to use for symbol styles.

This may be None, in which case totally random colors are used for styles.

New in version 3.2.

Return type

QgsColorScheme

removeColorScheme(self, scheme: QgsColorScheme) bool

Removes all matching color schemes from the registry

Parameters

scheme (QgsColorScheme) – color scheme to remove

Return type

bool

Returns

True if scheme was found and removed

See also

addColorScheme()

schemes(self) List[QgsColorScheme]

Returns all color schemes in the registry

Returns

list of color schemes

schemes(self, flag: QgsColorScheme.SchemeFlag) -> List[QgsColorScheme] Returns all color schemes in the registry which have a specified flag set

Parameters

flag – flag to match

Return type

List[QgsColorScheme]

Returns

list of color schemes with flag set

setRandomStyleColorScheme(self, scheme: QgsColorScheme)

Sets the color scheme to use when fetching random colors to use for symbol styles.

scheme should match a color scheme which is already present in the registry.

Note that calling this method takes a snapshot of the colors from the scheme’s QgsColorScheme.fetchColors() list. Accordingly, any future changes to the colors in scheme are not automatically reflected by calls to fetchRandomStyleColor(). If scheme is updated, then another call to setRandomStyleColorScheme() must be made in order to update the cached list of available style colors.

New in version 3.2.

Parameters

scheme (QgsColorScheme) –