#! /usr/bin/env python
#  -*- coding: utf-8 -*-
#
# Support module generated by PAGE version 4.21
#  in conjunction with Tcl version 8.6
#    Mar 13, 2019 03:06:49 PM IST  platform: Linux
#    Mar 14, 2019 11:50:00 AM IST  platform: Linux

import sys
from tkinter import messagebox
try:
    import Tkinter as tk
except ImportError:
    import tkinter as tk

try:
    import ttk
    py3 = False
except ImportError:
    import tkinter.ttk as ttk
    py3 = True

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

def set_Tk_var():
    global egg, kitkat, vegS, nvegS
    egg = tk.IntVar()
    kitkat = tk.IntVar()
    vegS = tk.IntVar()
    nvegS = tk.IntVar()
    global account
    account = dict()
    global eggC, kitkatC, vegSC, nvegSC

    eggC = tk.IntVar()
    eggC.set(1)
    kitkatC = tk.IntVar()
    kitkatC.set(1)
    vegSC = tk.IntVar()
    vegSC.set(1)
    nvegSC = tk.IntVar()
    nvegSC.set(1)
    

def cancel():
    destroy_window()

def items(checked):
    to_display =[]
    [to_display.append(str(i+1)+". "+item[0]+":   "+str(item[1])+"\n") for i,item in enumerate(checked)]
    return ''.join(to_display)
     
def next():
    account['Egg'] = [egg.get(),eggC.get()]
    account['Kitkat'] = [kitkat.get(), kitkatC.get()]
    account['Veg soup'] = [vegS.get(), vegSC.get()]
    account['Chicken soup'] = [nvegS.get(), nvegSC.get()]
    #[print(key,value) for key,value in account.items()]
    checked = []
    [checked.append([key,value[1]]) for key, value in account.items() if (value[0]== 1)]
    if len(checked) == 0:
       wngbox = tk.messagebox.showwarning("Warning","Select atleast one item to confirm!")
    
    else:
        msgbox = tk.messagebox.askokcancel("Confirmation","Would you like to confirm the items?\n\n"+str(items(checked)))
        if msgbox:
          print("Data stored!!") 
          destroy_window()

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


if __name__ == '__main__':
    import second_win
    second_win.vp_start_gui()




