Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I have no knowledge of Python, but because ubuntu recommends it i will use it for the appinidcator.. So i got these 2 files:

enter image description here

and the code of the .py file is:

#!/usr/bin/python

import appindicator
import pynotify
import gtk

a = appindicator.Indicator('wallch_indicator', '/home/paul/scripts/wallch_tray.png', appindicator.CATEGORY_APPLICATION_STATUS)
a.set_status( appindicator.STATUS_ACTIVE )
m = gtk.Menu()
ci = gtk.MenuItem( 'Check' )
qi = gtk.MenuItem( 'Quit' )

m.append(ci)
m.append(qi)

a.set_menu(m)
ci.show()
qi.show()

def checkStatus(item):
        import urllib2
        htmltext = urllib2.urlopen('http://youtube.com/wichitsombat').readlines()
        neededline = []
        for line in htmltext:
                if line.strip().find('stat-value') > -1:
                        neededline.append(line) 

        n = neededline[0]
        subs = n[n.find('>')+1:n.rfind('<')]
        n = neededline[1]
        views = n[n.find('>')+1:n.rfind('<')]

        # show the notification message
        pynotify.init('wallch_indicator')
        n = pynotify.Notification('<b>Paulgramming Channel</b>',
                'subscribers: %s   views: %s'%(subs, views),
                'notification-message-im')
        n.show()

ci.connect('activate', checkStatus)

def quit(item):
        gtk.main_quit()

qi.connect('activate', quit)

gtk.main()

Code taken from this video How to make notification program using Python

When i run python wallch_indicator.py it keeps running but i don't see the indicator..What am i doing wrong?

share|improve this question
    
Works perfectly fine here. I have no clue as to why it shouldn't work on your machine. You don't get any error output when running it? –  gertvdijk Nov 28 '12 at 14:23
    
No error.. I must CRTL+C, and then i get "^CTraceback (most recent call last): File "wallch_indicator.py", line 47, in <module> gtk.main() KeyboardInterrupt" Do i miss a dependency or something? .. –  Leon Vitanos Nov 28 '12 at 14:29
    
check the path to the icon /home/paul/scripts/wallch_tray.png –  wojox Nov 28 '12 at 14:32
    
If you would be missing a dependency you should face an exception like ImportError for Python. –  gertvdijk Nov 28 '12 at 14:33
    
You are right wojox, i forgot to change that one, all works now, thanks ;) –  Leon Vitanos Nov 28 '12 at 14:41
add comment

1 Answer 1

up vote 4 down vote accepted

check the path to the icon /home/paul/scripts/wallch_tray.png

share|improve this answer
    
Thank you, big mistake by me :) –  Leon Vitanos Nov 28 '12 at 14:45
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.