Oct 27 2008

reload program after logoff in python/pygtk

Category: gtk,pygtk,pythonerm @ 6:28 pm

This snippit of code will restart/reload your python/pygtk app when you log out so you don’t have to keep restarting it.

import gnome.ui
gnome.program_init('program name', "1.0")
client = gnome.ui.master_client()
command = os.path.normpath(os.path.join(os.getcwd(), sys.argv[0]))
try: client.set_restart_command([command] + sys.argv[1:])
except TypeError:
	client.set_restart_command(len(sys.argv), [command] + sys.argv[1:])
client.connect('die', gtk.main_quit)

Tags: , , , , ,

Leave a Reply

You must be logged in to post a comment. Login now.