#! /usr/bin/env python
#
# Support module generated by PAGE version 4.11f
# In conjunction with Tcl version 8.6
#    Mar 05, 2018 05:50:00 AM

# ======================================================
#              splash1_support.py
# ------------------------------------------------------
# Created for the Learning Page Book Project
# Written by G.D. Walters
# Copyright (c) 2018 by G.D. Walters
# This source code is released under the MIT License
# (See MIT_License.txt)
# ======================================================


# ======================================================
#  Import the support file from your project
# ======================================================
import Main_support  # the name of the support module of your main program.
import sys

try:
    from Tkinter import *
except ImportError:
    from tkinter import *

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


def init(top, gui, *args, **kwargs):
    global w, top_level, root, timerID
    w = gui
    top_level = top
    root = top
    root.overrideredirect(True)  # Hide the 'decorations'
    delay = 1000  # Set a default timer delay
    if len(args) != 0:
        temp = list(args)[0]
        delay = int(temp[0])
        width = int(temp[1])
        height = int(temp[2])
        w.TLabel1.place(relx=0.0, rely=-0.0, height=height, width=width)
        global image1
        image1 = PhotoImage(file=temp[3])
        w.TLabel1.configure(image=image1)
    else:
        # We'll set these just to be safe
        width = 640
        height = 400
        delay = 5000
    centre_screen(width, height)
    timerID = root.after(delay, on_tick)


def centre_screen(w, h):
    ws = root.winfo_screenwidth()
    hs = root.winfo_screenheight()
    x = (ws/2) - (w/2)
    y = (hs/2) - (h/2)
    root.geometry('%dx%d+%d+%d' % (w, h, x, y))


def on_tick():
    # ======================================================
    # Once the 'timer' hits, hide the splash screen
    # ======================================================
    root.withdraw()
    # ======================================================
    #   Call the ShowMe routine in the main support file
    # ======================================================
    Main_support.show_me()


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

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

# ======================================================
# End of Splash1_support.py
# ======================================================
