Jan-23-2021, 10:09 AM
(This post was last modified: Jan-23-2021, 10:09 AM by Axel_Erfurt.)
try this (change "icon.png" to your icon name)
import gi gi.require_version("Gtk", "3.0") from gi.repository import Gtk class ButtonWindow(Gtk.Window): def __init__(self): Gtk.Window.__init__(self, title="Button Demo") self.set_border_width(10) hbox = Gtk.Box(spacing=6) self.add(hbox) button = Gtk.Button() grid = Gtk.Grid () img = Gtk.Image() img.set_from_file("icon.png") label = Gtk.Label (label='test button\nwith two lines') label.set_justify(Gtk.Justification.CENTER) grid.attach (img, 0, 0, 1, 1) grid.attach (label, 0, 1, 1, 1) grid.show_all () button.add (grid) button.connect("clicked", self.on_click_me_clicked) hbox.pack_start(button, True, True, 0) def on_click_me_clicked(self, button): print('"Click me" button was clicked') Gtk.main_quit() win = ButtonWindow() win.connect("destroy", Gtk.main_quit) win.show_all() Gtk.main()