Skip to content

Instantly share code, notes, and snippets.

@virtuald
Created July 6, 2016 04:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save virtuald/0a9143a0f4ec54327bbf75001f1d6dcf to your computer and use it in GitHub Desktop.
Save virtuald/0a9143a0f4ec54327bbf75001f1d6dcf to your computer and use it in GitHub Desktop.
Working StatusIcon code
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