Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5952767
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T17:43:42+00:00 2026-05-22T17:43:42+00:00

Experimenting with a battery monitor icon at the moment in Python using pygtk and

  • 0

Experimenting with a battery monitor icon at the moment in Python using pygtk and egg.trayicon to create an icon to display a battery icon/tooltip.

I seem to be able to add the icon and the tooltip text, but when it then reaches the gtk.main() stage I need a way to modify these so it can then show the updated values.

I’ve tried gobject.idle_add() and gobject.timeout_add() without much luck, not sure where to go from this.

Anyone got any ideas?

EDIT: Perhaps not the clearest of questions.

I need to loop, fetching information from acpi while running and apply it to widgets inside the gtk container.

EDIT 2: Ok, it’s properly down now. The issue was that I wasn’t returning anything inside my callback. I just gave it “return 123” and now it’s happily chugging away in my system tray, notifying me of my battery percentage 🙂

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T17:43:43+00:00Added an answer on May 22, 2026 at 5:43 pm

    This example works for me:

    # -*- Mode: Python -*-
    # vi:si:et:sw=4:sts=4:ts=4
    
    import gobject
    import gtk
    from egg import trayicon
    
    label = gtk.Label("Over here")
    
    def callback(widget, ev):
        label.set_text("You found me")
    
    def timeout():
        label.set_text("What are you waiting for?")
    
    tray = trayicon.TrayIcon("TrayIcon")
    box = gtk.EventBox()
    box.add(label)
    tray.add(box)
    tray.show_all()
    
    box.connect("button-press-event", callback)
    
    gobject.timeout_add(3000L, timeout)
    
    gtk.main()
    

    Without seeing your code, it’s hard to tell what doesn’t work.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

been experimenting with unordered list UL and i have seem varios examples of using
I am experimenting with drawing on a canvas using a thread to create a
Experimenting with android game development. I'm using PNG format for images, and was wondering
I'm experimenting with Spring Mobile but I can't seem to get the basic example
I'm experimenting with OnStart() in my Azure role using small instances. Turns out it
Just experimenting and learning, and I know how to create a shared dictionary that
I've been experimenting with the standard python math module and have come across some
I am experimenting with Ruby and Rails on OS X, using the XCode text
Experimenting with Swing, I learnt that there are two ways of using JOptionPane and
I experimenting with creating a simple finger-painting application on the ipad. I am able

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.