#! /usr/bin/env python
#
# Support module generated by PAGE version 4.9
# In conjunction with Tcl version 8.6
#    Nov 26, 2017 08:41:57 AM
#    Nov 26, 2017 09:11:25 AM


import sys

import requests
from bs4 import BeautifulSoup as bs
import csv
import result
try:
    from Tkinter import *
except ImportError:
    from tkinter import *

try:
    import ttk
    py3 = 0
except ImportError:
    import tkinter.ttk as ttk
    py3 = 1


def set_Tk_var():
    global u
    u = StringVar()
    print u
def get_result():
     r=requests.post('http://aucoe.annauniv.edu/cgi-bin/result/cgrade.pl',data={'regno':u.get()})
     s=bs(r.content,'html.parser')
     f=open('audata-single.csv','a+')
     writer=csv.writer(f)
     a=[]
     for st in s.find_all('strong'):
          a.append(st.text)
     if len(a)!=6:
        while a:
              writer.writerow(a[:3])
              a=a[3:]
     sys.stdout.flush()

def init(top, gui, *args, **kwargs):
    global w, top_level, root
    w = gui
    top_level = top
    root = top

def destroy_window():
    # Function which closes the window.
    global top_level
    top_level.destroy()
    top_level = None

if __name__ == '__main__':
    result.vp_start_gui()




