#! /usr/bin/env python
#  -*- coding: utf-8 -*-
#
# GUI module generated by PAGE version 4.20
#  in conjunction with Tcl version 8.6
#    Jan 27, 2019 11:26:19 PM CET  platform: Linux

import sys

#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

from tkinter import messagebox
from tkinter.filedialog import askopenfilename

import jpk_wb_support

def vp_start_gui():
    '''Starting point when module is the main routine.'''
    global val, w, root
    root = tk.Tk()
    jpk_wb_support.set_Tk_var()
    top = Toplevel1 (root)
    jpk_wb_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)
    jpk_wb_support.set_Tk_var()
    top = Toplevel1 (w)
    jpk_wb_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' 
        self.style = ttk.Style()
        if sys.platform == "win32":
            self.style.theme_use('winnative')
        self.style.configure('.',background=_bgcolor)
        self.style.configure('.',foreground=_fgcolor)
        self.style.configure('.',font="TkDefaultFont")
        self.style.map('.',background=
            [('selected', _compcolor), ('active',_ana2color)])

        # top.geometry("589x307+1835+225")
        top.geometry("589x307")
        top.title("JPK_WB Generator")

        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",
                compound="left",
                font="TkMenuFont",
                foreground="#000000",
                label="Plik")
        self.sub_menu.add_command(
                activebackground="#ececec",
                activeforeground="#000000",
                background="#d9d9d9",
                command=jpk_wb_support.config,
                compound="left",
                font="TkMenuFont",
                foreground="#000000",
                label="Ustawienia")
        self.sub_menu.add_separator(
                background="#d9d9d9")
        self.sub_menu.add_command(
                activebackground="#ececec",
                activeforeground="#000000",
                background="#d9d9d9",
                command=jpk_wb_support.open_mt940,
                compound="left",
                font="TkMenuFont",
                foreground="#000000",
                label="Otwórz plik z ...")
        self.sub_menu.add_separator(
                background="#d9d9d9")
        self.sub_menu.add_command(
                activebackground="#ececec",
                activeforeground="#000000",
                background="#d9d9d9",
                command=jpk_wb_support.quit,
                compound="left",
                font="TkMenuFont",
                foreground="#000000",
                label="Zakończ")
        self.sub_menu1 = tk.Menu(top,tearoff=0)
        self.menubar.add_cascade(menu=self.sub_menu1,
                activebackground="#ececec",
                activeforeground="#000000",
                background="#d9d9d9",
                compound="left",
                font="TkMenuFont",
                foreground="#000000",
                label="Generuj")
        self.sub_menu1.add_command(
                activebackground="#ececec",
                activeforeground="#000000",
                background="#d9d9d9",
                command=jpk_wb_support.generuj,
                compound="left",
                font="TkMenuFont",
                foreground="#000000",
                label="Generuj...",
                state='disabled')

        self.TFrame1 = ttk.Frame(top)
        self.TFrame1.place(relx=0.017, rely=0.0, relheight=0.505, relwidth=0.968)

        self.TFrame1.configure(relief='groove')
        self.TFrame1.configure(borderwidth="2")
        self.TFrame1.configure(relief='groove')
        self.TFrame1.configure(width=565)

        self.mt_file = ttk.Entry(self.TFrame1)
        self.mt_file.place(relx=0.246, rely=0.194, relheight=0.135
                , relwidth=0.411)
        self.mt_file.configure(width=234)
        self.mt_file.configure(takefocus="")
        self.mt_file.configure(cursor="xterm")

        self.label_mt = tk.Label(self.TFrame1)
        self.label_mt.place(relx=0.088, rely=0.194, height=21, width=81)
        self.label_mt.configure(justify='right')
        self.label_mt.configure(text='''Plik MT-940''')

        self.open_mt = ttk.Button(self.TFrame1)
        self.open_mt.place(relx=0.684, rely=0.161, height=28, width=83)
        self.open_mt.configure(command=jpk_wb_support.open_mt940)
        self.open_mt.configure(takefocus="")
        self.open_mt.configure(text='''Otwórz''')

        self.b_Gen = ttk.Button(self.TFrame1)
        self.b_Gen.place(relx=0.439, rely=0.645, height=28, width=83)
        self.b_Gen.configure(command=jpk_wb_support.generuj)
        self.b_Gen.configure(takefocus="")
        self.b_Gen.configure(text='''Generuj''')
        self.b_Gen.configure(state='disabled')

        self.TLabelframe1 = ttk.Labelframe(top)
        self.TLabelframe1.place(relx=0.017, rely=0.489, relheight=0.44
                , relwidth=0.968)
        self.TLabelframe1.configure(relief='')
        self.TLabelframe1.configure(text='''Kominikaty''')
        self.TLabelframe1.configure(width=570)

        self.TProgressbar1 = ttk.Progressbar(self.TLabelframe1)
        self.TProgressbar1.place(relx=0.018, rely=0.815, relwidth=0.958
                , relheight=0.0, height=19, bordermode='ignore')
        self.TProgressbar1.configure(length="530")

        self.Message1 = tk.Message(self.TLabelframe1)
        self.Message1.place(relx=0.035, rely=0.222, relheight=0.407
                , relwidth=0.933, bordermode='ignore')
        self.Message1.configure(background="#f7f7f7")
        self.Message1.configure(borderwidth="2")
        self.Message1.configure(textvariable=jpk_wb_support.msg)
        self.Message1.configure(width=532)

if __name__ == '__main__':
    vp_start_gui()





