from pgi.repository import Gtk

class ColorChooserWindow(Gtk.Window):
    def __init__(self):
        Gtk.Window.__init__(self, title="Main Window")
        self.colorlist = list()

        box = Gtk.Box(spacing=6)
        self.add(box)

        button1 = Gtk.Button("Choose Color")
        button1.connect("clicked", self.on_color_clicked)
        box.add(button1)

    def on_color_clicked(self, widget):
        dialog = Gtk.ColorChooserDialog("Choose a Color", self, 0)

        response = dialog.run()
        if response == Gtk.ResponseType.OK:
            color = dialog.get_rgba()
            print("color choosen: " + color.to_string())
            print("red: {}".format(color.red))
            self.colorlist.append(ColorInstance(color))
        elif response == Gtk.ResponseType.CANCEL:
            print("cancel clicked")

        dialog.destroy()

class ColorInstance():
    def __init__(self, gtk_rgba):
        self.color = gtk_rgba


class ColorSchemer():

    def __init__(self):
        self.win = ColorChooserWindow()
        self.win.connect("delete-event", Gtk.main_quit)
        self.win.show_all()


if __name__ == '__main__':
    schemer = ColorSchemer()
    Gtk.main()
