
import tkinter as tk
from tkinter import ttk
from os import startfile
from tkinter import messagebox
from employeeindex import search_from_db_employee, search_from_db_employee_name
from toolsIndex import search_from_db_tool
import toolsIndex
import employeeindex
import out_and_in_tools
import missing_tools
import total_inventory


# todo back up list for missing file
# todo created list for permanent out tools
# todo autogenerated missing list.
# todo update location and replace labels
# todo format printing pages


class SearchByName:

    def __init__(self, root, outside_field):
        self.outside_field = outside_field

        # basic configuration
        self.manual_gui = tk.Toplevel()
        self.manual_gui.title('IBK Inventory')
        self.manual_gui.configure(background="#00012f")
        self.manual_gui.geometry("480x200")

        # layout of all the Frames
        self.frame1 = tk.Frame(self.manual_gui, bg='#00012f')
        self.frame2 = tk.Frame(self.manual_gui, bg='#00012f')
        self.frame3 = tk.Frame(self.manual_gui, bg='#00012f')

        self.frame1.grid(row=0, sticky='ew')
        self.frame2.grid(row=1, sticky='ew')
        self.frame3.grid(row=2, sticky='e')

        # first row label and title
        self.image = tk.PhotoImage(file='IBKLogo.gif')
        tk.Label(self.frame1, image=self.image, bg='#00012f').grid(row=0, column=0, sticky='wens')
        tk.Label(self.frame1, text="Manual Input", bg='#00012f', fg='white', font="none 14 bold").grid(row=0, column=1, sticky='wens')

        # Second row input information
        self.lb_code = tk.Label(self.frame1, text="Introduce Code", bg='#00012f', fg='white', font="none 14 bold")
        self.entry_code = ttk.Entry(self.frame1, font="none 14 bold")
        self.button_save = ttk.Button(self.frame1, text="Search", command=self.search_by)

        self.lb_code.grid(row=1, column=0, sticky='wesn')
        self.entry_code.grid(row=1, column=1, sticky='wesn')
        self.button_save.grid(row=1, column=2, sticky='wens')

        #  row 3
        # working
        self.lb_location = tk.Label(self.frame1, text=" ", bg='#00012f', fg='white', font="none 14 bold")
        self.lb_location.grid(row=2, column=1, sticky='ew')

        #  row 4 button
        self.button_save = ttk.Button(self.frame1, text="Enter", command=self.enter_button)
        self.button_save.grid(row=3, column=1)
        self.manual_gui.bind('<Return>', self.enter_button)

        self.manual_gui.mainloop()
        self.outside_field = outside_field

    def search_by(self):
        code = self.entry_code.get()
        results = employeeindex.search_by_card_number(code)
        try:
            name_to = '{}  -  {}'.format(results[0][0], results[0][2])
            self.lb_location.configure(text=name_to)
        except IndexError:
            self.lb_location.configure(text="Match Not Found")

    def enter_button(self, event=None):
        code = self.entry_code.get()
        results = employeeindex.search_by_card_number(code)
        try:
            name_to = '{}'.format(results[0][0])
            print(name_to)
            self.outside_field.insert(0.0, '-{}-\n'.format(name_to))
            self.lb_location.configure(text=name_to)
            self.entry_code.delete(0, tk.END)
        except IndexError:
            self.lb_location.configure(text="Match Not Found")


class UpdateGui:

    def __init__(self, root):
        # basic configuration
        self.update_gui = tk.Toplevel()
        self.update_gui.title('IBK Inventory')
        self.update_gui.configure(background="#00012f")
        self.update_gui.geometry("650x200")
        self.update_gui.resizable(False, False)

        # layout of all the Frames
        self.frame1 = tk.Frame(self.update_gui)

        # first row label and title
        self.frame1.grid(row=0, sticky='ew')
        self.image = tk.PhotoImage(file='IBKLogo.gif')
        tk.Label(self.frame1, image=self.image, bg='#00012f').grid(row=0, column=0, sticky='we', ipadx=30)
        tk.Label(self.frame1,
                 text="Choose How to Update",
                 bg='#00012f', fg='white', font="none 14 bold").grid(row=0, column=1, sticky='ns', ipadx=88)

        # Second row input information
        self.width_d = 12
        self.lb_code = tk.Label(self.frame1, text="Introduce Code", bg='#00012f', fg='white', font="none 14 bold")
        self.entry_code = ttk.Entry(self.frame1, width=self.width_d)

        self.lb_code.grid(row=1, column=0,sticky='wesn')
        self.entry_code.grid(row=1, column=1, sticky='wesn')

        #  row 3
        # working

        self.width_d = 12
        self.lb_location = tk.Label(self.frame1, text="Location", bg='#00012f', fg='white', font="none 14 bold")
        self.entry_location = ttk.Entry(self.frame1, width=self.width_d)

        self.lb_location.grid(row=2, column=0, sticky='wesn')
        self.entry_location.grid(row=2, column=1, sticky='wesn')

        # row 4
        self.frame2 = tk.Frame(self.update_gui)
        self.frame2.grid(row=7, column=0, sticky='e')

        self.button_save = ttk.Button(self.frame2, text='save', width=15, command=self.update_location)
        self.button_save.grid(row=0, column=1, sticky='nse')

        self.update_gui.mainloop()

    def update_location(self):

        pass


class NewUserGui:

    def __init__(self, root):
        # basic configuration
        self.new_user = tk.Toplevel()
        self.new_user.title('IBK Inventory')
        self.new_user.configure(background="#00012f")
        self.new_user.geometry("650x200")
        self.entry_width = 45
        self.label_width = 15

        #  frame 1 title and logo  ################################################################################
        self.frame1 = tk.Frame(self.new_user)
        self.frame1.grid(row=0, column=0, sticky='w')

        self.image = tk.PhotoImage(file='IBKLogo.gif')
        tk.Label(self.frame1,
                 image=self.image,
                 bg='#00012f').grid(row=0, column=0, sticky='we', ipadx=50)
        tk.Label(self.frame1,
                 text="New User",
                 bg='#00012f',
                 fg='white',
                 font="none 14 bold").grid(row=0, column=1, sticky='ns', ipadx=88)

        #  frame 2 introduction of code to be in data base  ########################################################
        self.frame2 = tk.Frame(self.new_user)
        self.frame2.grid(row=1, column=0, sticky='w')

        self.intro_code = tk.Label(self.frame2,
                                   text="Introduce Code",
                                   bg='#00012f',
                                   fg='white',
                                   font="none 10 bold",
                                   width=self.label_width)
        self.entry1 = ttk.Entry(self.frame2,
                                font='none 14 bold',
                                width=self.entry_width)

        self.entry1.grid(row=0, column=1, sticky='ns')
        self.intro_code.grid(row=0, column=0, sticky='ns')

        # row 3 instruction of name to be save in database  #########################################################
        self.frame3 = tk.Frame(self.new_user)
        self.frame3.grid(row=2, column=0, sticky='w')

        self.name_label = tk.Label(self.frame3,
                                   text="Name",
                                   bg='#00012f',
                                   fg='white',
                                   font="none 10 bold",
                                   width=self.label_width)
        self.name = ttk.Entry(self.frame3,
                              font='none 14 bold',
                              width=self.entry_width)

        self.name.grid(row=0, column=1, sticky='ns')
        self.name_label.grid(row=0, column=0, sticky='ns')

        # row 4 instruction of Card Number to be save in database  #########################################################
        self.frame4 = tk.Frame(self.new_user)
        self.frame4.grid(row=3, column=0, sticky='w')

        self.card_number_label = tk.Label(self.frame4,
                                   text="Card Number",
                                   bg='#00012f',
                                   fg='white',
                                   font="none 10 bold",
                                   width=self.label_width)
        self.number_card = ttk.Entry(self.frame4,
                              font='none 14 bold',
                              width=self.entry_width)

        self.number_card.grid(row=0, column=1, sticky='ns')
        self.card_number_label.grid(row=0, column=0, sticky='ns')

        # row 4  save button  #######################################################################################
        self.frame4 = tk.Frame(self.new_user)

        self.frame4.grid(row=7, column=0, sticky='e')
        self.button_save = ttk.Button(self.frame4, text='save', width=15, command=self.click)
        self.button_save.grid(row=0, column=1, sticky='nse')

        self.new_user.mainloop()

    def click(self):
        code = self.entry1.get()
        user_name = self.name.get()
        card_number = self.number_card.get()

        print("{}   {}   {}".format(user_name, code, card_number))

        employeeindex.dynamic_data_entry(user_name, code, card_number)
        self.entry1.delete(0, tk.END)
        self.name.delete(0, tk.END)
        self.number_card.delete(0, tk.END)


class GuiNewTool:

    def __init__(self, root):

        self.new_tool = tk.Toplevel()
        self.new_tool.title('IBK Inventory')
        self.new_tool.configure(background="#00012f")
        self.new_tool.geometry("650x300")
        self.entry_width = 45
        self.label_width = 15

        #  frame 1 title and logo
        self.image = tk.PhotoImage(file='IBKLogo.gif')

        self.frame1 = tk.Frame(self.new_tool)
        self.frame1.grid(row=0, column=0, sticky='w')

        self.label0 = tk.Label(self.frame1, image=self.image, bg='#00012f')
        self.label0.grid(row=0, column=0, sticky='we', ipadx=50)

        self.label01 = tk.Label(self.frame1, text="NEW TOOL", bg='#00012f', fg='white', font="none 12 bold")
        self.label01.grid(row=0, column=1, sticky='ns', ipadx=88)

        # frame 2 first entry  IBK CODE
        self.frame2 = tk.Frame(self.new_tool)
        self.frame2.grid(row=1, column=0, sticky='w')

        self.label2 = tk.Label(self.frame2, text="Introduce Code", bg='#00012f', fg='white', font="none 10 bold", width=self.label_width)
        self.label2.grid(row=0, column=0, sticky='ns')

        self.ibk_code = ttk.Entry(self.frame2, font='none 14 bold', width=self.entry_width)
        self.ibk_code.grid(row=0, column=1, sticky='ns')

        # frame 3  entry  TypeTool
        self.frame3 = tk.Frame(self.new_tool)
        self.frame3.grid(row=2, column=0, sticky='w')

        self.label3 = tk.Label(self.frame3, text="Type of tool", bg='#00012f', fg='white', font="none 10 bold", width=self.label_width)
        self.label3.grid(row=0, column=0, sticky='ns')

        self.typeTool = ttk.Entry(self.frame3, font='none 14 bold', width=self.entry_width)
        self.typeTool.grid(row=0, column=1, sticky='ns')

        # frame 4  brand
        self.frame4 = tk.Frame(self.new_tool)
        self.frame4.grid(row=3, column=0, sticky='w')

        self.label4 = tk.Label(self.frame4, text="Brand", bg='#00012f', fg='white', font="none 10 bold", width=self.label_width)
        self.label4.grid(row=0, column=0, sticky='ns')

        self.brand = ttk.Entry(self.frame4, font='none 14 bold', width=self.entry_width)
        self.brand.grid(row=0, column=1, sticky='ns')

        # frame 5  description
        self.frame5 = tk.Frame(self.new_tool)
        self.frame5.grid(row=4, column=0, sticky='w')

        self.label5 = tk.Label(self.frame5, text="Description", bg='#00012f', fg='white', font="none 10 bold", width=self.label_width)
        self.label5.grid(row=0, column=0, sticky='ns')

        self.description = ttk.Entry(self.frame5, font='none 14 bold', width=self.entry_width)
        self.description.grid(row=0, column=1, sticky='ns')

        # frame 6  serial
        self.frame6 = tk.Frame(self.new_tool)
        self.frame6.grid(row=5, column=0, sticky='w')

        self.label6 = tk.Label(self.frame6, text="Serial", bg='#00012f', fg='white', font="none 10 bold", width=self.label_width)
        self.label6.grid(row=0, column=0, sticky='ns')

        self.serial = ttk.Entry(self.frame6, font='none 14 bold',width=self.entry_width)
        self.serial.grid(row=0, column=1, sticky='ns')

        # frame 7  job_site
        self.frame7 = tk.Frame(self.new_tool)
        self.frame7.grid(row=6, column=0, sticky='w')

        self.label7 = tk.Label(self.frame7,text="Current Job-site", bg='#00012f', fg='white', font="none 10 bold",width=self.label_width)
        self.label7.grid(row=0, column=0, sticky='ns')

        self.job_site = ttk.Entry(self.frame7, font='none 14 bold',width=self.entry_width)
        self.job_site.grid(row=0, column=1, sticky='ns')

        # frame 8  job_site
        self.frame8 = tk.Frame(self.new_tool)
        self.frame8.grid(row=7, column=0, sticky='e')
        self.saveButton = ttk.Button(self.frame8, text='save', width=15, command=self.click)
        self.saveButton.grid(row=0, column=1, sticky='nse')

        self.new_tool.mainloop()

    def click(self):
        code = self.ibk_code.get()
        typetool = self.typeTool.get()
        brand1 = self.brand.get()
        description1 = self.description.get()
        serial1 = self.serial.get()
        jobsite1 = self.job_site.get()

        print("{} - {} - {} - {} - {}".format(code, typetool, brand1, description1, serial1))

        '''to send the data to dynamic_data_entry this are the field require
        ibkIndex, typeTool, brand, description, serial, job_site'''

        toolsIndex.dynamic_data_entry(code, typetool, brand1, description1, serial1, jobsite1)

        # this is to clear all the boxes after the data is input into the database
        self.ibk_code.delete(0, tk.END)
        self.typeTool.delete(0, tk.END)
        self.brand.delete(0, tk.END)
        self.description.delete(0, tk.END)
        self.serial.delete(0, tk.END)
        self.job_site.delete(0, tk.END)


class MainWindow:

    def __init__(self, root):

        # basic configuration
        self.tk = tk
        self.root = root
        self.root.title('IBK Inventory')
        self.root.configure(background="#00012f")
        self.root.geometry("1008x688")
        self.root.resizable(False, False)

        self.var = tk.IntVar()
        self.var.set(1)

        # layout setup
        self.frame1 = tk.Frame(root)
        self.frame2 = tk.Frame(root, bg='#00012f')
        self.frame3 = tk.Frame(root)
        self.frame4 = tk.Frame(root, bg='#00012f')

        self.frame1.grid(row=0, sticky='ew')
        self.frame2.grid(row=1, sticky='we')
        self.frame3.grid(row=2, sticky='we')
        self.frame4.grid(row=3, sticky='we')

        #  first row  #####################################################################################
        #  logo introduction and selection of button for in and out

        self.image = tk.PhotoImage(file='IBKLogo.gif')
        self.lb_logo = self.tk.Label(self.frame1, image=self.image, bg='#00012f')
        self.lb_tools = self.tk.Label(self.frame1, text="Tools Inventory", bg='#00012f', fg='white', font="none 17 bold")

        self.radio_button1 = ttk.Radiobutton(self.frame1,  # selection out
                                             text='OUT',
                                             value=1,
                                             variable=self.var,
                                             command=self.clean_field_radiobuttons)
        self.radio_button2 = ttk.Radiobutton(self.frame1,  # selection return
                                             text='Return',
                                             value=2,
                                             variable=self.var,
                                             command=self.clean_field_radiobuttons)
        self.radio_button3 = ttk.Radiobutton(self.frame1,  # selection missing
                                             text='Missing (today)',
                                             value=3,
                                             variable=self.var,
                                             command=self.clean_field_radiobuttons)

        self.lb_logo.grid(row=0, column=0, sticky='we', ipadx=40)  # logo placement
        self.lb_tools.grid(row=0, column=1, sticky='ns', ipadx=190)
        self.radio_button1.grid(row=0, column=2, sticky='nse', ipadx=18)  # selection out
        self.radio_button2.grid(row=0, column=3, sticky='nse', ipadx=18)  # selection return
        self.radio_button3.grid(row=0, column=4, sticky='nse', ipadx=18)  # selection missing

        # second row ###################################################################################

        self.lb_code = self.tk.Label(self.frame2, text="Introduce Code", bg='#00012f', fg='white', font="none 10 bold")
        self.textentry = ttk.Entry(self.frame2, font='none 20 bold', width=36)
        self.enter_button = ttk.Button(self.frame2, text='Enter', width=5, command=self.get_info)
        self.reports_bt = ttk.Button(self.frame2, text='Report', width=5, command=self.reports)
        self.save_bt = ttk.Button(self.frame2, text='Save', width=21, command=self.saving_info)

        self.root.bind('<Return>', self.get_info)
        self.root.bind('<space>', self.saving_info)
        self.root.bind('<Left>', self.radio_button_key_left)  # help to select 
        self.root.bind('<Right>', self.radio_button_key_right)

        self.lb_code.grid(row=0, column=0, sticky='ns', ipadx=30, ipady=10)
        self.textentry.grid(row=0, column=1, padx=10, pady=10)
        self.enter_button.grid(row=0, column=2, sticky='nse', ipadx=10)
        self.reports_bt.grid(row=0, column=4, sticky='nse', ipadx=10)
        self.save_bt.grid(row=0, column=3, sticky='nse', ipadx=12)

        # third row  ##################################################################################
        # Display information area

        self.output = tk.Text(self.frame3, width=107, height=25, background='white', font='none 12 bold')
        self.S = ttk.Scrollbar(self.frame3, command=self.output.yview, orient="vertical")
        self.S.config(command=self.output.yview)
        self.output.configure(yscrollcommand=self.S.set)

        self.output.grid(row=0, column=0, ipadx=10, ipady=10, sticky='wens')
        self.S.grid(row=0, column=2, sticky='nswe')

        # row 4  #######################################################################################
        # enter field for the codes

        width_size = 41

        self.manual_input = ttk.Button(self.frame4,
                                      text='Manual Input',
                                      width=width_size,
                                      command=self.manual_input_gui)

        self.edit_button = ttk.Button(self.frame4,
                                      text='Edit Entry',
                                      width=width_size,
                                      command=self.open_edit)

        self.new_tool_bt = ttk.Button(self.frame4,
                                      text='New Tool',
                                      width=width_size,
                                      command=self.new_tool_gui)

        self.new_user_bt = ttk.Button(self.frame4,
                                      text='New User',
                                      width=width_size,
                                      command=self.new_employee_gui)

        self.total_tool_bt = ttk.Button(self.frame4,
                                          text='Total Missing tools',
                                          width=width_size,
                                          command=self.total_missing)

        self.total_inventory_bt = ttk.Button(self.frame4,
                                             text='Total Inventory',
                                             width=width_size,
                                             command=self.total_inventory_tools)

        self.print_bt = ttk.Button(self.frame4,
                                   text='Print',
                                   width=width_size,
                                   command=self.print_from_outbox)
        self.size_button = 7
        self.manual_input.grid(row=0, column=1, sticky='nsew', ipady=self.size_button)
        self.new_tool_bt.grid(row=0, column=2, sticky='nsew', ipady=self.size_button)
        self.total_tool_bt.grid(row=0, column=4, sticky='nsew', ipady=self.size_button,rowspan = 2)
        self.total_inventory_bt.grid(row=0, column=6, sticky='nsew', ipady=self.size_button)
        self.edit_button.grid(row=1, column=1, sticky='nsew', ipady=self.size_button,)
        self.new_user_bt.grid(row=1, column=2, sticky='nsew', ipady=self.size_button,)
        self.print_bt.grid(row=1, column=6, sticky='nsew', ipady=self.size_button)

    def manual_input_gui(self):
        SearchByName(root, self.output)   # this send the output in to the class searchbyname so it can be modify

    def new_employee_gui(self):
        NewUserGui(root)

    def new_tool_gui(self):
        GuiNewTool(root)

    def get_name_for_tool(self, text):
        #  after build the whole application i decide that i need it to print the name of the tool and description
        #  on this application. so i decide to created this application to do this
        c = search_from_db_tool(text)
        try:
            return c
        except:
            pass

    def report_picker(self):
        #  this evaluate which list is active at the moment and choose which function activated.
        table_chooser = self.selection_data()
        if table_chooser == 1:
            data = out_and_in_tools.read_out_report()
            return data
        elif table_chooser == 2:
            data = out_and_in_tools.read_out_return()
            return data
        else:

            def name_last_employee(code, timestamp):
                return out_and_in_tools.name_of_last_employee_with_tools(timestamp, code)

            self.output.delete("1.0", tk.END)
            data = missing_tools.missing_tools_current()

            for item in data:
                print(item)
                item_name = self.get_name_for_tool(item[0])
                name_employee = name_last_employee(item[0], item[1])
                self.output.insert(0.0, '{:10} - {}  -  {}  -  {}  -  {}  -  {}\n'.format(item[0],
                                                                                          item[1],
                                                                                          name_employee[0],
                                                                                          item_name[1],
                                                                                          item_name[2],
                                                                                          item_name[3],
                                                                                          ))

    def clean_field_radiobuttons(self):
        # clean the text entry and output box when we switch between active list.
        self.textentry.delete(0, tk.END)
        self.output.delete("1.0", tk.END)
        self.textentry.focus_set()

    def get_info(self, event=None):
            self.textentry.focus_set()
            text = self.textentry.get()
            text = text.strip()
            p = search_from_db_employee(text)
            c = search_from_db_tool(text)

            if p is not None:
                self.output.insert(0.0, '-{}-\n'.format(p[0]))
                self.textentry.delete(0, self.tk.END)
            elif c is not None:
                self.output.insert(0.0, ' -{}-{}-\n'.format(c[0], c[1]))
                self.textentry.delete(0, self.tk.END)
            else:
                messagebox.showerror('No found', "we don't find that code in the system please add it.")

    def radio_button_key_left(self, event = None):
        self.radio_button1.invoke()#  activated Out Radiobutton

    def radio_button_key_right(self, event = None):
        self.radio_button2.invoke() #  activated return radiobutton

    def reports(self):
        self.output.delete("1.0", tk.END)
        self.textentry.focus_set()
        data = self.report_picker()
        print(data)
        try:
            for item in data:
                fullname = self.get_name_for_tool(item[1])
                try:
                    self.output.insert(0.0, '{:10} - {:30}  -  {}  -  {}  -  {}  -  {}\n'.format(item[1],
                                                                                           item[2][:-7],
                                                                                              item[0],
                                                                                              fullname[1],
                                                                                              fullname[2],
                                                                                              fullname[3]))
                except:
                    pass
        except TypeError:
            pass
        finally:
            self.textentry.focus_set()

    def saving_info(self,event=None):

        table_chooser = self.selection_data()
        data = self.output.get("1.0", tk.END)

        c = data.split("-")  # the data giving to me is pretty messy i have to separated
        if table_chooser == 1:
            for names in c:
                x = search_from_db_employee_name(names)
                if x is not None and len(x[0]) >= 4:
                    print('{} for {}'.format(len(x[0]), x[0]))
                    for item in c:
                        v = search_from_db_tool(item)
                        if v is not None and len(v[0]) >= 5 :
                            print('{} for {}'.format(len(v[0]),v[0]))
                            out_and_in_tools.tools_out_entry(x[0], v[0])
                            self.output.delete("1.0", self.tk.END)

        elif table_chooser == 2:
            for item in c:
                v = search_from_db_tool(item)
                if v is not None:

                    out_and_in_tools.tools_return_entry_no_id(v[0])
                    self.output.delete("1.0", self.tk.END)

        elif table_chooser == 3:
            for item in c:
                v = search_from_db_tool(item)
                if v is not None:
                    self.output.delete("1.0", self.tk.END)
                    missing_tools.delete_from_missing(str(v[0]))
                    self.output.insert(0.0, 'We Erase {}'.format(v))

        self.textentry.focus_set()

    def close_window(self):
        self.root.destroy()

    def open_edit(self):
        startfile('database.db')

    def total_missing(self):

        def name_last_employee(code, timestamp):
            return out_and_in_tools.name_of_last_employee_with_tools(timestamp, code)
        self.output.delete("1.0", tk.END)
        data = missing_tools.missing_tools_total()

        try:
            for item in data:
                print(item)
                item_name = self.get_name_for_tool(item[0])
                name_employee =name_last_employee(item[0], item[1])
                try:
                    self.output.insert(0.0, '{} - {}  -  {}  -  {}  -  {}  -  {}\n'.format(item[0],
                                                                                            item[1],
                                                                                            name_employee[0],
                                                                                            item_name[1],
                                                                                            item_name[2],
                                                                                            item_name[3],
                                                                                            ))
                except:
                    pass
        except:
            tk.messagebox.showerror("Information Missing", 'some information is missing from the data base')

    def total_inventory_tools(self):
        self.output.delete("1.0", tk.END)
        p = total_inventory.total_inventory_count()
        for key in p:
            self.output.insert(0.0, "{:-10} -- {}\n".format(p[key], key))

    def print_from_outbox(self):
        data = self.output.get("1.0", self.tk.END)
        with open('printing_text.txt', 'w') as filetoprint:
            filetoprint.write(data)
        startfile('printing_text.txt', 'print')
        self.output.insert(0.0, "\nOK, It was send to the default printer \n")

    def selection_data(self):
        self.selection = self.var.get()
        return self.selection


if __name__ == '__main__':
    root = tk.Tk()
    mygui = MainWindow(root)
    root.mainloop()
