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.

How can I change the Application Indicator label after delay

self.ind = appindicator.Indicator("new-gmail-indicator", "/usr/share/icons/ubuntu-mono-dark/status/16/ubuntuone-client-error.svg", appindicator.CATEGORY_APPLICATION_STATUS)

self.ind.set_label("SSH")

time.sleep(4)

self.ind.set_label("HSS")

The application runs but I only see the HSS label when running the application. I never see SSH.

share|improve this question

1 Answer 1

The problem here is that you've got a single threaded application, and the sleep is blocking it, thus the AppIndicator library doesn't get a chance to update the label. What you need to do for your timeout is use GLib's timeout function to set up a delay, and change the label in that callback. The code would probably look something like:

def set_label(self):
    self.ind.set_label("SSH")
    GLib.timeout_add(4, self.respond_to_timeout)

def respond_to_timeout(self):
    self.ind.set_label("HSS")

Good luck!

share|improve this answer
    
I wanted to do similar thing and I also tried GLib's timeout_add method but it gives me Segmentation fault (core dumped) error. I also tried totally separate thread but it give me Fatal Python error: ceval: tstate mix-up Aborted (core dumped). Though it's an old question, but still hoping to find a solution. –  sparrow May 2 at 16:43

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.