Class Palette
Build from Palette.h
Krita 4.0.0Krita master

The Palette class Palette is a resource object that stores organised color data. It's purpose is to allow artists to save colors and store them.

An example for printing all the palettes and the entries:

import sysfrom krita import *resources = Application.resources("palette")for (k, v) in resources.items(): print(k) palette = Palette(v) for x in range(palette.numberOfEntries()): entry = palette.colorSetEntryByIndex(x) print(x, entry.name(), entry.id(), entry.spotColor())

Methods

Palette(resource: Resource) addEntry(entry: Swatch, groupName: str = "") addGroup(name: str) changeGroupName(oldGroupName: str, newGroupName: str) colorSetEntryByIndex(index: int)Swatch colorSetEntryFromGroup(index: int, groupName: str)Swatch colorsCountGroup(name: str)int colorsCountTotal()int columnCount()int comment()str entryByIndex(index: int)Swatch entryByIndexFromGroup(index: int, groupName: str)Swatch groupNames()list[str] moveGroup(groupName: str, groupNameInsertBefore: str = "") numberOfEntries()int removeEntry(index: int, groupName: str) removeGroup(name: str, keepColors: bool = True) renameGroup(oldGroupName: str, newGroupName: str) save()bool setColumnCount(columns: int) setComment(comment: str)

Member documentation

Palette(resource: Resource)
Krita 4.0.0

Parameters

resource(no description provided)

Return

(no description provided)

addEntry(entry: Swatch, groupName: str = "")
Krita 4.2.0Krita master

add a color entry to a group. Color is appended to the end.

Parameters

entry

the entry

groupName

the name of the group to add to.

addGroup(name: str)
Krita 4.0.0Krita master

Palette content can be organized in groups. This method allows to add a new group in palette.

Parameters

name

The name of the new group to add.

changeGroupName(oldGroupName: str, newGroupName: str)
Krita 4.0.0Krita 5.2.0Krita master

change the group name.

DEPRECATED: use `renameGroup()` instead

Parameters

oldGroupName

the old groupname to change.

newGroupName

the new name to change it into.

Return

whether successful. Reasons for failure include not knowing have oldGroupName

colorSetEntryByIndex(index: int)Swatch
Krita 4.2.0Krita master

get the colorsetEntry from the global index.

DEPRECATED: use `entryByIndex()` instead

Parameters

index

the global index

Return

the colorset entry

colorSetEntryFromGroup(index: int, groupName: str)Swatch
Krita 4.2.0Krita master

DEPRECATED: use `entryByIndexFromGroup()` instead

Parameters

index

index in the group.

groupName

the name of the group to get the color from.

Return

the colorsetentry.

colorsCountGroup(name: str)int
Krita 4.0.0

Parameters

name

of the group to check. Empty is the default group.

Return

the amount of colors within that group.

colorsCountTotal()int
Krita 4.0.0Krita master

number of colors (swatches) in palette NOTE: same as `numberOfEntries()`

Return

total number of colors

columnCount()int
Krita 4.0.0Krita master

Palettes are defined in grids. The number of column define grid width. The number of rows will depend of columns and total number of entries.

Return

the number of columns this palette is set to use.

comment()str
Krita 4.0.0Krita master

the comment or description associated with the palette.

Return

A string for which value contains the comment/description of palette.

entryByIndex(index: int)Swatch
Krita master

get color (swatch) from the global index.

Parameters

index

the global index

Return

The Swatch color for given index.

entryByIndexFromGroup(index: int, groupName: str)Swatch
Krita master

get color (swatch) from the given group index.

Parameters

index

index in the group.

groupName

the name of the group to get the color from.

Return

The Swatch color for given index within given group name.

groupNames()list[str]
Krita 4.0.0Krita master

Palette content can be organized in groups.

Return

The list of group names (list of string). This list follow the order the groups are defined in palette.

moveGroup(groupName: str, groupNameInsertBefore: str = "")
Krita 4.0.0Krita master

Move the group `groupName` to position before group `groupNameInsertBefore`.

Parameters

groupName

group to move.

groupNameInsertBefore

reference group for which `groupName` have to be moved before.

numberOfEntries()int
Krita 4.0.0Krita master

number of colors (swatches) in palette NOTE: same as `colorsCountTotal()`

Return

total number of colors

removeEntry(index: int, groupName: str)
Krita 4.0.0Krita master

remove from defined group a color entry designed by given index.

Parameters

index

index in the group.

groupName

the name of the group within which color have to be removed.

removeGroup(name: str, keepColors: bool = True)
Krita 4.0.0Krita master

Palette content can be organized in groups. This method allows to remove an existing group from palette.

Parameters

name

The name of the new group to remve.

keepColors

whether or not to delete all the colors inside, or to move them to the default group.

renameGroup(oldGroupName: str, newGroupName: str)
Krita master

rename a group

Parameters

oldGroupName

the old groupname to change.

newGroupName

the new name to change it into.

save()bool
Krita 4.0.0Krita master

the palette

WARNING: this method does nothing and need to be implemented!

Return

always False

setColumnCount(columns: int)
Krita 4.0.0Krita master

Palettes are defined in grids. The number of column define grid width, this value can be defined. The number of rows will depend of columns and total number of entries.

Parameters

columns

Set the amount of columns this palette should use.

setComment(comment: str)
Krita 4.0.0Krita master

the comment or description associated with the palette.

Parameters

comment

set the comment or description associated with the palette.