Skip to content

Instantly share code, notes, and snippets.

@craigcabrey
Created July 25, 2016 12:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save craigcabrey/367eb0b411c0ffb3c4851f6dcd921837 to your computer and use it in GitHub Desktop.
Save craigcabrey/367eb0b411c0ffb3c4851f6dcd921837 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python3
import sys
import gi
gi.require_version('Gtk', '3.0')
from gi.repository import Gtk
class Application(Gtk.Application):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.window = None
def do_startup(self):
Gtk.Application.do_startup(self)
def do_activate(self):
Gtk.Application.do_activate(self)
if not self.window:
self.window = Window(application=self)
self.window.show_all()
self.window.present()
class Window(Gtk.ApplicationWindow):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
color_chooser = Gtk.ColorChooserWidget(show_editor=True, use_alpha=False)
color_chooser.connect('color-activated', self._on_color_activated)
self.add(color_chooser)
def _on_color_activated(self, *args):
colors = ', '.join([str(elem) for elem in args[0].get_rgba()])
print('activated with rgba(' + colors + ')')
if __name__ == '__main__':
app = Application()
app.run(sys.argv)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment