#! /usr/bin/env python
#  -*- coding: utf-8 -*-
#
# GUI module generated by PAGE version 4.19
#  in conjunction with Tcl version 8.6
#    Nov 25, 2018 06:44:15 PM CET  platform: Windows NT

import sys
from PIL import ImageTk,Image
import webbrowser


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

import Mainpage_support

def vp_start_gui():
    '''Starting point when module is the main routine.'''
    global val, w, root
    root = tk.Tk()
    top = TopLevel1 (root)
    Mainpage_support.init(root, top)
    root.mainloop()

w = None
def create_TopLevel1(root, *args, **kwargs):
    '''Starting point when module is imported by another program.'''
    global w, w_win, rt
    rt = root
    w = tk.Toplevel (root)
    top = TopLevel1 (w)
    Mainpage_support.init(w, top, *args, **kwargs)
    return (w, top)

def destroy_TopLevel1():
    global w
    w.destroy()
    w = None

"""
customized functions for commands
"""
def contents(filename):
    contents = open(filename, 'r').read()
    return contents


def callwebsite(event):
    webbrowser.open_new(r"andreasturm.ch")

def tasks():
    import Task_01
    C1 = Task_01.vp_start_gui()

def ETO_design():
    import ETO_design
    C2 = ETO_design.vp_start_gui()

def orders():
    import Orders
    C5 = Orders.vp_start_gui()

def productions():
    import Productions
    C6 = Productions.vp_start_gui()

def location_tracking():
    import Locations
    C7 = Locations.vp_start_gui()

def delivery_service():
    import Delivery
    C8 = Delivery.vp_start_gui()

def quality_inspect():
    import Quality
    C9 = Quality.vp_start_gui()

def reshipping():
    import Reship
    C10 = Reship.vp_start_gui()

def change_request():
    import Request
    C12 = Request.vp_start_gui()

def material_status():
    import Mstatus
    C13 = Mstatus.vp_start_gui()

"""
interface
"""

class TopLevel1:
    def __init__(self, top=None):
        '''This class configures and populates the toplevel window.
           top is the toplevel containing window.'''
        _bgcolor = '#d9d9d9'  # X11 color: 'gray85'
        _fgcolor = '#000000'  # X11 color: 'black'
        _compcolor = '#d9d9d9' # X11 color: 'gray85'
        _ana1color = '#d9d9d9' # X11 color: 'gray85' 
        _ana2color = '#ececec' # Closest X11 color: 'gray92' 

        top.geometry("863x607+378+199")
        top.title("On-demand Construction Material Management")
        top.configure(background="#d9d9d9")
        top.configure(highlightbackground="#d9d9d9")
        top.configure(highlightcolor="black")
        top.wm_iconbitmap('logo.ico')

        self.menubar = tk.Menu(top,font="TkMenuFont",bg=_bgcolor,fg=_fgcolor)
        top.configure(menu = self.menubar)

        self.sub_menu = tk.Menu(top,tearoff=0)
        self.menubar.add_cascade(menu=self.sub_menu,
                activebackground="#ececec",
                activeforeground="#000000",
                background="#d9d9d9",
                font="TkMenuFont",
                foreground="#000000",
                label="Planning&Design")
        self.sub_menu.add_command(
                activebackground="#ececec",
                activeforeground="#000000",
                background="#d9d9d9",
                font="TkMenuFont",
                foreground="#000000",
                label="Task Planning", command=tasks)
        self.sub_menu.add_command(
                activebackground="#ececec",
                activeforeground="#000000",
                background="#d9d9d9",
                font="TkMenuFont",
                foreground="#000000",
                label="ETO material", command=ETO_design)
        # self.sub_menu.add_command(
        #         activebackground="#ececec",
        #         activeforeground="#000000",
        #         background="#d9d9d9",
        #         font="TkMenuFont",
        #         foreground="#000000",
        #         label="ATO material")
        # self.sub_menu.add_command(
        #         activebackground="#ececec",
        #         activeforeground="#000000",
        #         background="#d9d9d9",
        #         font="TkMenuFont",
        #         foreground="#000000",
        #         label="MTO material")
        self.sub_menu1 = tk.Menu(top,tearoff=0)
        self.menubar.add_cascade(menu=self.sub_menu1,
                activebackground="#ececec",
                activeforeground="#000000",
                background="#d9d9d9",
                font="TkMenuFont",
                foreground="#000000",
                label="Procurement")
        self.sub_menu1.add_command(
                activebackground="#ececec",
                activeforeground="#000000",
                background="#d9d9d9",
                font="TkMenuFont",
                foreground="#000000",
                label="Material orders", command = orders)
        self.sub_menu1.add_command(
                activebackground="#ececec",
                activeforeground="#000000",
                background="#d9d9d9",
                font="TkMenuFont",
                foreground="#000000",
                label="Material production", command = productions)
        self.sub_menu12 = tk.Menu(top,tearoff=0)
        self.menubar.add_cascade(menu=self.sub_menu12,
                activebackground="#ececec",
                activeforeground="#000000",
                background="#d9d9d9",
                font="TkMenuFont",
                foreground="#000000",
                label="Delivery")
        self.sub_menu12.add_command(
                activebackground="#ececec",
                activeforeground="#000000",
                background="#d9d9d9",
                font="TkMenuFont",
                foreground="#000000",
                label="Location tracking", command = location_tracking)
        self.sub_menu12.add_command(
                activebackground="#ececec",
                activeforeground="#000000",
                background="#d9d9d9",
                font="TkMenuFont",
                foreground="#000000",
                label="Delivery services", command = delivery_service)
        self.sub_menu123 = tk.Menu(top,tearoff=0)
        self.menubar.add_cascade(menu=self.sub_menu123,
                activebackground="#ececec",
                activeforeground="#000000",
                background="#d9d9d9",
                font="TkMenuFont",
                foreground="#000000",
                label="Inspection(Inv.)")
        self.sub_menu123.add_command(
                activebackground="#ececec",
                activeforeground="#000000",
                background="#d9d9d9",
                font="TkMenuFont",
                foreground="#000000",
                label="Quality inspection", command = quality_inspect)
        self.sub_menu123.add_command(
                activebackground="#ececec",
                activeforeground="#000000",
                background="#d9d9d9",
                font="TkMenuFont",
                foreground="#000000",
                label="Re-shipping", command = reshipping)
        # self.sub_menu123.add_command(
        #         activebackground="#ececec",
        #         activeforeground="#000000",
        #         background="#d9d9d9",
        #         font="TkMenuFont",
        #         foreground="#000000",
        #         label="Safety inventory level")
        self.sub_menu1234 = tk.Menu(top,tearoff=0)
        self.menubar.add_cascade(menu=self.sub_menu1234,
                activebackground="#ececec",
                activeforeground="#000000",
                background="#d9d9d9",
                font="TkMenuFont",
                foreground="#000000",
                label="Interventions")
        self.sub_menu1234.add_command(
                activebackground="#ececec",
                activeforeground="#000000",
                background="#d9d9d9",
                font="TkMenuFont",
                foreground="#000000",
                label="Change request", command = change_request)
        self.sub_menu1234.add_command(
                activebackground="#ececec",
                activeforeground="#000000",
                background="#d9d9d9",
                font="TkMenuFont",
                foreground="#000000",
                label="Material status", command = material_status)

        self.Label_project = tk.Label(top)
        self.Label_project.place(relx=-0.046, rely=-0.033, height=661, width=624)

        self.Label_project.configure(activebackground="#f9f9f9")
        self.Label_project.configure(activeforeground="black")
        self.Label_project.configure(background="#d9d9d9")
        self.Label_project.configure(disabledforeground="#a3a3a3")
        self.Label_project.configure(foreground="#000000")
        self.Label_project.configure(highlightbackground="#d9d9d9")
        self.Label_project.configure(highlightcolor="black")
        self._img1 = ImageTk.PhotoImage(Image.open("project.jpg"))
        self.Label_project.configure(image=self._img1)

        self.Text1 = tk.Text(top)
        self.Text1.place(relx=0.626, rely=0.0, relheight=0.484, relwidth=0.375)
        self.Text1.configure(background="white")
        self.Text1.configure(font="TkTextFont")
        self.Text1.configure(foreground="black")
        self.Text1.configure(highlightbackground="#d9d9d9")
        self.Text1.configure(highlightcolor="black")
        self.Text1.configure(insertbackground="black")
        self.Text1.configure(selectbackground="#c4c4c4")
        self.Text1.configure(selectforeground="black")
        self.Text1.configure(width=324)
        self.Text1.configure(wrap='word')
        self.Text1.insert('end', contents('project data.txt'))

        self.Text2 = tk.Text(top)
        self.Text2.place(relx=0.626, rely=0.511, relheight=0.303, relwidth=0.375)

        self.Text2.configure(background="white")
        self.Text2.configure(font="TkTextFont")
        self.Text2.configure(foreground="black")
        self.Text2.configure(highlightbackground="#d9d9d9")
        self.Text2.configure(highlightcolor="black")
        self.Text2.configure(insertbackground="black")
        self.Text2.configure(selectbackground="#c4c4c4")
        self.Text2.configure(selectforeground="black")
        self.Text2.configure(width=324)
        self.Text2.configure(wrap='word')
        self.Text2.insert('end',contents('project data_milestones.txt'))


        self.Label2 = tk.Label(top)
        self.Label2.place(relx=0.73, rely=0.906, height=31, width=194)
        self.Label2.configure(background="#d9d9d9")
        self.Label2.configure(disabledforeground="#a3a3a3")
        self.Label2.configure(foreground="#000000")
        self.Label2.configure(text='''Label''')
        self.Label2.configure(width=194)
        self.Label2.configure(text='andreasturm.ch', fg='blue', cursor='hand2')
        self.Label2.bind("<Button-1>", callwebsite)





if __name__ == '__main__':
    vp_start_gui()

