0

I've snipped out parts of the code, as i suspect the answer is quite newbie :)

I am trying to validate the input in the Entry by clicking the button (which references to a validation funciton). However the path_directory-variable are not updated (it keeps the initial value).

How do I update it when the button is clicked?

directory = tk.Entry(entry_frame)

validate_button= tk.Button(paths_frame, text='Next', command=lambda path_directory=directory.get(): self.validate_path(path_directory)) 

def validate_path(self, path_directory):
        if path.exists(path_directory):
            print('# Path validation succuessful: ', path_directory)
        else: 
            print('# Path validation failed: ', path_directory)

1 Answer 1

1

The problem is that you are getting the value only on lambda init. Simply use a function, not lambda, like this:

def validate_click():
    path_directory=directory.get()
    self.validate_path(path_directory)
validate_button= tk.Button(paths_frame, text='Next', command=validate_click)

Hope that's helpful!

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, 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.