KDE 4.9 PyKDE API Reference

- KDE's Python API

# KColorCollection Class Reference

`from PyKDE4.kdeui import *`

## Detailed Description

Class for handling color collections ("palettes").

This class makes it easy to handle color collections, sometimes referred to as "palettes". This class can read and write collections from and to a file.

This class uses the "GIMP" palette file format.

Author:
  Waldo Bastian (bastian@kde.org)

## Enumerations

Editable | { Yes, No, Ask }

## Methods

| __init__ (self, QString name=QString())
| __init__ (self, KColorCollection a0)
int | addColor (self, QColor newColor, QString newColorName=QString())
int | changeColor (self, int index, QColor newColor, QString newColorName=QString())
int | changeColor (self, QColor oldColor, QColor newColor, QString newColorName=QString())
QColor | color (self, int index)
int | count (self)
QString | description (self)
KColorCollection.Editable | editable (self)
int | findColor (self, QColor color)
QString | name (self)
QString | name (self, int index)
QString | name (self, QColor color)
bool | save (self)
| setDescription (self, QString desc)
| setEditable (self, KColorCollection.Editable editable)
| setName (self, QString name)

## Static Methods

QStringList | installedCollections ()

## Method Documentation

__init__ | ( | self, |
|  | QString | name=QString()
| ) |  |  |

KColorCollection constructor. Creates a KColorCollection from a file the filename is derived from the name.

Parameters:

  | name | The name of collection as returned by installedCollections()

__init__ | ( | self, |
|  | KColorCollection | a0
| ) |  |  |

KColorCollection copy constructor.

int addColor | ( | self, |
|  | QColor | newColor,
|  | QString | newColorName=QString()
| ) |  |  |

Add a color.

Parameters:

  | newColor | The color to add.
  | newColorName | The name of the color, null to remove the name.

Returns:
  The index of the added color.

int changeColor | ( | self, |
|  | int | index,
|  | QColor | newColor,
|  | QString | newColorName=QString()
| ) |  |  |

Change a color.

Parameters:

  | oldColor | The original color
  | newColor | The new color.
  | newColorName | The new color name, null to remove the name.

Returns:
  The index of the new color or -1 if the color couldn't be changed.

int changeColor | ( | self, |
|  | QColor | oldColor,
|  | QColor | newColor,
|  | QString | newColorName=QString()
| ) |  |  |

Change a color.

Parameters:

  | oldColor | The original color
  | newColor | The new color.
  | newColorName | The new color name, null to remove the name.

Returns:
  The index of the new color or -1 if the color couldn't be changed.

QColor color | ( | self, |
|  | int | index
| ) |  |  |

Find color by index.

Parameters:

  | index | the index of the desired color

Returns:
  The index -th color of the collection, null if not found.

int count | ( |  | self ) |

Return the number of colors in the collection.

Returns:
  the number of colors

QString description | ( |  | self ) |

Get the description of the collection.

Returns:
  the description of the collection.

KColorCollection.Editable editable | ( |  | self ) |

Returns whether the collection may be edited.

Returns:
  the state of the collection

int findColor | ( | self, |
|  | QColor | color
| ) |  |  |

Find index by color.

Parameters:

  | color | the color to find

Returns:
  The index of the color in the collection or -1 if the color is not found.

QString name | ( |  | self ) |

Find color name by color.

Returns:
  The name of color according to this collection. Note that not all collections have named the colors. Note also that each collection can give the same color a different name.

QString name | ( | self, |
|  | int | index
| ) |  |  |

Find color name by color.

Returns:
  The name of color according to this collection. Note that not all collections have named the colors. Note also that each collection can give the same color a different name.

QString name | ( | self, |
|  | QColor | color
| ) |  |  |

Find color name by color.

Returns:
  The name of color according to this collection. Note that not all collections have named the colors. Note also that each collection can give the same color a different name.

bool save | ( |  | self ) |

Save the collection

Returns:
  'true' if successful

setDescription | ( | self, |
|  | QString | desc
| ) |  |  |

Set the description of the collection.

Parameters:

  | desc | the new description

setEditable | ( | self, |
|  | KColorCollection.Editable | editable
| ) |  |  |

Change whether the collection may be edited.

Parameters:

  | editable | the state of the collection

setName | ( | self, |
|  | QString | name
| ) |  |  |

Set the name of the collection.

Parameters:

  | name | the name of the collection

## Static Method Documentation

QStringList installedCollections | ( |  | ) |

Query which KDE color collections are installed.

Returns:
  A list with installed color collection names.

## Enumeration Documentation

Editable

Used to specify whether a collection may be edited.

See also:
  editable()

See also:
  setEditable()

Enumerator:

  Yes |
  No |
  Ask |