Created
July 6, 2016 04:52
-
-
Save virtuald/0a9143a0f4ec54327bbf75001f1d6dcf to your computer and use it in GitHub Desktop.
Working StatusIcon code
This file contains hidden or 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 | |
gi.require_version('Gtk', '3.0') | |
from gi.repository import Gtk, GdkPixbuf, GLib | |
win = Gtk.Window() | |
win.connect("delete-event", Gtk.main_quit) | |
win.show_all() | |
theme = Gtk.IconTheme.get_default() | |
_sizes = [16, 22, 24, 32, 48, 128, 'scalable'] | |
for s in reversed(_sizes): | |
try: | |
px = GdkPixbuf.Pixbuf.new_from_file('data/images/%sx%s/exaile.png' % (s, s)) | |
except: | |
px = GdkPixbuf.Pixbuf.new_from_file('data/images/%s/exaile.svg' % s) | |
s = s if s != 'scalable' else -1 | |
theme.add_builtin_icon('exaile', s, px) | |
icon = Gtk.StatusIcon() | |
icon.set_from_icon_name('exaile') | |
icon.set_tooltip_text("WTF") | |
icon.set_visible(True) | |
def later(): | |
print "Got size", icon.get_size() | |
GLib.timeout_add_seconds(1, later) | |
Gtk.main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment