Skip to content
Advertisement

Trying to declare a lambda function inside command parameter for the button but it doesn’t work(Tkinter)

I’m trying to enter a function with parameters without calling it by using lambda but I bump into an error, do you know why?

Here’s the function:

JavaScript

All I’m trying to do is to change the accountName and accountPassword values for my code.

Here’s where I’m trying to write it down:

JavaScript

And here’s from where I retrieve the new values:

JavaScript

Thanks a lot in advance :)

Advertisement

Answer

The reason you’re getting error (in future please post the traceback in the question too) is that tkinter’s button requires command to be function of no arguments. So drop the underscore in your code.

JavaScript

Also note that it’s better to check for None the following way and use and when you don’t mean bit operations:

JavaScript
User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement