#!/usr/bin/python

from Tkinter import *
import os

test = 0

def func():
    global time
    global timeleft

    timeleft = timeleft - 1

    if (not timeleft):
	if (test):
	    print "Killing X!"
	else:
	    os.system("./killall X")

    time['text'] = "Seconds left: %d" % timeleft
    time.after(1000, func)

def done():
    global timeleft
    global time

    timeleft = 10000
    
    if (test):
	print "Creating /tmp/xworked and /usr/rhs/install/install"
	time.quit()
    else:
	f = open("/tmp/xworked", "w")
	f.close()
        os.execv("./install", ("./install", ))
	print "God is against me :-("
	self.quit()

f = Frame(None)
l = Label(f, {'text' : 'Click on Ok if this looks good'})
l.pack()
time = Label(f, {'text' : 'Seconds left: 30'})
timeleft = 30
time.pack()
time.after(1000, func)
b = Button(f, {'text' : 'Ok', 'command' : done} )
b.pack()
f.pack()
l.mainloop()
