#!/usr/bin/python3 import sys import gi gi.require_version('Gtk', '3.0') from gi.repository import Gtk class AppWindow(Gtk.ApplicationWindow): def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.set_border_width(10) button = Gtk.Button.new() hbox = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=0) icon_theme = Gtk.IconTheme.get_default() icon = icon_theme.load_icon("window-close", -1, Gtk.IconLookupFlags.FORCE_SIZE) image = Gtk.Image.new_from_pixbuf(icon) hbox.add(image) label = Gtk.Label.new_with_mnemonic("_Close") hbox.add(label) hbox.set_homogeneous(True) button.add(hbox) button.connect("clicked", self.on_button_clicked) button.set_relief(Gtk.ReliefStyle.NORMAL) self.add(button) self.set_size_request(230, 100) def on_button_clicked(self, param): self.destroy() class Application(Gtk.Application): def __init__(self, *args, **kwargs): super().__init__(*args, application_id="org.example.myapp", **kwargs) self.window = None def do_activate(self): if not self.window: self.window = AppWindow(application=self, title="Look-alike Stock Item") self.window.show_all() self.window.present() if __name__ == "__main__": app = Application() app.run(sys.argv)