For my education:
In directButton if the command=function does not call function till you press button , but command=function() calls the function even if you do not push the button why is that?
JB
For my education:
In directButton if the command=function does not call function till you press button , but command=function() calls the function even if you do not push the button why is that?
JB
The moment Python executes the line DirectButton(command=function()), the function gets executed directly, and the result of function() (most likely None) will be passed to the ‘command’ argument. On the other hand, if you pass command=function, you’re not actually calling it yet, but rather storing a reference to the function. DirectButton will invoke it for you when you click the button.
You need to keep in mind that a function is just like any other variable. You can do whatever you want with it, like “functionA = functionB”. The only difference is that they are callable, that means that you can invoke the code that it stores by use of (), like function().