Exemple #1
0
 def refresh(self):
     self.currentTable = getAll('patrons')
     stype = None
     direct = 'up'
     for key, value in self.disptable.directions.iteritems():
         if value:
             stype = key
             direct = value
     self.disptable = DisplayTable(self, self.currentTable, sorttype=stype, direction=direct)
     self.currentTable = self.disptable.currentTable
     self.populate(self.currentTable)
     self.getInfoButton.configure(state=tk.DISABLED)
Exemple #2
0
 def refresh(self, new=False):
     if not new:
         try:
             rtnval = self.selected.curselection()
         except AttributeError:
             rtnval = False
         self.deleteButton.configure(state=tk.DISABLED)
         self.getInfoButton.configure(state=tk.DISABLED)
     self.currentTable = getAll('patrons')
     if new:
         rtnval = len(self.currentTable)
         rtnval = [rtnval]
     stype = None
     direct = 'up'
     for key, value in self.disptable.directions.iteritems():
         if value:
             stype = key
             direct = value
     self.disptable = DisplayTable(self, self.currentTable, sorttype=stype, direction=direct)
     self.currentTable = self.disptable.currentTable
     self.populate(self.currentTable)
     if rtnval:
         self.detectSelect(self.selected, rtn=rtnval)
Exemple #3
0
 def resetSearch(self):
     table = getAll('patrons')
     self.searchBox.delete(0, 'end')
     self.disptable = DisplayTable(self, table, sorttype='last', direction='up')
     self.currentTable = self.disptable.currentTable
     self.populate(self.currentTable)
Exemple #4
0
    def __init__(self, parent, *args, **kwargs):
        logTC("Creating MainApp from primaryGUI.py")
        tk.Frame.__init__(self, parent, *args, **kwargs)
        self.parent = parent

        self.selected = 0

        self.currentTable = []

        self.currentSort = "last"

        self.menuBar = tk.Menu(self.parent)
        self.parent.configure(menu=self.menuBar)

        self.fileMenu = tk.Menu(self.menuBar, tearoff=0)
        self.fileMenu.add_command(label='Advanced Search', command=self.execadvsearch)
        self.fileMenu.add_command(label='Exit', command=self.terminate)
        self.menuBar.add_cascade(label='File', menu=self.fileMenu)

        self.toolsMenu = tk.Menu(self.menuBar, tearoff=0)
        self.toolsMenu.add_command(label='Generate Metrics', command=self.genMetrics)
        self.toolsMenu.add_command(label='Reset Configuration File', command=self.resetConfig)
        self.menuBar.add_cascade(label='Tools', menu=self.toolsMenu)

        self.helpMenu = tk.Menu(self.menuBar, tearoff=0)
        self.helpMenu.add_command(label='About', command=self.aboutWindow)
        self.menuBar.add_cascade(label='Help', menu=self.helpMenu)

        self.searchBoxVar = tk.StringVar()
        self.searchBox = tk.Entry(self, textvariable=self.searchBoxVar)
        self.searchBox.grid(column=2, row=1, pady=(20, 0))
        self.searchBox.bind("<KeyRelease>", self.caps)
        self.searchBox.bind("<Return>", self.lookup)

        self.searchButton = tk.Button(self, text="Search", command=self.lookup)
        self.searchButton.grid(column=3, row=1, pady=(20, 0))

        self.exactSearch = tk.IntVar()
        self.exactSearchCheckbox = tk.Checkbutton(self, text="Exact Search", variable=self.exactSearch)
        self.exactSearchCheckbox.grid(column=3, row=2, pady=(0, 20))

        self.resetSearchButton = tk.Button(self, text="Reset Search", command=self.resetSearch)
        self.resetSearchButton.grid(column=4, row=1, pady=(20, 0))

        self.options = ("Last,First", "Municipality", "State")
        self.searchOptionVar = tk.StringVar()
        self.searchOptionVar.set(self.options[0])
        self.searchOption = tk.OptionMenu(self, self.searchOptionVar, *self.options)
        self.searchOption.grid(column=4, row=2, pady=(0, 20))

        self.refreshButton = tk.Button(self, text="Add Record", command=self.addRecord)
        self.refreshButton.grid(column=6, row=1, pady=PADY)

        self.deleteButton = tk.Button(self, text="Delete Record", command=self.deleteRecord)
        self.deleteButton.grid(column=7, row=1, pady=PADY)
        self.deleteButton.configure(state=tk.DISABLED)

        self.getInfoButton = tk.Button(self, text="Display Patron Info", command=self.getInfo)
        self.getInfoButton.grid(column=8, row=1, pady=PADY)
        self.getInfoButton.configure(state=tk.DISABLED)

        self.scrollbar = tk.Scrollbar(self, orient="vertical", command=self.onScroll)
        self.scrollbar.grid(column=9, row=4, sticky='ns')

        self.statusSortID = ''
        self.idLBLabel = tk.Button(self, text='ID ^', command=lambda: self.sort('id'))
        self.idLBLabel.grid(column=1, row=3, padx=(20,0), sticky='we')
        self.idLB = tk.Listbox(self, width=5, bd=0, highlightthickness=0, exportselection=0, yscrollcommand=self.scrollbar.set, height=YSIZE)
        self.idLB.grid(column=1, row=4, padx=(20,0))
        self.idLB.bind('<<ListboxSelect>>', lambda _: self.detectSelect(self.idLB))
        self.idLB.bind("<MouseWheel>", self.onMouseWheel)
        self.idLB.bind("<Double-Button-1>", lambda _: self.getInfo())

        self.statusSortLast = 'up'
        self.lnameLBLabel = tk.Button(self, text='Last', command=lambda: self.sort('last'))
        self.lnameLBLabel.grid(column=2, row=3, sticky='we')
        self.lnameLB = tk.Listbox(self, bd=0, highlightthickness=0, exportselection=0, yscrollcommand=self.scrollbar.set, height=YSIZE)
        self.lnameLB.grid(column=2, row=4)
        self.lnameLB.bind('<<ListboxSelect>>', lambda _: self.detectSelect(self.lnameLB))
        self.lnameLB.bind("<MouseWheel>", self.onMouseWheel)
        self.lnameLB.bind("<Double-Button-1>", lambda _: self.getInfo())

        self.statusSortFirst = ''
        self.fnameLBLabel = tk.Button(self, text='First', command=lambda: self.sort('first'))
        self.fnameLBLabel.grid(column=3, row=3, sticky='we')
        self.fnameLB = tk.Listbox(self, bd=0, highlightthickness=0, exportselection=0, yscrollcommand=self.scrollbar.set, height=YSIZE)
        self.fnameLB.grid(column=3, row=4)
        self.fnameLB.bind('<<ListboxSelect>>', lambda _: self.detectSelect(self.fnameLB))
        self.fnameLB.bind("<MouseWheel>", self.onMouseWheel)
        self.fnameLB.bind("<Double-Button-1>", lambda _: self.getInfo())

        self.statusSortMiddle = ''
        self.mnameLBLabel = tk.Button(self, text='Middle', command=lambda: self.sort('middle'))
        self.mnameLBLabel.grid(column=4, row=3, sticky='we')                                                               
        self.mnameLB = tk.Listbox(self, bd=0, highlightthickness=0, exportselection=0, yscrollcommand=self.scrollbar.set, height=YSIZE)
        self.mnameLB.grid(column=4, row=4)
        self.mnameLB.bind('<<ListboxSelect>>', lambda _: self.detectSelect(self.mnameLB))
        self.mnameLB.bind("<MouseWheel>", self.onMouseWheel)
        self.mnameLB.bind("<Double-Button-1>", lambda _: self.getInfo())

        self.statusSortMuni = ''
        self.muniLBLabel = tk.Button(self, text='Municipality', command=lambda: self.sort('muni'))
        self.muniLBLabel.grid(column=5, row=3, sticky='we') 
        self.muniLB = tk.Listbox(self, bd=0,highlightthickness=0, exportselection=0, yscrollcommand=self.scrollbar.set, height=YSIZE)
        self.muniLB.grid(column=5, row=4)
        self.muniLB.bind('<<ListboxSelect>>', lambda _: self.detectSelect(self.muniLB))
        self.muniLB.bind("<MouseWheel>", self.onMouseWheel)
        self.muniLB.bind("<Double-Button-1>", lambda _: self.getInfo())

        self.statusSortState = ''
        self.stateLBLabel = tk.Button(self, text='State', command=lambda: self.sort('state'))
        self.stateLBLabel.grid(column=6, row=3, sticky='we')
        self.stateLB = tk.Listbox(self, bd=0,highlightthickness=0, exportselection=0, yscrollcommand=self.scrollbar.set, height=YSIZE)
        self.stateLB.grid(column=6, row=4)
        self.stateLB.bind('<<ListboxSelect>>', lambda _: self.detectSelect(self.stateLB))
        self.stateLB.bind("<MouseWheel>", self.onMouseWheel)
        self.stateLB.bind("<Double-Button-1>", lambda _: self.getInfo())

        self.statusSortCards = ''
        self.cardTimesLBLabel = tk.Button(self, text='Cards Issued', command=lambda: self.sort('cards'))
        self.cardTimesLBLabel.grid(column=7, row=3, sticky='we')
        self.cardTimesLB = tk.Listbox(self, bd=0,highlightthickness=0, exportselection=0, yscrollcommand=self.scrollbar.set, height=YSIZE)
        self.cardTimesLB.grid(column=7, row=4)
        self.cardTimesLB.bind('<<ListboxSelect>>', lambda _: self.detectSelect(self.cardTimesLB))
        self.cardTimesLB.bind("<MouseWheel>", self.onMouseWheel)
        self.cardTimesLB.bind("<Double-Button-1>", lambda _: self.getInfo())

        self.statusSortStatus = ''
        self.statusLBLabel = tk.Button(self, text='Status', command=lambda: self.sort('status'))
        self.statusLBLabel.grid(column=8, row=3, sticky='we')
        self.statusLB = tk.Listbox(self, bd=0,highlightthickness=0, exportselection=0, yscrollcommand=self.scrollbar.set, height=YSIZE)
        self.statusLB.grid(column=8, row=4)
        self.statusLB.bind('<<ListboxSelect>>', lambda _: self.detectSelect(self.statusLB))
        self.statusLB.bind("<MouseWheel>", self.onMouseWheel)
        self.statusLB.bind("<Double-Button-1>", lambda _: self.getInfo())
        
        table = getAll('patrons')
        if Config.defaultsort in ('id', 'last', 'first', 'middle', 'muni', 'state', 'cards', 'status'):
            st = Config.defaultsort
        else:
            logTC('Invalid option set in config for defaultsort: \'' + Config.defaultsort + '\'. Using default instead.', 'WARNING')
            st = 'id'
        if Config.defaultsortorder in ('up', 'down'):
            d = Config.defaultsortorder
        else:
            logTC('Invalid option set in config for defaultsortorder: \'' + Config.defaultsortorder + '\'. Using default instead.', 'WARNING')
            d = 'up'
        if not table:
            if not existsTable():
                self.searchButton.configure(state=tk.DISABLED)
                self.resetSearchButton.configure(state=tk.DISABLED)
                self.refreshButton.configure(state=tk.DISABLED)
                self.deleteButton.configure(state=tk.DISABLED)
                self.getInfoButton.configure(state=tk.DISABLED)
                self.idLBLabel.configure(state=tk.DISABLED)
                self.lnameLBLabel.configure(state=tk.DISABLED)
                self.fnameLBLabel.configure(state=tk.DISABLED)
                self.mnameLBLabel.configure(state=tk.DISABLED)
                self.muniLBLabel.configure(state=tk.DISABLED)
                self.stateLBLabel.configure(state=tk.DISABLED)
                self.cardTimesLBLabel.configure(state=tk.DISABLED)
                self.statusLBLabel.configure(state=tk.DISABLED)
                logTC('Table not initialized', 'ERROR')
                e = ErrorWindow(self, "Table not initialized")
            else:
                logTC("Table contains no data", "INFO")

        self.disptable = DisplayTable(self, table, sorttype=st, direction=d)
        self.populate(self.disptable.currentTable, True)
Exemple #5
0
class MainApp(tk.Frame):
    def __init__(self, parent, *args, **kwargs):
        logTC("Creating MainApp from primaryGUI.py")
        tk.Frame.__init__(self, parent, *args, **kwargs)
        self.parent = parent

        self.selected = 0

        self.currentTable = []

        self.currentSort = "last"

        self.menuBar = tk.Menu(self.parent)
        self.parent.configure(menu=self.menuBar)

        self.fileMenu = tk.Menu(self.menuBar, tearoff=0)
        self.fileMenu.add_command(label='Advanced Search', command=self.execadvsearch)
        self.fileMenu.add_command(label='Exit', command=self.terminate)
        self.menuBar.add_cascade(label='File', menu=self.fileMenu)

        self.toolsMenu = tk.Menu(self.menuBar, tearoff=0)
        self.toolsMenu.add_command(label='Generate Metrics', command=self.genMetrics)
        self.toolsMenu.add_command(label='Reset Configuration File', command=self.resetConfig)
        self.menuBar.add_cascade(label='Tools', menu=self.toolsMenu)

        self.helpMenu = tk.Menu(self.menuBar, tearoff=0)
        self.helpMenu.add_command(label='About', command=self.aboutWindow)
        self.menuBar.add_cascade(label='Help', menu=self.helpMenu)

        self.searchBoxVar = tk.StringVar()
        self.searchBox = tk.Entry(self, textvariable=self.searchBoxVar)
        self.searchBox.grid(column=2, row=1, pady=(20, 0))
        self.searchBox.bind("<KeyRelease>", self.caps)
        self.searchBox.bind("<Return>", self.lookup)

        self.searchButton = tk.Button(self, text="Search", command=self.lookup)
        self.searchButton.grid(column=3, row=1, pady=(20, 0))

        self.exactSearch = tk.IntVar()
        self.exactSearchCheckbox = tk.Checkbutton(self, text="Exact Search", variable=self.exactSearch)
        self.exactSearchCheckbox.grid(column=3, row=2, pady=(0, 20))

        self.resetSearchButton = tk.Button(self, text="Reset Search", command=self.resetSearch)
        self.resetSearchButton.grid(column=4, row=1, pady=(20, 0))

        self.options = ("Last,First", "Municipality", "State")
        self.searchOptionVar = tk.StringVar()
        self.searchOptionVar.set(self.options[0])
        self.searchOption = tk.OptionMenu(self, self.searchOptionVar, *self.options)
        self.searchOption.grid(column=4, row=2, pady=(0, 20))

        self.refreshButton = tk.Button(self, text="Add Record", command=self.addRecord)
        self.refreshButton.grid(column=6, row=1, pady=PADY)

        self.deleteButton = tk.Button(self, text="Delete Record", command=self.deleteRecord)
        self.deleteButton.grid(column=7, row=1, pady=PADY)
        self.deleteButton.configure(state=tk.DISABLED)

        self.getInfoButton = tk.Button(self, text="Display Patron Info", command=self.getInfo)
        self.getInfoButton.grid(column=8, row=1, pady=PADY)
        self.getInfoButton.configure(state=tk.DISABLED)

        self.scrollbar = tk.Scrollbar(self, orient="vertical", command=self.onScroll)
        self.scrollbar.grid(column=9, row=4, sticky='ns')

        self.statusSortID = ''
        self.idLBLabel = tk.Button(self, text='ID ^', command=lambda: self.sort('id'))
        self.idLBLabel.grid(column=1, row=3, padx=(20,0), sticky='we')
        self.idLB = tk.Listbox(self, width=5, bd=0, highlightthickness=0, exportselection=0, yscrollcommand=self.scrollbar.set, height=YSIZE)
        self.idLB.grid(column=1, row=4, padx=(20,0))
        self.idLB.bind('<<ListboxSelect>>', lambda _: self.detectSelect(self.idLB))
        self.idLB.bind("<MouseWheel>", self.onMouseWheel)
        self.idLB.bind("<Double-Button-1>", lambda _: self.getInfo())

        self.statusSortLast = 'up'
        self.lnameLBLabel = tk.Button(self, text='Last', command=lambda: self.sort('last'))
        self.lnameLBLabel.grid(column=2, row=3, sticky='we')
        self.lnameLB = tk.Listbox(self, bd=0, highlightthickness=0, exportselection=0, yscrollcommand=self.scrollbar.set, height=YSIZE)
        self.lnameLB.grid(column=2, row=4)
        self.lnameLB.bind('<<ListboxSelect>>', lambda _: self.detectSelect(self.lnameLB))
        self.lnameLB.bind("<MouseWheel>", self.onMouseWheel)
        self.lnameLB.bind("<Double-Button-1>", lambda _: self.getInfo())

        self.statusSortFirst = ''
        self.fnameLBLabel = tk.Button(self, text='First', command=lambda: self.sort('first'))
        self.fnameLBLabel.grid(column=3, row=3, sticky='we')
        self.fnameLB = tk.Listbox(self, bd=0, highlightthickness=0, exportselection=0, yscrollcommand=self.scrollbar.set, height=YSIZE)
        self.fnameLB.grid(column=3, row=4)
        self.fnameLB.bind('<<ListboxSelect>>', lambda _: self.detectSelect(self.fnameLB))
        self.fnameLB.bind("<MouseWheel>", self.onMouseWheel)
        self.fnameLB.bind("<Double-Button-1>", lambda _: self.getInfo())

        self.statusSortMiddle = ''
        self.mnameLBLabel = tk.Button(self, text='Middle', command=lambda: self.sort('middle'))
        self.mnameLBLabel.grid(column=4, row=3, sticky='we')                                                               
        self.mnameLB = tk.Listbox(self, bd=0, highlightthickness=0, exportselection=0, yscrollcommand=self.scrollbar.set, height=YSIZE)
        self.mnameLB.grid(column=4, row=4)
        self.mnameLB.bind('<<ListboxSelect>>', lambda _: self.detectSelect(self.mnameLB))
        self.mnameLB.bind("<MouseWheel>", self.onMouseWheel)
        self.mnameLB.bind("<Double-Button-1>", lambda _: self.getInfo())

        self.statusSortMuni = ''
        self.muniLBLabel = tk.Button(self, text='Municipality', command=lambda: self.sort('muni'))
        self.muniLBLabel.grid(column=5, row=3, sticky='we') 
        self.muniLB = tk.Listbox(self, bd=0,highlightthickness=0, exportselection=0, yscrollcommand=self.scrollbar.set, height=YSIZE)
        self.muniLB.grid(column=5, row=4)
        self.muniLB.bind('<<ListboxSelect>>', lambda _: self.detectSelect(self.muniLB))
        self.muniLB.bind("<MouseWheel>", self.onMouseWheel)
        self.muniLB.bind("<Double-Button-1>", lambda _: self.getInfo())

        self.statusSortState = ''
        self.stateLBLabel = tk.Button(self, text='State', command=lambda: self.sort('state'))
        self.stateLBLabel.grid(column=6, row=3, sticky='we')
        self.stateLB = tk.Listbox(self, bd=0,highlightthickness=0, exportselection=0, yscrollcommand=self.scrollbar.set, height=YSIZE)
        self.stateLB.grid(column=6, row=4)
        self.stateLB.bind('<<ListboxSelect>>', lambda _: self.detectSelect(self.stateLB))
        self.stateLB.bind("<MouseWheel>", self.onMouseWheel)
        self.stateLB.bind("<Double-Button-1>", lambda _: self.getInfo())

        self.statusSortCards = ''
        self.cardTimesLBLabel = tk.Button(self, text='Cards Issued', command=lambda: self.sort('cards'))
        self.cardTimesLBLabel.grid(column=7, row=3, sticky='we')
        self.cardTimesLB = tk.Listbox(self, bd=0,highlightthickness=0, exportselection=0, yscrollcommand=self.scrollbar.set, height=YSIZE)
        self.cardTimesLB.grid(column=7, row=4)
        self.cardTimesLB.bind('<<ListboxSelect>>', lambda _: self.detectSelect(self.cardTimesLB))
        self.cardTimesLB.bind("<MouseWheel>", self.onMouseWheel)
        self.cardTimesLB.bind("<Double-Button-1>", lambda _: self.getInfo())

        self.statusSortStatus = ''
        self.statusLBLabel = tk.Button(self, text='Status', command=lambda: self.sort('status'))
        self.statusLBLabel.grid(column=8, row=3, sticky='we')
        self.statusLB = tk.Listbox(self, bd=0,highlightthickness=0, exportselection=0, yscrollcommand=self.scrollbar.set, height=YSIZE)
        self.statusLB.grid(column=8, row=4)
        self.statusLB.bind('<<ListboxSelect>>', lambda _: self.detectSelect(self.statusLB))
        self.statusLB.bind("<MouseWheel>", self.onMouseWheel)
        self.statusLB.bind("<Double-Button-1>", lambda _: self.getInfo())
        
        table = getAll('patrons')
        if Config.defaultsort in ('id', 'last', 'first', 'middle', 'muni', 'state', 'cards', 'status'):
            st = Config.defaultsort
        else:
            logTC('Invalid option set in config for defaultsort: \'' + Config.defaultsort + '\'. Using default instead.', 'WARNING')
            st = 'id'
        if Config.defaultsortorder in ('up', 'down'):
            d = Config.defaultsortorder
        else:
            logTC('Invalid option set in config for defaultsortorder: \'' + Config.defaultsortorder + '\'. Using default instead.', 'WARNING')
            d = 'up'
        if not table:
            if not existsTable():
                self.searchButton.configure(state=tk.DISABLED)
                self.resetSearchButton.configure(state=tk.DISABLED)
                self.refreshButton.configure(state=tk.DISABLED)
                self.deleteButton.configure(state=tk.DISABLED)
                self.getInfoButton.configure(state=tk.DISABLED)
                self.idLBLabel.configure(state=tk.DISABLED)
                self.lnameLBLabel.configure(state=tk.DISABLED)
                self.fnameLBLabel.configure(state=tk.DISABLED)
                self.mnameLBLabel.configure(state=tk.DISABLED)
                self.muniLBLabel.configure(state=tk.DISABLED)
                self.stateLBLabel.configure(state=tk.DISABLED)
                self.cardTimesLBLabel.configure(state=tk.DISABLED)
                self.statusLBLabel.configure(state=tk.DISABLED)
                logTC('Table not initialized', 'ERROR')
                e = ErrorWindow(self, "Table not initialized")
            else:
                logTC("Table contains no data", "INFO")

        self.disptable = DisplayTable(self, table, sorttype=st, direction=d)
        self.populate(self.disptable.currentTable, True)

    def populate(self, table, first=False):
        if first:
            if not table:
                logTC("Table contains no information")
        if first:
            self.wholeTable = table
        self.currentTable = table
        self.idLB.delete(0, tk.END)
        self.fnameLB.delete(0, tk.END)
        self.mnameLB.delete(0, tk.END)
        self.lnameLB.delete(0, tk.END)
        self.muniLB.delete(0, tk.END)
        self.stateLB.delete(0, tk.END)
        self.cardTimesLB.delete(0, tk.END)
        self.statusLB.delete(0, tk.END)
        if not table:
            pass
        else:
            for record in table:
                self.idLB.insert(tk.END, record[0])
                self.fnameLB.insert(tk.END, record[1])
                self.mnameLB.insert(tk.END, record[2])
                self.lnameLB.insert(tk.END, record[3])
                self.muniLB.insert(tk.END, record[4])
                self.stateLB.insert(tk.END, record[5])
                dates = multiParse(record[6])
                times = len(dates)
                self.cardTimesLB.insert(tk.END, times)
                if not record[7]:
                    self.statusLB.insert(tk.END, ' ')
                else:
                    self.statusLB.insert(tk.END, record[7])

    def detectSelect(self, item, rtn=None):
        if rtn:
            try:
                index = rtn[0]
            except IndexError:
                return -1
        else:
            self.selected = item
            try:
                index = (item.curselection()[0])
            except IndexError:
                return -1
        self.idLB.selection_clear(0, tk.END)
        self.idLB.selection_set(first=index)
        
        self.lnameLB.selection_clear(0, tk.END)
        self.lnameLB.selection_set(first=index)
        
        self.fnameLB.selection_clear(0, tk.END)
        self.fnameLB.selection_set(first=index)
        
        self.mnameLB.selection_clear(0, tk.END)
        self.mnameLB.selection_set(first=index)

        self.muniLB.selection_clear(0, tk.END)
        self.muniLB.selection_set(first=index)

        self.stateLB.selection_clear(0, tk.END)
        self.stateLB.selection_set(first=index)
        
        self.cardTimesLB.selection_clear(0, tk.END)
        self.cardTimesLB.selection_set(first=index)

        self.statusLB.selection_clear(0, tk.END)
        self.statusLB.selection_set(first=index)

        self.deleteButton.configure(state=tk.NORMAL)
        self.getInfoButton.configure(state=tk.NORMAL)

    def lookup(self, *args):
        self.getInfoButton.configure(state=tk.DISABLED)
        sterm = self.searchBoxVar.get()
        option = self.searchOptionVar.get()
        if not sterm:
            logTC("Nothing entered into search box.", "ERROR")
            e = ErrorWindow(self, "Nothing entered into search box.")
            return False
        else:
            if option == 'Last,First':
                sterm = nameVAndF(sterm)
                if not sterm:
                    logTC("Entered name not in correct format.", "ERROR")
                    e = ErrorWindow(self, "Entered name not in correct format.")
                else:
                    if self.exactSearch.get():
                        if not sterm[1]:
                            ln = sterm[0]
                            results = filt('patrons', lname=ln)
                        elif not sterm[0]:
                            fn = sterm[1]
                            results = filt('patrons', fname=fn)
                        else:
                            ln = sterm[0]
                            fn = sterm[1]
                            results = filt('patrons', fname=fn, lname=ln)
                    else:
                        results = getAll('patrons')
                        w_results = []
                        for result in results:
                            rl = 0
                            rf = 0
                            try:
                                rl = difflib.SequenceMatcher(None, result[3], sterm[0]).ratio()
                                rf = difflib.SequenceMatcher(None, result[1], sterm[1]).ratio()
                            except TypeError:
                                pass
                            w_results.append((result, rl + rf))
                        w_results = sorted(w_results, key=lambda x: x[1], reverse=True)
                        results= []
                        for res in w_results:
                            results.append(res[0])
            if option == 'Municipality':
                if self.exactSearch.get():
                    results = filt('patrons', muni=sterm)
                else:
                    results = getAll('patrons')
                    w_results = []
                    for result in results:
                        ratio = difflib.SequenceMatcher(None, result[4], sterm).ratio()
                        w_results.append((result, ratio))
                    w_results = sorted(w_results, key=lambda x: x[1], reverse=True)
                    results = []
                    for res in w_results:
                        results.append(res[0])
            if option == 'State':
                if self.exactSearch.get():
                    results = filt('patrons', state=sterm)
                else:
                    results = getAll('patrons')
                    w_results = []
                    for result in results:
                        ratio = difflib.SequenceMatcher(None, result[5], sterm).ratio()
                        w_results.append((result, ratio))
                    w_results = sorted(w_results, key=lambda x: x[1], reverse=True)
                    results = []
                    for res in w_results:
                        results.append(res[0])
                
            self.populate(results)
            
    def getInfo(self):
        selection = self.selected.curselection()
        idNum = self.idLB.get(selection)
        idNum = (idNum,)
        infoArr = lookupByID(idNum)
        logTC("Passing array to PatronInfo class with the following data:")
        logTC("ID: " + str(infoArr[0]))
        logTC("First Name: " + infoArr[1])
        logTC("Middle Name: " + infoArr[2])
        logTC("Last Name: " + infoArr[3])
        logTC("Municipality: " + infoArr[4])
        logTC("State: " + infoArr[5])
        logTC("Dates: " + str(infoArr[6]))
        logTC("Status: " + str(infoArr[7]))
        logTC("Ban Date: " + str(infoArr[8]))
        logTC("Expiration Date: " + str(infoArr[9]))
        logTC("Barcode: " + str(infoArr[10]))
        try:
            logTC("Reason: " + str(infoArr[11]))
        except UnicodeEncodeError:
            logTC("Improper unicode", "ERROR")
        try:
            logTC("Additional Info: " + str(infoArr[12]))
        except UnicodeEncodeError:
            logTC("Improper unicode", "ERROR")
        patronInfo = PatronInfo(self, infoArr)
                    
    def addRecord(self):
        arWin = ARWin(self)

    def deleteRecord(self):
        selection = self.selected.curselection()
        idNum = self.idLB.get(selection)
        idNum = (idNum,)
        v = VerifyWindow(self, "Are you sure you want to delete this record? This action cannot be undone...", "Confirm Deletion", lambda: deleteRecord('patrons', idNum), geo='450x100')

    def checkButtons(self, displaytable):
        self.getInfoButton.configure(state=tk.DISABLED)
        
        self.idLBLabel.configure(text='ID')
        self.lnameLBLabel.configure(text='Last')
        self.fnameLBLabel.configure(text='First')
        self.mnameLBLabel.configure(text='Middle')
        self.muniLBLabel.configure(text='Municipality')
        self.stateLBLabel.configure(text='State')
        self.cardTimesLBLabel.configure(text='Cards Issued')
        self.statusLBLabel.configure(text='Status')
        if displaytable.directions['id']:
            if displaytable.directions['id'] == 'up':
                self.idLBLabel.configure(text='ID ^')
            else:
                self.idLBLabel.configure(text='ID v')
        if displaytable.directions['last']:
            if displaytable.directions['last'] == 'up':
                self.lnameLBLabel.configure(text='Last ^')
            else:
                self.lnameLBLabel.configure(text='Last v')
        if displaytable.directions['first']:
            if displaytable.directions['first'] == 'up':
                self.fnameLBLabel.configure(text='First ^')
            else:
                self.fnameLBLabel.configure(text='First v')
        if displaytable.directions['middle']:
            if displaytable.directions['middle'] == 'up':
                self.mnameLBLabel.configure(text='Middle ^')
            else:
                self.mnameLBLabel.configure(text='Middle v')
        if displaytable.directions['muni']:
            if displaytable.directions['muni'] == 'up':
                self.muniLBLabel.configure(text='Municipality ^')
            else:
                self.muniLBLabel.configure(text='Municipality v')
        if displaytable.directions['state']:
            if displaytable.directions['state'] == 'up':
                self.stateLBLabel.configure(text='State ^')
            else:
                self.stateLBLabel.configure(text='State v')
        if displaytable.directions['cards']:
            if displaytable.directions['cards'] == 'up':
                self.cardTimesLBLabel.configure(text='Cards Issued ^')
            else:
                self.cardTimesLBLabel.configure(text='Cards Issued v')
        if displaytable.directions['status']:
            if displaytable.directions['status'] == 'up':
                self.statusLBLabel.configure(text='Status ^')
            else:
                self.statusLBLabel.configure(text='Status v')

    def sort(self, by):
        if self.disptable.directions[by]:
            self.disptable.revdir(by)
            self.disptable.sort(by, self.disptable.directions[by])
        else:
            self.disptable.sort(by, 'up')
        self.populate(self.disptable.currentTable)

    def genMetrics(self, *args):
        mWindow = MetricsWindow(self)

    def onScroll(self, *args):
        self.idLB.yview(*args)
        self.fnameLB.yview(*args)
        self.mnameLB.yview(*args)
        self.lnameLB.yview(*args)
        self.muniLB.yview(*args)
        self.stateLB.yview(*args)
        self.cardTimesLB.yview(*args)
        self.statusLB.yview(*args)

    def onMouseWheel(self, event):
        self.idLB.yview("scroll", -event.delta,"units")
        self.fnameLB.yview("scroll", -event.delta,"units")
        self.mnameLB.yview("scroll", -event.delta,"units")
        self.lnameLB.yview("scroll", -event.delta,"units")
        self.muniLB.yview("scroll", -event.delta,"units")
        self.stateLB.yview("scroll", -event.delta,"units")
        self.cardTimesLB.yview("scroll", -event.delta,"units")
        self.statusLB.yview("scroll", -event.delta,"units")
        return "break"

    def refresh(self, new=False):
        if not new:
            try:
                rtnval = self.selected.curselection()
            except AttributeError:
                rtnval = False
            self.deleteButton.configure(state=tk.DISABLED)
            self.getInfoButton.configure(state=tk.DISABLED)
        self.currentTable = getAll('patrons')
        if new:
            rtnval = len(self.currentTable)
            rtnval = [rtnval]
        stype = None
        direct = 'up'
        for key, value in self.disptable.directions.iteritems():
            if value:
                stype = key
                direct = value
        self.disptable = DisplayTable(self, self.currentTable, sorttype=stype, direction=direct)
        self.currentTable = self.disptable.currentTable
        self.populate(self.currentTable)
        if rtnval:
            self.detectSelect(self.selected, rtn=rtnval)

    def execadvsearch(self, *args):
        advsrch = AdvSearchWin(self)
        #advsrch = DWindow(self, "This functionality is not yet available.", "Sorry!", "Ok")

    def caps(self, *args):
        self.searchBoxVar.set(self.searchBoxVar.get().upper())

    def aboutWindow(self):
        a = AWindow(self)

    def resetSearch(self):
        table = getAll('patrons')
        self.searchBox.delete(0, 'end')
        self.disptable = DisplayTable(self, table, sorttype='last', direction='up')
        self.currentTable = self.disptable.currentTable
        self.populate(self.currentTable)

    def resetConfig(self):
        rcw = RCWindow(self)
            
    def terminate(self):
        logTC("Destroying MainApp from primaryGUI.py")
        logTC("Shutting down...")
        self.destroy()
        exit()