Widget.Icon SVG ignoring CSS color #41
-
I have a Widget.Button with a Widget.Icon inside it (the icon is a local SVG), but the icon's color isn't following the CSS styles. Python Widgetimport os
from ignis.widgets import Widget
icons_folder = os.path.expanduser("~/.config/icons")
def notifications() -> Widget.Button:
return Widget.Button(
css_classes=["notifications"],
on_click=lambda x: print(x),
child=Widget.Icon(
css_classes=["notifications-icon"],
image=f"{icons_folder}/bell-filled.svg",
pixel_size=16
)
) CSS.notifications-icon {
color: #fff;
} SVG<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
<path fill="currentColor" d="M20.52 15.21l-1.8-1.81V8.94a6.86 6.86 0 0 0-5.82-6.88 6.74 6.74 0 0 0-7.62 6.67v4.67l-1.8 1.81A1.64 1.64 0 0 0 4.64 18H8v.34A3.84 3.84 0 0 0 12 22a3.84 3.84 0 0 0 4-3.66V18h3.36a1.64 1.64 0 0 0 1.16-2.79zM14 18.34A1.88 1.88 0 0 1 12 20a1.88 1.88 0 0 1-2-1.66V18h4z" />
</svg> |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 3 replies
-
|
Beta Was this translation helpful? Give feedback.
-
Okay, i found the solution.
<?xml version="1.0" encoding="UTF-8"?>
<gresources>
<gresource prefix="/org/myapp/">
<file>data/icons/scalable/actions/aaaa-symbolic.svg</file>
</gresource>
</gresources> Replace from gi.repository import Gio
resource = Gio.Resource.load("PATH/TO/COMPILED/resources.gresource")
Gio.resources_register(resource)
from gi.repository import Gtk, Gdk
icon_theme = Gtk.IconTheme.get_for_display(Gdk.Display.get_default())
icon_theme.add_resource_path("/org/myapp/data/icons")
Widget.Icon(image="aaaa-symbolic") and it will support changing color with CSS I don't even know how someone could come up with that, but GTK is continue being GTK |
Beta Was this translation helpful? Give feedback.
-
Oh, wait, after 1 month i found better solution It's amazing, but if you add just one directory to the icon path, you don't have to bother with gresource and can simply add a search path to
from gi.repository import Gtk, Gdk
icon_theme = Gtk.IconTheme.get_for_display(Gdk.Display.get_default())
icon_theme.add_search_path("PATH/TO/icons") EDIT: #53 is merged, now you can use the |
Beta Was this translation helpful? Give feedback.
-
I tried |
Beta Was this translation helpful? Give feedback.
Oh, wait, after 1 month i found better solution
It's amazing, but if you add just one directory to the icon path, you don't have to bother with gresource and can simply add a search path to
Gtk.IconTheme
hicolor/scalable/actions
directory. In this example I will useicons/hicolor/scalable/actions
actions
EDIT: #53 is merged, now you can use the
IgnisApp.add_icons()
method