I wrote a python-cgi script (raspberry) that shows a page in the browser with some data. I will enter in this page from an other pc (linux, mac, etc.) entering usual address (//localhost/cgi-bin/myscript.py) in the browser. The page will be shown in fullscreen mode. I would have a button on the page that, as pushed, the page will close and exit the browser. I tried with pygame button and with submit (post or get method) button but with no success (I'm not really expert!). Anybody can help me? Thanks
#!/usr/bin/python
import os.path, sys, datetime, time
import cgi, cgitb
import os
import RPi.GPIO as io
import pygame, random, pygame.font, pygame.event, pygame.draw, string
import common
pygame.init()
io.setmode(io.BCM)
os.system('modprobe w1-gpio')
os.system('modprobe w1-therm')
ctime = datetime.datetime.now()
clock = ctime.strftime("%H:%M")
date = ctime.strftime("%A %d")
form = cgi.FieldStorage()
fileobj = open('/sys/bus/w1/devices/28-0000065fb5c1/w1_slave','r')
lines1 = fileobj.readlines()
fileobj.close()
Temp2 = int(5)
Temp= form.getvalue(Temp2)
print "Content-type: text/html\n\n"
def main():
        print "<html>"
        print "<head>"
        print "<meta http-equiv='refresh' content='5' >"
        print "</head>"
        print "<body>"
        print "<body bgcolor=""#000000"">"
        fileobj = open('/sys/bus/w1/devices/28-0000065fb5c1/w1_slave','r')
        lines1 = fileobj.readlines()
        fileobj.close()
        Temp2 = int(5)
        if (lines1[0][-4])=='Y':
                pos1=lines1[1].index('t=')
                Temp2 = int(lines1[1][pos1+2:])/1000
                Temp2=round(Temp2,1)
                time.sleep(1)
        print "<table style=""width:1920px"">"
        print "<tr height=""60"">"
        print "</tr>"
        print "<tr height=""400"">"
        print "<td width=""442px"" >"
        print "</td>"
        if Temp2 <= 32:
            print "<td width=""345""  background=""//192.168.10.32/dashblue.png"" >" 
            print "<font size=""7"" color=""#00FFF"" face=""sans-serif"" >"
            print "<p align=""center"">"
            print "<b>"
            print Temp2
            degree = chr(176)
            print degree
            print "</b>"
            print "</p>"
            print "</font>"
            print "</td>"
        elif Temp2 > 32 and Temp2 <= 37:
            print "<td width=""345""  background=""//192.168.10.32/dashgreen.png"" >" 
            print "<font size=""7"" color=""#00FFF"" face=""sans-serif"" >"
            print "<p align=""center"">"
            print "<b>"
            print Temp2
            degree = chr(176)
            print degree
            print "</b>"
            print "</p>"
            print "</font>"
            print "</td>"
        if Temp2 > 37:
            print "<td width=""345""  background=""//192.168.10.32/dashred.png"" >" 
            print "<font size=""7"" color=""#00FFF"" face=""sans-serif"" >"
            print "<p align=""center"">"
            print "<b>"
            print Temp2       
            degree = chr(176)
            print degree
            print "</b>"
            print "</p>"
            print "</font>"
            print "</td>" 
        file = open('/home/pi/Downloads/temperat.txt','r')
        lines = file.readlines()
        file.close()
        Temp = float(lines[0][:4])
        Temp=round(Temp,1)
        if Temp <= 22:
            print "<td width=""345""  background=""//192.168.10.32/dashblue.png"" >" 
            print "<font size=""7"" color=""#00FFF"" face=""sans-serif"" >"
            print "<p align=""center"">"
            print "<b>"
            print Temp
            degree = chr(176)
            print degree
            print "</b>"
            print "</p>"
            print "</font>"
            print "</td>"
        elif Temp > 22 and Temp <= 26:
            print "<td width=""345""  background=""//192.168.10.32/dashgreen.png"" >" 
            print "<font size=""7"" color=""#00FFF"" face=""sans-serif"" >"
            print "<p align=""center"">"
            print "<b>"
            print Temp
            degree = chr(176)
            print degree
            print "</b>"
            print "</p>"
            print "</font>"
            print "</td>"
        if Temp > 27:
            print "<td width=""345""  background=""//192.168.10.32/dashred.png"" >" 
            print "<font size=""7"" color=""#00FFF"" face=""sans-serif"" >"
            print "<p align=""center"">"
            print "<b>"
            print Temp       
            degree = chr(176)
            print degree
            print "</b>"
            print "</p>"
            print "</font>"
            print "</td>" 
        Hum=int(lines[1])
        print "<td width=""345""  background=""//192.168.10.32/dashblue.png"" >" 
        print "<font size=""7"" color=""#00FFF"" face=""sans-serif"" >"
        print"<p align=""center"">"
        print "<b>"
        print Hum
        degree = chr(37)
        print degree
        print "</b>"
        print "</p>"
        print "</td>"
        print "<td width=""6%"" >"
        print "</font>"
        print "</td>"
        print "</tr>"
        print "<tr height=""80"">"
        print "<td width=""6%"" >"
        print "</td>"
        print "<td width=""345"">" 
        print "<font size=""7"" color=""#00FFF"" face=""sans-serif"" >"
        print "</p>"
        print "<p align=""center"">"
        print "Water Temperature"
        print "</p>"
        print "</font>"
        print "</td>"   
        print "<td width=""345"" >"
        print "<font size=""7"" color=""#00FFF"" face=""sans-serif"" >"
        print "<p align=""center"">"
        print "Bath Temperature"
        print "</p>"
        print "</font>"
        print "</td>"       
        print "<td width=""345"" >"
        print "<font size=""7"" color=""#00FFF"" face=""sans-serif"" >"
        print"<p align=""center"">"
        print "Bath Humidity"
        print "</p>"
        print "</font>"
        print "</td>"
        print "<td width=""442px"" >"
        print "</td>"
        print "</tr>"
        print "</table>"
        print "<font size=""10"" color=""#00FFF"" face=""sans-serif"" >"
        print "<h1 align=""center"">now..%s    %s</h1>" % (date,clock)
        print "</font>"
        print "</body>"
        print "</html>"
        for event in pygame.event.get():
            if event.type == QUIT or (event.type == pygame.KEYUP and event.key == pygame.K_F6):
                pygame.quit()
                sys.exit()
if (__name__=='__main__'):
        main()
 
     
    