How can I treat a file when the client imports a local file as a variable and using it later?


def getFile():
    return filedialog.askopenfilename()
from operation.encryption import getFile
button_encrypt = tk.Button(layoutframe, text="Encrypt", fg="green", command=getFile)

1 Reply 1

define a File class and make getFile a method.

class File:
    def __init__(self):
        self.filename=None
    def getFile(self):
        self.filename=filedialog.askopenfilename()

file = File()

then command=file.getFile

Now file.filename should contain the return value of askopenfilename

Your Reply

By clicking “Post Your Reply”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.