Created
January 1, 2016 19:42
-
-
Save mhanoglu/044b42c3cb3cbbb1194b to your computer and use it in GitHub Desktop.
Ubuntu, elementaryOS için indikatör örneği
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
# -*- coding: utf-8 -*- | |
import os | |
import time | |
import gobject | |
import glib | |
import gtk | |
import appindicator | |
def _( x ): return x.decode('u8') | |
class AppIndicatorUI : | |
def __init__( self ) : | |
self.menu = gtk.Menu() | |
self.items = {} | |
self.data = {} | |
self.run = True | |
self.icon_active = os.getenv( "HOME" ) + "/Masaüstü/ikon.png" | |
self.ind = appindicator.Indicator(_("İndikator Örneği"), self.icon_active, appindicator.CATEGORY_OTHER) | |
#print dir(self.ind) | |
self.ind.set_status( appindicator.STATUS_ACTIVE ) | |
self.ind.set_label(_("İndikator")) | |
self.build_menu() | |
def build_menu( self ) : | |
self.items['sep2'] = gtk.SeparatorMenuItem() | |
self.menu.append( self.items['sep2'] ) | |
self.items['about'] = gtk.MenuItem(_('Hakkında')) | |
self.items['about'].connect('activate', self._about ) | |
self.menu.append( self.items['about'] ) | |
self.items['quit'] = gtk.MenuItem(_('Çıkış')) | |
self.items['quit'].connect('activate', self._quit ) | |
self.menu.append( self.items['quit'] ) | |
def _about( self, event ) : | |
print "about" | |
#print dir(event) | |
def _quit( self, event ) : | |
print "quit" | |
self.run = False | |
gtk.main_quit() | |
def _refresh( self ) : | |
self.ind.set_label(_("Yenilendi")) | |
print "_refresh" | |
return self.run | |
def show( self ) : | |
self.ind.set_menu( self.menu ) | |
self.menu.show_all() | |
glib.timeout_add_seconds( 5, self._refresh ) # 5.sn de bir yenile | |
gtk.main() | |
ind = AppIndicatorUI() | |
ind.show() | |
# END |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment