Created
July 25, 2016 12:44
-
-
Save craigcabrey/367eb0b411c0ffb3c4851f6dcd921837 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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