KDE 4.4 PyKDE API Reference
  • KDE's Python API
  • Overview
  • PyKDE Home
  • Sitemap
  • Contact Us
 

KColorDialog Class Reference

from PyKDE4.kdeui import *

Inherits: KDialog → QDialog → QWidget → QObject

Detailed Description

A color selection dialog.

Features:\n

  • Color selection from a wide range of palettes.
  • Color selection from a palette of H vs S and V selectors.
  • Direct input of HSV or RGB values.
  • Saving of custom colors
  • In most cases, you will want to use the static method KColorDialog.getColor(). This pops up the dialog (with an initial selection provided by you), lets the user choose a color, and returns.

    Example:

     	QColor myColor;
     	int result = KColorDialog.getColor( myColor );
             if ( result == KColorDialog.Accepted )
                ...
    

    To react to the color selection as it is being selected, the colorSelected() signal can be used. This can be used still in a modal way, for example:

      KColorDialog dialog(this);
      connect(&dialog, SIGNAL(colorSelected(const QColor &)), this, SLOT(temporarilyChangeColor(const QColor &)));
      QColor myColor;
      dialog.setColor(myColor);
      int result = dialog.exec();
    
      if ( result == KColorDialog.Accepted )
        changeColor( dialog.color() );
      else
        temporarilyChangeColor(myColor); //change back to original color
    

    "KDE Color Dialog"

    The color dialog is really a collection of several widgets which can you can also use separately: the quadratic plane in the top left of the dialog is a KXYSelector. Right next to it is a KHSSelector for choosing hue/saturation.

    On the right side of the dialog you see a KColorTable showing a number of colors with a combo box which offers several predefined palettes or a palette configured by the user. The small field showing the currently selected color is a KColorPatch.


    Signals

     colorSelected (, QColor col)

    Methods

     __init__ (self, QWidget parent=0, bool modal=0)
     __init__ (self, KColorDialog a0)
    QColor color (self)
     colorSelected (self, QColor col)
    QColor defaultColor (self)
    bool eventFilter (self, QObject obj, QEvent ev)
    int getColor (self, QColor theColor, QWidget parent=0)
    int getColor (self, QColor theColor, QColor defaultColor, QWidget parent=0)
    QColor grabColor (self, QPoint p)
     keyPressEvent (self, QKeyEvent a0)
     mouseMoveEvent (self, QMouseEvent a0)
     mouseReleaseEvent (self, QMouseEvent a0)
     setColor (self, QColor col)
     setDefaultColor (self, QColor defaultCol)

    Method Documentation

    __init__ (  self,
    QWidget  parent=0,
    bool  modal=0
    )

    Constructs a color selection dialog.

    __init__ (  self,
    KColorDialog  a0
    )
    QColor color (   self )

    Returns the currently selected color.

    colorSelected (  self,
    QColor  col
    )

    Emitted when a color is selected. Connect to this to monitor the color as it as selected if you are not running modal.

    Signal syntax:
    QObject.connect(source, SIGNAL("colorSelected(const QColor&)"), target_slot)
    QColor defaultColor (   self )

    Returns:
    the value passed to setDefaultColor

    bool eventFilter (  self,
    QObject  obj,
    QEvent  ev
    )
    int getColor (  self,
    QColor  theColor,
    QWidget  parent=0
    )

    Creates a modal color dialog, lets the user choose a color, and returns when the dialog is closed.

    The selected color is returned in the argument theColor.

    This version takes a defaultColor argument, which sets the color selected by the "default color" checkbox. When this checkbox is checked, the invalid color (QColor()) is returned into theColor.

    Parameters:
    theColor  if valid, specifies the color to be initially selected. On return, holds the selected color.
    defaultColor  color selected by the "default color" checkbox

    Returns:
    QDialog.result().

    int getColor (  self,
    QColor  theColor,
    QColor  defaultColor,
    QWidget  parent=0
    )

    Creates a modal color dialog, lets the user choose a color, and returns when the dialog is closed.

    The selected color is returned in the argument theColor.

    This version takes a defaultColor argument, which sets the color selected by the "default color" checkbox. When this checkbox is checked, the invalid color (QColor()) is returned into theColor.

    Parameters:
    theColor  if valid, specifies the color to be initially selected. On return, holds the selected color.
    defaultColor  color selected by the "default color" checkbox

    Returns:
    QDialog.result().

    QColor grabColor (  self,
    QPoint  p
    )

    Gets the color from the pixel at point p on the screen.

    keyPressEvent (  self,
    QKeyEvent  a0
    )
    mouseMoveEvent (  self,
    QMouseEvent  a0
    )
    mouseReleaseEvent (  self,
    QMouseEvent  a0
    )
    setColor (  self,
    QColor  col
    )

    Preselects a color.

    setDefaultColor (  self,
    QColor  defaultCol
    )

    Call this to make the dialog show a "Default Color" checkbox. If this checkbox is selected, the dialog will return an "invalid" color (QColor()). This can be used to mean "the default text color", for instance, the one with the KDE text color on screen, but black when printing.

    • Full Index

    Modules

    • akonadi
    • dnssd
    • kdecore
    • kdeui
    • khtml
    • kio
    • knewstuff
    • kparts
    • kutils
    • nepomuk
    • phonon
    • plasma
    • polkitqt
    • solid
    • soprano
    This documentation is maintained by Simon Edwards.
    KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal