Пример #1
0
def main():  # método principal, chama outros métodos e os instancia
    root = Tk()
    #root.geometry("700x500+500+500") # define os parâmetros de lagura, altura e comprimento da janela
    app = Example(root)

    # trocar o uso do Frame pelo Canvas
    frame = Frame(
        root, width=700, height=500
    )  # nesse caso, o tamanho do frame sobre o root é do msm tamanho do root
    frame.bind(centerWindow)  # tentativa de chamada do metodo centerWindow
    frame.bind("<Button-1>", callback)
    frame.pack()

    root.mainloop()
Пример #2
0
class ScrollableFrame(Frame):

    def __init__(self, root):
        Frame.__init__(self, root)
        self.canvas = ResizingCanvas(self, borderwidth=0)
        self.frame = Frame(self.canvas)
        self.vsb = Scrollbar(
            self, orient="vertical", command=self.canvas.yview)
        self.canvas.configure(yscrollcommand=self.vsb.set)
        self.vsb.pack(side="right", fill="y")
        self.canvas.pack(side="left", fill="both", expand=True)
        self.canvas.create_window(
            (4, 4), window=self.frame, anchor="nw", tags="self.frame")
        self.frame.bind("<Configure>", self.OnFrameConfigure)

    def OnFrameConfigure(self, event):
        '''Reset the scroll region to encompass the inner frame'''
        # print "OnFrameConfigure"
        self.canvas.configure(scrollregion=self.canvas.bbox("all"))
Пример #3
0
class ScrollableFrame(Frame):

    def __init__(self, root):
        Frame.__init__(self, root)
        self.canvas = ResizingCanvas(self, borderwidth=0)
        self.frame = Frame(self.canvas)
        self.vsb = Scrollbar(
            self, orient="vertical", command=self.canvas.yview)
        self.canvas.configure(yscrollcommand=self.vsb.set)
        self.vsb.pack(side="right", fill="y")
        self.canvas.pack(side="left", fill="both", expand=True)
        self.canvas.create_window(
            (4, 4), window=self.frame, anchor="nw", tags="self.frame")
        self.frame.bind("<Configure>", self.OnFrameConfigure)

    def OnFrameConfigure(self, event):
        '''Reset the scroll region to encompass the inner frame'''
        # print "OnFrameConfigure"
        self.canvas.configure(scrollregion=self.canvas.bbox("all"))
Пример #4
0
class mainframe(Frame):

    def __init__(self, parent):
        Frame.__init__(self, parent)
        self.filenm=None
        self.streamnm = None
        self.pack(fill=BOTH, expand=1)
        self.parent = parent
        self.initplayer()
        self.player_process = None
        self.seekthread = None
        self.fstate = False
        self.paused = True
        self.trackmouse = True
        self.stdout_thread = None
        self.stream = False
        self.inhibit_slider_trigger = False
        self.q = LifoQueue()
        self.currtime = 0
        self.endtime = -1

    def initplayer(self):
        self.parentframe = Frame(self)
        self.parentframe.pack(fill=BOTH, expand=True)
        self.videoFrame = Frame(self.parentframe, width=800, height=480)
        self.videoFrame.pack(side="top", fill="both", expand=True)
        self.buttonframe = Frame(self.parentframe, padding="2 2 1 1")
        self.buttonframe.pack(side="bottom", fill="x", expand=False)

        self.seekbar = Scale(self.buttonframe, from_= 0, to=100, orient=HORIZONTAL)
        self.seekbar.grid(column=0, columnspan=4, row=0, sticky=[N, E, S, W])
        self.seekbar.configure(command=self.seeked)

        self.selectbutton = Button(self.buttonframe, text="Select File")
        self.selectbutton.grid(column=0, row=1, sticky=[E,W])
        self.streambutton = Button(self.buttonframe, text="Open HTTP", command=self.streamopen)
        self.streambutton.grid(column=1, row=1, sticky=[E,W])
        self.playbutton = Button(self.buttonframe, text="Play")
        self.playbutton.config(command=self.playpause)
        self.playbutton.grid(column=2, row=1, sticky=[E,W])
        self.fullscreenbutton = Button(self.buttonframe, text="Fullscreen", command=self.togglefullscreen)
        self.fullscreenbutton.grid(column=3, row=1, sticky=[E,W])
        for child in self.buttonframe.winfo_children(): child.grid_configure(padx=5, pady=5)
        self.buttonframe.rowconfigure(0, weight=1)
        self.buttonframe.rowconfigure(1, weight=1)
        self.buttonframe.columnconfigure(0, weight=1)
        self.buttonframe.columnconfigure(1, weight=1)
        self.buttonframe.columnconfigure(2, weight=1)
        self.buttonframe.columnconfigure(3, weight=1)

        self.selectbutton.configure(command=self.fileopen)
        self.videoFrame.bind("<Button-1>",self.playpause)
        self.parent.bind("<F11>", self.togglefullscreen)
        self.parent.bind("<Motion>",self.mouseops)

    def mouseops(self,event=None):
        self.videoFrame.config(cursor="")
        self.videoFrame.after(5000,self.cursorhandler)
        if self.trackmouse:
            x, y = self.parent.winfo_pointerx(), self.parent.winfo_pointery()
            windowx, windowy = self.parent.winfo_width(), self.parent.winfo_height()
            if windowy - 30 <= y:
                if self.fstate:
                    self.buttonframe.pack(side="bottom", fill="x", expand=False)
                    self.trackmouse = False
                    self.parent.after(5000, self.mousetracker)
                self.inhibit_slider_trigger = False
            elif self.fstate:
                self.buttonframe.pack_forget()
                self.inhibit_slider_trigger = True
            else:
                self.inhibit_slider_trigger = True

    def mousetracker(self):
        print 'Mouse Tracker'
        self.trackmouse = True
        self.videoFrame.after(0,self.mouseops)

    def cursorhandler(self):
        self.videoFrame.config(cursor="none")

    def togglefullscreen(self, event=None):
        self.fstate = not self.fstate
        self.parent.attributes("-fullscreen",self.fstate)
        if self.fstate:
            self.fullscreenbutton.config(text="Exit Fullscreen")
            self.buttonframe.pack_forget()
            self.videoFrame.config(cursor="none")
        else:
            self.fullscreenbutton.config(text="Fullscreen")
            self.buttonframe.pack(side="bottom", fill="x", expand=False)
            self.videoFrame.after(5000, self.cursorhandler)

    def fileopen(self):
        self.filenm = askopenfilename(filetypes=[("Supported Files","*.mp4;*.mkv;*.mpg;*.avi;*.mov"),("All Files","*.*")])
        self.stream = False
        self.play()

    def streamopen(self):
        self.streamnm = Dlog(self.parent)
        if self.streamnm.result is not None:
            s = str(self.streamnm)
        else:
            return
        if s.startswith('http'):
            self.stream = True
            self.play()
        else:
            self.stream = False
            showerror("Error","Incorrect Entry")

    def play(self):
        global fifofilename
        if self.filenm is not None and self.filenm != "":
            winid = self.videoFrame.winfo_id()
            if self.mplayer_isrunning():
                self.stop()
            try:
                self.paused = False
                self.playbutton.configure(text="Pause")
                if not self.stream:
                    self.player_process = Popen(["mplayer","-fs","-slave","-quiet","-wid",str(winid),self.filenm],stdin=PIPE, stdout=PIPE)
                else:
                    self.player_process = Popen(["mplayer","-fs","-slave","-quiet","-wid",str(winid),self.streamnm], stdin=PIPE, stdout=PIPE)
                self.stdout_thread = Thread(target=self.enqueue_pipe, args=(self.player_process.stdout, self.q))
                self.stdout_thread.daemon = True
                self.stdout_thread.start()
                self.emptypipe()
                self.seekthread = Thread(target=self.seekbar_setup, args=())
                self.seekthread.daemon = True
                self.seekthread.start()
            except:
                showerror("Error","".join(["Couldn't play video:\n",str(sys.exc_info()[:])]))

    def getvidtime(self):
        if self.mplayer_isrunning():
            self.command_player("get_time_length")
            output = self.readpipe()
            while "ANS_LENGTH" not in output:
                output = self.readpipe()
            if "ANS_LENGTH" in output:
                return output.split('ANS_LENGTH=')[1]
            else:
                return 0

    def playpause(self, event=None):
        if self.player_process is None:
            return
        self.paused = not self.paused
        if self.paused:
            print "VIDEO IS PAUSED /B/RO"
            self.playbutton.configure(text="Play")
        else:
            self.playbutton.configure(text="Pause")
        self.command_player("pause")

    def setwh(self,w,h):
        self.videoFrame.configure(width=w, height=h)

    def quit(self):
        print "QUIT CALLED"
        self.destroy()

    def mplayer_isrunning(self):
        if self.player_process is not None:
            return (self.player_process.poll() is None)
        else:
            return False

    def command_player(self, comd):
        global fifofilename
        if self.mplayer_isrunning():
            try:
                self.player_process.stdin.flush()
                self.player_process.stdin.write("\r\n%s\r\n"%comd)
                # for _ in itertools.repeat(None,8192):
                #     self.player_process.stdin.write("\n")
                self.player_process.stdin.flush()
            except:
                showerror("Error","Error passing command to mplayer\n%s"%sys.exc_info()[1])

    def enqueue_pipe(self, out, q):
        print 'Working on reading mplayer pipe output...'
        for line in iter(out.readline, b''):
            q.put(line)
        out.close()

    def seekbar_setup(self):
        pos = '0'
        trial = 0
        while float(pos)<1:
            trial += 1
            pos = self.getvidtime()
        self.seekbar.config(to=int(float(pos)))
        self.endtime = int(float(pos))
        Timer(1, self.seekbar_updater).start()

    def seekbar_updater(self):
        if not self.paused and self.inhibit_slider_trigger:
            self.currtime += 1
            self.seekbar.set(self.currtime)
        else:
            self.currtime = self.seekbar.get()
        Timer(1, self.seekbar_updater).start()

    def seeked(self,e):
        pos = self.seekbar.get()
        print "We changed pos to :%d"% pos

        x, y = self.parent.winfo_pointerx(), self.parent.winfo_pointery()
        windowx, windowy = self.parent.winfo_width(), self.parent.winfo_height()
        if not self.inhibit_slider_trigger and windowy - 30 <= y:
            self.command_player("seek %d 2"%pos)
            if self.paused:
                self.command_player("pause")

    def startmousetrack(self):
        self.trackmouse = True

    def readpipe(self):
        line = ""
        try:
            line = self.q.get_nowait()
        except Empty:
            print "Empty PIPE"
        finally:
            return line

    def emptypipe(self):
        str = ''
        try:
            while not self.q.empty():
                str += self.q.get_nowait()
        except Empty:
            print "Empty Pipe"
        finally:
            return str

    def stop(self):
        if self.mplayer_isrunning():
            self.player_process.stdin.write("quit\n")
            self.player_process.stdin.flush()
            print self.emptypipe()
        self.player_process = None
Пример #5
0
    def setCard(self,cardnum,row,col):
        dodel = False
        if cardnum == -1:
            dodel = True
            cardnum = 1
        card = Card(cardnum)
        f = Frame(self, height = card.height, width = card.width)
        if (row == 2 and self.client.player == 'p1') or (row == 3 and self.client.player == 'p2'):
            f.config(height = card.height+20)
        if self.client.player == 'p1':
            f.grid(row=row+1, column=col)
        else:
            f.grid(row=6-row, column=NUM_COLS-col)
        f.pack_propagate(0)

        self.fgrid[row][col] = f
        
        pic = Label(f)
        if row <= 2:
            card.flip()
        if self.client.player == 'p2':
            card.flip()
        pic.config(image=card.img)
        pic.image = card.img
        pic.row = row
        pic.col = col
        pic.card = card
        
        def clicked(pic,ins,card):
            if ins.state == 'taking' and not pic.isNone:
                if pic.card.number == ins.activeCard:
                    endTime = time.time()
                    ins.delta = round(endTime-self.startTime,2)
                    print(ins.delta)
                    print("Got in "+str(ins.delta))
                    ins.client.sendMessage('took,'+str(ins.delta)+','+str(ins.faultCount))
                    if not ins.multiplayer:
                        ins.client.oppSendMessage('p2,took,20,0')
                    ins.changeState('waiting')

                    pic.pack_forget()
                    ins.model[pic.row][pic.col].isNone = True
                elif ins.activeCardRow == -1 or not (pic.row <= 2) == (ins.activeCardRow <= 2):
                    ins.faults[int(pic.row <= 2)] = 1
                    ins.faultCount = sum(ins.faults)
            elif ins.state == 'move-select-start':
                ins.movingPic = (pic.row, pic.col)
                print('moving card:')
                print(ins.movingPic)
                if (((self.client.player == 'p1' and pic.row > 2) or (self.client.player == 'p2' and pic.row <= 2))\
                    and not pic.isNone) or not ins.multiplayer:
                    ins.infoLabel.config(text="Card chosen. Select destination.")
                    ins.changeState('move-select-stop')

                else:
                    ins.infoLabel.config(text="Can't move that. Select a different card to move.")
                ins.moveButton.config(text="Cancel")

            elif ins.state == 'move-select-stop':
                print('to:')
                print((pic.row, pic.col))
                if ((self.client.player == 'p1' and pic.row <= 2) or (self.client.player == 'p2' and pic.row > 2))\
                    and not pic.isNone:
                    ins.infoLabel.config(text="Illegal move. Select a different card to move.")
                else:
                    ins.swapCards(self.movingPic,(pic.row, pic.col))
                    ins.infoLabel.config(text="Move completed. Select next card.")

                ins.changeState('move-select-start')




        
        f.bind("<Button-1>",lambda e,pic=pic,self=self,card=card:clicked(pic,self,card))
        pic.bind("<Button-1>",lambda e,pic=pic,self=self,card=card:clicked(pic,self,card))
        pic.pack(fill=BOTH)
        self.model[row][col] = pic

        if dodel:
            pic.pack_forget()
            self.model[row][col].isNone = True

        else:
            self.model[row][col].isNone = False
Пример #6
0
class Scan:
    bg_color = "#E9E9E9"

    def __init__(self, parent, receipt):
        self.curr_upc = ""
        self.receipt = receipt

        self.title = "Scan"
        self.root = Frame(parent)
        self.prompt = "Scan Item to Add\n it to Your Cart"
        self.label = tk.Label(self.root,
                              text=self.prompt,
                              font=("Helvetica", 26),
                              anchor=tk.CENTER,
                              bg=Scan.bg_color,
                              pady=170)
        self.text = tk.Text(self.root,
                            height=1,
                            width=1,
                            fg=Scan.bg_color,
                            bg=Scan.bg_color,
                            highlightcolor=Scan.bg_color,
                            insertbackground=Scan.bg_color)
        self.text.bind("<Key>", self.create_upc)
        self.text.bind("<Return>", self.callback)
        self.root.bind("<Visibility>", self.on_visibility)
        self.text.focus_set()
        self.text.pack()
        self.label.pack()

    def get_root(self):
        return self.root

    def get_title(self):
        return self.title

    def on_visibility(self, event):
        self.text.focus_set()

    def create_upc(self, event):
        self.curr_upc += event.char
        print self.curr_upc

    def callback(self, event):
        self.scan(self.curr_upc)
        self.curr_upc = ""

    # @param: upc is an identifier number that matches a specific item in the database
    def scan(self, upc):

        data = self.get_data(upc)

        description = data["description"]
        nutrients = data["formattedNutrition"]
        # curr_img_url = data["thumbnail"]

        print "Description: ", description
        print nutrients
        print "---------"

        #servings in item
        servings = 1
        # if "Servings Per Container" in nutrients: servings = float(nutrients["Servings Per Container"]["qty"])

        # pull out desired nutrients to be sent to receipt
        desired_nutrients = [
            "Total Fat", "Saturated Fat", "Cholesterol", "Sodium",
            "Total carbohydrates", "Dietary Fiber"
        ]
        nutrients_amounts = dict()
        for key in nutrients.keys():
            if key in desired_nutrients:
                #splits quantity on numeric value
                qty = (re.findall(r'\d+|\D+', str(nutrients[key]["qty"]))[0])
                if qty == "None":
                    qty = 0
                else:
                    qty = float(qty)
                nutrients_amounts[key] = qty * servings

                # dv = str(nutrients[key]["dv"])
                # newdv = dv.replace("%", "")
                # nutrients_amounts[key] = [qty, dv]

        # still need pricing data
        # add new item to receipt with description, price, nutrients
        self.receipt.add_item(description, 3.99, nutrients_amounts)

        # image_byt = urllib2.urlopen(curr_img_url).read()
        # image_b64 = base64.encodestring(image_byt)
        # photo = tk.PhotoImage(data=image_b64)
        # self.label = tk.Label(self.root, image=photo, text=self.prompt, font=("Helvetica", 26),anchor=tk.CENTER, bg=Scan.bg_color, pady=170)
        # self.label.image = photo
        # self.label.pack()

    def get_data(self, upc):
        print "UPC:", upc
        if upc is "":
            return

        # api_key = "/7LZow+CLrFl" #[email protected]
        api_key = "/waE+F/WTEgU"
        # api_key = "/5L6JpJVLpCI"

        # user_key = "Gk93Y4w4e5Fl6Pe4" #[email protected]
        user_key = "Zj16I9n3c5Ry1Hl5"  #[email protected]
        # user_key = "Eb58I1n1j7Xj0By2"

        #create hashed signature based on user key
        m = hmac.new(user_key, upc, hashlib.sha1)
        signature = base64.b64encode(m.digest())

        url = "http://digit-eyes.com/gtin/v2_0/?upc_code=" + upc + "&app_key=" + api_key + "&signature=" + signature + "&language=en&field_names=description,brand,formattedNutrition,image,thumbnail"
        data = json.load(urllib2.urlopen(url))

        return data
Пример #7
0
class App(Frame):
    # Constructor
    def __init__(self, parent):
        Frame.__init__(self, parent)

        self.pack(fill=BOTH, expand=True)
        # run the initial formatting on the data folder
        analyzePigeons(defaultThreshold, path)

        print "\nTips for using the GUI of this program can be found in the supplied \
README file. Tooltips are also available upon hovering over any \
element within the GUI.\n\n"

        self.createComponents()

    # function for creating the select all and de-select button frames
    def createButtons(self, frame, vals, text):
        # create canvas for select all and deselect all buttons
        canv = Canvas(frame, width=220, height=10)
        canv.create_line(20, 10, 220, 10, dash=(2, 4))
        canv.pack(fill=X)

        # create each button separately
        selectAll = Button(frame,
                           text="Select All",
                           command=lambda: self.allButtons(vals, "Select"))
        selectAll.pack()
        selectTrialToolTip = ToolTip(selectAll,
                                     delay=toolTipDelay,
                                     text="Select all " + text +
                                     " for analysis.")
        deselectAll = Button(
            frame,
            text="De-Select All",
            command=lambda: self.allButtons(vals, "De-Select"))
        deselectAll.pack()
        deselectTrialToolTip = ToolTip(deselectAll,
                                       delay=toolTipDelay,
                                       text="Deselect all " + text +
                                       " marked for analysis.")

        return (selectAll, deselectAll)

    # Callback for select all and de-select all buttons
    def allButtons(self, buttonGroup, event):
        for buttonNum in range(len(buttonGroup)):
            if event == "Select":
                buttonGroup[buttonNum].set(1)
            else:
                buttonGroup[buttonNum].set(0)

    # Output the desired analyses
    def run(self):
        trialsForOutput = self.getGroups(self.trialVals, "trials")
        animalsForOutput = self.getGroups(self.animalVals, "animals")
        if ((trialsForOutput != []) and (animalsForOutput != [])):
            outputFrames = self.analyzeGroups(trialsForOutput,
                                              animalsForOutput)

            # get the output name for saving the excel file
            todaysDate = time.strftime("%Y-%m-%d")
            initialFileName = todaysDate + '-' + '-'.join(
                trialsForOutput) + ".xls"
            chosenName = tkFileDialog.asksaveasfilename(
                initialdir=dirname, initialfile=initialFileName)
            chosenName = chosenName.replace('/', sep)
            if (chosenName != dirname + sep + initialFileName) and (
                    ".xls" not in chosenName):
                chosenName = chosenName + ".xls"

            try:
                # create excelwriter object for outputting to excel
                writer = pd.ExcelWriter(chosenName)
                # create the excel writer object
                for frameIndex in outputFrames:
                    outputFrames[frameIndex].to_excel(writer,
                                                      sheet_name=frameIndex)
            except:
                tkMessageBox.showinfo(
                    "Saving cancelled", "No output file name \
was selected. Saving operation cancelled.")

            try:
                writer.save()
                print "Saving output of chosen groups and pigeons to ", chosenName
            except:
                tkMessageBox.showinfo(
                    "Saving cancelled", "Sorry there as an \
issue writing to the designated excel file. Check to make sure it is not \
currently in use. Saving operation cancelled.")
        elif (trialsForOutput == [] and animalsForOutput == []):
            tkMessageBox.showinfo("Nothing selected",
                                  "Please select something to analyze.")
        elif (trialsForOutput == []):
            tkMessageBox.showinfo(
                "No groups selected",
                "Please select at least one grouping to analyze.")
        elif (animalsForOutput == []):
            tkMessageBox.showinfo(
                "No birds selected",
                "Please select at least one bird to analyze.")

    def checkReformat(self, thresholdBox,
                      reset):  # re-run if threshold has been changed
        value = float(thresholdBox.get())

        try:
            if (value == defaultThreshold):
                print "Threshold has not changed from default"
                return
            if (reset == True):
                thresholdBox.delete(0, END)
                thresholdBox.insert(0, defaultThreshold)
                value = defaultThreshold

            analyzePigeons(value, path)
        except:
            tkMessageBox.showinfo("Not a number",
                                  "Please enter a valid number.")
            thresholdBox.delete(0, END)
            thresholdBox.insert(0, defaultThreshold)

    def scrollFunc(self, event):
        self.animalCanvas.configure(scrollregion=self.animalCanvas.bbox("all"))

    # Create all of the buttons and components of the GUI
    def createComponents(self):
        # Create text fonts for components
        self.titleFont = tkFont.Font(family="Arial", size=18)
        self.componentFont = tkFont.Font(family="Helvetica", size=16)

        # Create a frame for the title section
        # ======================================================================
        titleFrame = Frame(self)
        titleFrame.pack(fill=X)

        # Create the title label
        title_label = Label(titleFrame,
                            text="Data Processor For Pigeon Experiment",
                            font=self.titleFont)
        title_label.pack(fill=X, expand=True)
        title_labelTooltip = ToolTip(
            title_label,
            delay=toolTipDelay + 500,
            text="This program was created by Chris Cadonic for use \
                    in the laboratory of Dr. Debbie Kelly.")

        # Create a canvas for drawing a separation line
        canv = Canvas(titleFrame, width=840, height=10)
        canv.create_line(0, 10, 840, 10)
        canv.pack(fill=X, anchor=CENTER, expand=True)

        # Create a frame for the bottom section
        # ======================================================================
        footerFrame = Frame(self)
        footerFrame.pack(anchor=S, expand=True, side=BOTTOM)

        # Create a run button
        runButton = Button(footerFrame,
                           width=200,
                           text="Run Processing",
                           command=self.run)
        runButton.pack(fill=Y)
        runToolTip = ToolTip(
            runButton,
            delay=toolTipDelay,
            text="Run analysis based on the groups and animals\
                    selected above.")

        # Create and populate group and trial button frames
        # ======================================================================
        trialFrame = Frame(self)
        trialFrame.pack(expand=True, anchor=W, side=LEFT)

        # Create a checkbox for each test group
        self.trialLabels = [
            "Non-reinforced training", "Control 1", "Control 2",
            "Feature Only", "Geometry Only", "Affine"
        ]
        self.trialKeys = ["Nrtr", "C1", "C2", "FO", "GO", "AF"]
        self.trialTooltips = [
            "Non-reinforced training group.", "Control group 1",
            "Control group 2", "Group where an extra wall and a \
feature wall are placed in the environment to create an enclosed square.",
            "Group where the feature wall is removed, but the geometry of the environment \
remains the same.", "Group where the feature wall is moved to the end of the \
long wall."
        ]
        self.trialVals = []

        # create all of the group buttons
        for num in range(len(self.trialLabels)):
            self.trialVals.append(IntVar())
            trialButtons.append(
                Checkbutton(trialFrame,
                            text=self.trialLabels[num],
                            variable=self.trialVals[num],
                            font=self.componentFont))
            trialButtons[-1].pack(pady=8)
            trialButtonTooltips.append(
                ToolTip(trialButtons[-1],
                        delay=toolTipDelay,
                        text=self.trialTooltips[num]))

        # create select/deselect all buttons
        self.createButtons(trialFrame, self.trialVals, "experimental phases")

        # Create a frame for handling all of the birds
        # ======================================================================
        animalsFrame = Frame(self, width=100, height=360)
        animalsFrame.pack(expand=True, anchor=CENTER, side=RIGHT)

        self.animalCanvas = Canvas(animalsFrame,
                                   width=100,
                                   height=360,
                                   scrollregion=(0, 0, 500, 1000))
        self.newFrame = Frame(self.animalCanvas, width=100, height=360)
        self.animalScrollbar = Scrollbar(animalsFrame,
                                         orient="vertical",
                                         command=self.animalCanvas.yview)
        self.animalCanvas.configure(yscrollcommand=self.animalScrollbar.set)

        self.animalScrollbar.pack(side="right", fill="y")
        self.animalCanvas.pack(side="top")
        self.animalCanvas.create_window((0, 0),
                                        window=self.newFrame,
                                        anchor='nw')
        self.newFrame.bind("<Configure>", self.scrollFunc)

        self.animals = list(allData.keys())

        self.animalVals = []

        # Create a button for each bird in the data directory
        for bird in range(len(self.animals)):
            self.animalVals.append(IntVar())
            animalButtons.append(
                Checkbutton(self.newFrame,
                            text=self.animals[bird],
                            variable=self.animalVals[bird],
                            font=self.componentFont))
            self.animalVals[-1].set(1)
            animalButtons[-1].pack(pady=6)
        # create select/deselect all buttons
        self.createButtons(animalsFrame, self.animalVals, "animals")

        # Create a frame for handling all of the additional buttons
        # ======================================================================
        buttonsFrame = Frame(self)
        buttonsFrame.pack(fill=X, expand=True)

        # Threshold label
        thresholdLabel = Label(buttonsFrame, text="Change threshold: ")

        # Threshold entry box
        thresholdBox = Entry(buttonsFrame, width=10)
        thresholdBox.pack()
        thresholdBox.insert(0, defaultThreshold)
        thresholdBoxTooltip = ToolTip(
            thresholdBox,
            delay=toolTipDelay,
            text="Change this value to set a new threshold value \
for calculating the max distance away from a goal to be kept for data analysis."
        )

        # Re-analyze with new thresholdBox
        reformatButton = Button(
            buttonsFrame,
            text="Apply new threshold",
            command=lambda: self.checkReformat(thresholdBox, False))
        reformatButton.pack()
        reformatTooltip = ToolTip(
            reformatButton,
            delay=toolTipDelay,
            text="Click to apply any changes to threshold box above.")

        # Reset threshold to defaultThreshold
        resetButton = Button(
            buttonsFrame,
            text="Reset threshold and run",
            command=lambda: self.checkReformat(thresholdBox, True))
        resetButton.pack()
        resetButtonTooltip = ToolTip(
            resetButton,
            delay=toolTipDelay,
            text="Click to reset threshold to default value.")

        # Create a sort button
        self.sortOutput = IntVar()
        sortButton = Checkbutton(buttonsFrame,
                                 text="Sort",
                                 variable=self.sortOutput,
                                 font=self.componentFont)
        sortButton.pack()
        sortTooltip = ToolTip(
            sortButton,
            delay=toolTipDelay,
            text="Select to auto-sort the output excel spreadsheets by \
trial type.")

        # Create a quit button
        quitButton = Button(buttonsFrame, text="Quit", command=self.quit)
        quitButton.pack()
        quitToolTip = ToolTip(quitButton,
                              delay=toolTipDelay,
                              text="Quit the program and close the GUI.")

    def create_window(self):
        self.counter += 1
        t = Toplevel(self)
        t.wm_title("Window #%s" % self.counter)
        l = Label(t, text="This is window #%s" % self.counter)
        l.pack(side="top", fill="both", expand=True, padx=100, pady=100)

    # function for determining which groups/animals will be analyzed
    def getGroups(self, buttons, groupType):
        groupsForOutput = []
        if (groupType == "animals"):
            keys = self.animals
        else:
            keys = self.trialKeys

        # check which buttons are selected
        for buttonNum in buttons:
            if buttonNum.get():
                indexOfButton = buttons.index(buttonNum)
                groupsForOutput.append(keys[indexOfButton])
        return groupsForOutput

    # function for parsing dataframe based on groups
    def analyzeGroups(self, trials, animals):
        outputFrames = {}
        columns = [
            "Pigeon Name", "Trial Type", "Removed Pecks", "Average Dist"
        ]
        goColumns = list(columns)
        goColumns[-1] = "Average Opp Dist"
        AFColumns = list(goColumns)
        AFColumns.extend(["Average AF Dist"])
        '''if X and Y coordinates option selected
            columns = columns.append(["X Dist", "Y Dist"])'''

        for trial in trials:
            trialFrame = pd.DataFrame({})  # storage frame for each trial
            gotrialFrame = pd.DataFrame({})
            AFtrialFrame = pd.DataFrame({})
            # loop over each pigeon and acquire data matching requested trials
            for pigeon in animals:
                tempFrame = pd.DataFrame({})
                pigeonFrame = allData[pigeon]

                if (trial == "GO"):
                    goFrame = self.getFrame(pigeonFrame, goColumns, trial)
                    gotrialFrame = gotrialFrame.append(goFrame)
                elif (trial == "AF"):
                    goFrame = self.getFrame(pigeonFrame, goColumns, trial)
                    gotrialFrame = gotrialFrame.append(goFrame)
                    AFFrame = self.getFrame(pigeonFrame, AFColumns, trial)
                    AFtrialFrame = AFtrialFrame.append(AFFrame)

                tempFrame = self.getFrame(pigeonFrame, columns, trial)
                trialFrame = trialFrame.append(
                    tempFrame)  # add this pigeon to trial frame

            # sort by group and store in list of dataframes if selected to
            if (self.sortOutput == 1):
                if (trial == "GO"):
                    outputFrames["GO-Opp Distance"] = gotrialFrame.sort(
                        ["Trial Type", "Pigeon Name"])
                elif (trial == "AF"):
                    outputFrames["AF-Opp Distance"] = gotrialFrame.sort(
                        ["Trial Type", "Pigeon Name"])
                    outputFrames["AF-AF Distance"] = AFtrialFrame.sort(
                        ["Trial Type", "Pigeon Name"])
                outputFrames[trial] = trialFrame.sort(
                    ["Trial Type", "Pigeon Name"])
            else:
                if (trial == "GO"):
                    outputFrames["GO-Opp Distance"] = gotrialFrame
                elif (trial == "AF"):
                    outputFrames["AF-Opp Distance"] = gotrialFrame
                    outputFrames["AF-AF Distance"] = AFtrialFrame
                outputFrames[trial] = trialFrame

        return outputFrames

    # function to also create a processed dataframe for each pigeon/trial
    def getFrame(self, pigeonFrame, columns, trial):
        tempFrame = pigeonFrame.loc[pigeonFrame["Experiment Phase"] ==
                                    trial][columns]
        tempFrame = tempFrame.dropna()

        # tempFrame = tempFrame[~tempFrame[columns[-1]].isin(["No Pecks"])==True]
        return tempFrame