I really need help in some parts of my minesweeper code using Tkinter. I don´t have much experience in python and I am facing two major problems that I just can´t solve. The first one is that, as I generate buttons dynamically, they all have the same name and receive the same variable in the textvar option. Because of that I am not able to change the image presented on the button. The only button I am able to change this way is the last one, obviously wrong...
The other problem is that i am not finding a way to make this:
When you click a button there are three option, there may be a bomb what will bring the game to an end, there may be bombs in the eight buttons around the one clicked and then a number will be shown in it, or (and here is my problem) if there are neither bombs in the button nor in the eight other, the program should "open" buttons in all directions until the button you clicked is surrounded by numbers or borders. How is the most efficient way to do that?

Recommended Answers

All 2 Replies

Can you show some code you have written by now?

Your project sounds like fun. rather than using buttons you might explore the canvas widget. I find that the canvas is more flexible than working with buttons/frames.

With buttons you can use pack|pack_forget to display and hide them but I can't think of a way to stack images.

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.