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)
self.play_bttn.grid()

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

command takes a function reference and return is no such object

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:
    pass

Which has the effect of simply ending the function.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.