Anywhere you use a function you can also use a lambda expression, since a lambda expression is just a different way of writing a function. But I don't think that is what you are asking. To be honest I have no idea what you are asking.
You use the words "continue" and "def". In Python, "continue" can be used to jump to the start of an enclosed loop. Is that what you mean by "continue"?
Another common usage of "continue" is to resume. Are you asking if you can use a button as a variable length wait? Something like this:
1 2 3 4 5 |
while not button_pressed:
pass
…
Button(root, 'Push me' , command = button_pressed = True )
|
This is wrong in a couple of ways. The first error is that you cannot have "infinite" loops in a GUI program. The "while not button_pressed:" loop prevents mainloop() from running. If mainloop() does not run then the program will not recognize that you pushed the button. The entire GUI freezes.
Since waiting is mostly done by preventing anything else from happening, waiting is something to avoid in a GUI program. A GUI program is event driven. You do not wait for the user to do anything. The user performs actions which generate events (button presses, text entry etc...) and your program responds to the events to do what the user wants to do. So instead of:
1 2 3 |
do_A()
wait for button press
do_B()
|
You would have something like:
1 2 |
do_A()
Button(root, text = "Push me" , command = do_B())
|
Instead of a long stream of code that you expect to execute sequentially your program becomes a bunch of short functions that get bound to GUI controls. It is a completely different way of thinking about programming.