Skip to content

Instantly share code, notes, and snippets.

@pbuyle
Created January 3, 2009 21:06
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 pbuyle/42931 to your computer and use it in GitHub Desktop.
Save pbuyle/42931 to your computer and use it in GitHub Desktop.
Using the GTK loop to block a Tux Droid script until the K_STANDBY button is pressed (with a bonus status icon)
#! /usr/bin/python
from tuxisalive.api.TuxAPI import *
import gtk
tux = TuxAPI('127.0.0.1', 270)
tux.server.autoConnect(CLIENT_LEVEL_RESTRICTED, 'TuxGTK', 'NONE')
tux.server.waitConnected(10.0)
tux.dongle.waitConnected(10.0)
tux.radio.waitConnected(10.0)
if tux.access.waitAcquire(10.0, ACCESS_PRIORITY_NORMAL):
statusIcon = gtk.status_icon_new_from_file('tuxisalive.ico')
statusIcon.set_visible(True)
tux.button.remote.registerEventOnPressed(gtk.main_quit, K_STANDBY)
gtk.gdk.threads_init()
gtk.main()
tux.access.release()
tux.server.disconnect()
tux.destroy()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment