ColorChooserDialog

A ColorChooserDialog provides a dialog window from which a user can choose a colour from a palette offered.

Constructor

The ColorChooserDialog is constructed using:

colorchooserdialog = Gtk.ColorChooserDialog()

Methods

A title should be set on the ColorChooserDialog indicating the function of the dialog:

colorchooserdialog.set_title(title)

Examples

Below is an example of a ColorChooserDialog:

#!/usr/bin/env python3

from gi.repository import Gtk

def color_activated():
    color = colorchooserdialog.get_rgba()

    red = (color.red * 255)
    green = (color.green * 255)
    blue = (color.blue * 255)

    print('Hex: #%02x%02x%02x' % (red, green, blue))

colorchooserdialog = Gtk.ColorChooserDialog()

if colorchooserdialog.run() == Gtk.ResponseType.OK:
    color_activated()

colorchooserdialog.destroy()

Download: ColorChooserDialog