Created
July 11, 2024 18:17
-
-
Save acristoffers/ab2ed3b4b6e0ce67a2484c33822fc2fd to your computer and use it in GitHub Desktop.
Symbolic SVG with GTK4 in Python
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
import gi | |
import os | |
gi.require_version("Gtk", "4.0") | |
from gi.repository import Gtk | |
from gi.repository import Gio | |
def on_activate(app): | |
win = Gtk.ApplicationWindow(application=app) | |
pwd = os.path.dirname(os.path.abspath(__file__)) | |
icon_path = os.path.join(pwd, "icon-symbolic.svg") | |
icon = Gio.Icon.new_for_string(icon_path) | |
img = Gtk.Image.new_from_gicon(icon) | |
img.set_pixel_size(512) | |
win.set_child(img) | |
win.present() | |
app = Gtk.Application(application_id="org.gtk.Example") | |
app.connect("activate", on_activate) | |
app.run(None) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment