#!/usr/bin/env python3 import gi gi.require_version('Gtk', '3.0') from gi.repository import Gtk from .image import ScaleImage class ImageButton(Gtk.Button): def __init__(self, filepath, width = 26, height = 26): Gtk.Button.__init__(self) self.set_name('ImageButton') self.set_size_request(width, height) image = ScaleImage(filepath) image.resize(width, height) self.set_image(image) css_provider = Gtk.CssProvider() style = f""" #ImageButton {{ border: 0; background-color: transparent; outline: none; }} """ css_provider.load_from_data(style.encode('UTF-8')) context = self.get_style_context() context.add_provider(css_provider, Gtk.STYLE_PROVIDER_PRIORITY_USER)