<s>[INST] from tkinter import *
from tkinter import filedialog

def upload():
        file = filedialog.askopenfilename(title="Select file", filetypes=[("All Files", "*.*")])

class Application(Frame):
    def __init__(self, master=None):
        super().__init__(master)
        self.master = master
        self.pack()
        self.create_widgets()

    def create_widgets(self):
        self.upload_button = Button(self)
        self.upload_button["text"] = "Upload"
        self.upload_button["command"] = upload
        self.upload_button.pack(side="top")

        self.quit = Button(self, text="QUIT", fg="red",
                          command=self.master.destroy)
        self.quit.pack(side="bottom")

root = Tk()
app = Application(master=root)
app.mainloop()

You're trying to use an instance variable in another method without specifying the instance.  Why can't you just define a function outside of the class the way you've done here?[/INST]