Hello Guys I am trying to make a game with Tkinter. It involves selecting different options from a set of buttons. I created a root for the window, and am done with all the basic game programming. Its a football league simulator allowing players to select a team and choose what they want to do when their team match comes up.
There is a minor problem regarding the buttons I want to create for the User to click.
Each time a game featuring the selected team comes up, I create the buttons. Each button click refers to a certain method in the Frame object.
But I want one of the buttons to return control to the calling function. That has not been possible. I used this command

self.play_bttn=Button(self, text="Play game", command=return)

It didnt work. Is there any way of making a button do nothing but return to the calling function. The next few lines of the calling function are related to simulating the game? thanks in advance

3 Years
Discussion Span
Last Post by Schol-R-LEA

Yes. Is there a way to write a function that does an equivalent task like return?


Uhm, all that return does is end the function. Since command is optional, not required, simply omitting the command keyword argument would do the trick. OTOH, if you think you absolutely need a function there (e.g., as a placeholder), you can use something like this:

def empty_command:

Which has the effect of simply ending the function.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.