#! /usr/bin/env python
#  -*- coding: utf-8 -*-
#
# GUI module generated by PAGE version 4.26
#  in conjunction with Tcl version 8.6
#    Apr 21, 2020 12:46:45 PM +0300  platform: Windows NT


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 tomupload_support
from tkinter import filedialog as fd

return_values = False
entry_values = []


def vp_start_gui(first_time=False):
    '''Starting point when module is the main routine.'''
    global val, w, root
    global return_values
    global entry_values
    entry_values = []
    return_values = False
    root = tk.Tk()
    top = Toplevel1(root)
    tomupload_support.init(root, top)
    # Keep gui alive by updating while user didn't select
    while not return_values:
        try:
            root.update()
        except:
            return
    if first_time:
        root.destroy()
    else:
        root.destroy()
    print('OUT')
    # Var reset
    return_values = False
    # Return back
    return entry_values[0]


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)
    tomupload_support.init(w, top, *args, **kwargs)
    return (w, top)


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


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("600x296+370+153")
        top.minsize(120, 1)
        top.maxsize(1364, 749)
        top.resizable(1, 1)
        top.title("Filecloud")
        top.configure(background="#0A3252")
        top.configure(highlightbackground="#d9d9d9")
        top.configure(highlightcolor="black")

        self.Label1 = tk.Label(top)
        self.Label1.place(relx=0.033, rely=0.0, height=71, width=544)
        self.Label1.configure(activebackground="#2d3436")
        self.Label1.configure(activeforeground="white")
        self.Label1.configure(activeforeground="#2d3436")
        self.Label1.configure(background="#0A3252")
        self.Label1.configure(disabledforeground="#a3a3a3")
        self.Label1.configure(font="-family {Bahnschrift Light} -size 48")
        self.Label1.configure(foreground="#ffffff")
        self.Label1.configure(highlightbackground="#d9d9d9")
        self.Label1.configure(highlightcolor="black")
        self.Label1.configure(text='''Upload to the cloud''')

        self.Button1_1 = tk.Button(top)
        self.Button1_1.place(relx=0.333, rely=0.709, height=54, width=187)
        self.Button1_1.configure(activebackground="#ececec")
        self.Button1_1.configure(activeforeground="#000000")
        self.Button1_1.configure(background="#34D03C")
        self.Button1_1.configure(disabledforeground="#a3a3a3")
        self.Button1_1.configure(font="-family {Verdana} -size 24")
        self.Button1_1.configure(foreground="#ffffff")
        self.Button1_1.configure(highlightbackground="#d9d9d9")
        self.Button1_1.configure(highlightcolor="black")
        self.Button1_1.configure(overrelief="flat")
        self.Button1_1.configure(pady="0")
        self.Button1_1.configure(relief="flat")
        self.Button1_1.configure(text='''UPLOAD''')
        self.Button1_1.configure(command=lambda:pass_back_path(self.Entry1))

        self.Label2 = tk.Label(top)
        self.Label2.place(relx=0.15, rely=0.338, height=31, width=434)
        self.Label2.configure(activebackground="#f9f9f9")
        self.Label2.configure(activeforeground="black")
        self.Label2.configure(background="#0A3252")
        self.Label2.configure(disabledforeground="#a3a3a3")
        self.Label2.configure(font="-family {System} -size 10 -weight bold")
        self.Label2.configure(foreground="#ffffff")
        self.Label2.configure(highlightbackground="#d9d9d9")
        self.Label2.configure(highlightcolor="black")
        self.Label2.configure(text='''Please select the path to the fie you would like you upload''')

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

        self.Entry1 = tk.Entry(top)
        self.Entry1.place(relx=0.067, rely=0.507,height=40, relwidth=0.64)
        self.Entry1.configure(background="#125b98")
        self.Entry1.configure(disabledforeground="#a3a3a3")
        self.Entry1.configure(font="TkFixedFont")
        self.Entry1.configure(foreground="#000000")
        self.Entry1.configure(highlightbackground="#d9d9d9")
        self.Entry1.configure(highlightcolor="black")
        self.Entry1.configure(insertbackground="black")
        self.Entry1.configure(relief="groove")
        self.Entry1.configure(selectbackground="#c4c4c4")
        self.Entry1.configure(selectforeground="black")
        self.Entry1.configure(fg="white")

        self.Button1_2 = tk.Button(top)
        self.Button1_2.place(relx=0.733, rely=0.5, height=44, width=107)
        self.Button1_2.configure(activebackground="#ececec")
        self.Button1_2.configure(activeforeground="#000000")
        self.Button1_2.configure(background="#11568e")
        self.Button1_2.configure(disabledforeground="#a3a3a3")
        self.Button1_2.configure(font="-family {Verdana} -size 14")
        self.Button1_2.configure(foreground="#ffffff")
        self.Button1_2.configure(highlightbackground="#d9d9d9")
        self.Button1_2.configure(highlightcolor="black")
        self.Button1_2.configure(overrelief="flat")
        self.Button1_2.configure(pady="0")
        self.Button1_2.configure(relief="flat")
        self.Button1_2.configure(text='''BROWSE''')
        self.Button1_2.configure(command=lambda: get_browser(self.Entry1))


# TODO CHANGE FILETYPES IF YOU WANT TO INCLUD VIDS AND OTHER FILES
def get_browser(entry):
    # Launch file explorer window
    file_browse_path = fd.askopenfilename(initialdir=r"C:\Users",)
    entry.delete(0, "end")
    entry.insert(0, file_browse_path)


def pass_back_path(entry):
    # Take the selection from a list and pass it back through another list
    global entry_values
    global return_values
    print("TEST")
    entry_values.append(entry.get())
    return_values = True


if __name__ == '__main__':
    vp_start_gui()
