In this course, you will improve your Python skills by coding a Minesweeper game using the tkinter library. The game is fully implemented using Object Oriented Programming.
✏️ Course from JimShapedCoding. Check out his channel:
💻 Code:
⭐️ Course Conetents ⭐️
⌨️ (0:00:00) Getting Started
⌨️ (0:26:22) Creating Cells & Mines
⌨️ (0:49:40) Minesweeper Algorithms
⌨️ (1:36:29) Display Game data
⌨️ (2:00:28) Finishing touches and playing the game
🎉 Thanks to our Champion and Sponsor supporters:
👾 Raymond Odero
👾 Agustín Kussrow
👾 aldo ferretti
👾 Otis Morgan
👾 DeezMaster
—
Learn to code for free and get a developer job:
Read hundreds of articles on programming:
And subscribe for new videos on technology every day:
Thank you for your effort freecodecamp.. Can you make Android dev tutorials like (kotlin, jet pack compose, android studio) 💖🎊
I think they are already available
@Anon only kotlin course is available.. There is an android studio course but they use Java in the course not kotlin… And they use xml not jet pack compose…Java and xml are old.. And nowadays people use kotlin and jet pack compose
Thank you for this awesomeness! 🙏
Thanks a lot for posting this, I hope it will make a lot of developers comfortable developing Object Oriented Projects! 🙂
i recently watched some of your videos on your channel (python OOP videos) and i found some useful things.
thanks!!
Thank you very much for your wonderful teachings.
Great course, Jim!
I have a question.
I want to randomixe the mines if the first click is mine.
How can I do that?
Hi Jim great video. I’ve followed everything but I am still only getting a “I am left clicked” responce when I right click. I have tried it as button 2 and button 3. Any ideas where I might be going wrong? I am using a Mac if that helps
Thank you for the great tutorial. I just wanted to leave a quick note for anyone using Linux. The background color specified @2:05:11 bg=”SystemButtonFace” will generate an error. Use bg=”gray85″ instead
@timex haven’t tackled that part just yet. i saw there’s a way using gtk in linux, but I haven’t gotten it to work just yet
That issue makes me a little worried when developing cross-platform GUI apps. What GUI lib can be used cross-compile and using python?
Piggy-backing your comment to deliver another message to Linux users: as Jim mentions in the video, the ctypes module won’t work for you. However, tkinter already has dialog box functionality. In `cell.py` add `messagebox` to this list of `tkinter` imports. Then, down in the `show_mine` method add: `messagebox.showinfo(“title here”, “message text here.”)`
@Dennis Chaves thank you! I’ll definitely give this a try
Works!
After hunting down all of my typos, finally it runs, and from many many tries, I won once. Great fun to prog along with you.
Wow, such a cool game, I remember playing this game when I’m small, it’s really cool
This is awesome, thank you, really appreciate.
I really enjoyed this one, quite simple and a lot of good ideas which can be used
Thank you -what is the IDE you are using? I am using IDLE on MacOS, and when I try an Run the file it doens’t launch Python, I have to launch Python fis then run the file. Your integrated IDE looks a btter option!
Pycharm
Great tutorial I have ever seen about tkinter library 😎
In order to test the success message, I added a static method to the class to show all the mines:
@staticmethod
def show_all_mines():
for cell in Cell.all:
if cell.is_mine:
cell.cell_btn_object.configure(bg=’yellow’)
In the main program, after randomize the mine placement:
Cell.show_all_mines()
Just for testing of course.
HAHA I did something similar, I left a section of commented lines called “IDBEHOLDA 😈”
Or randomize 1 mine instead of 9
Ubuntu 20 in show_min() , use activebackground=’red’ , so it is going to stop the transitioning effect in the button grid.
Really easy to follow and overall good project
nice. just starting to learn oop. easy to follow along. thanks jim.
going to take a break now before designing. if you get to static method part 55:47 make sure to indent! lol
Thank’s a lot for this tutorial. Great job. You not only declared how to code this game but you really explained every step including your thoughts why to chose a certain implementation.
Your tutorials are well explained. Thank you!
Excelent. Thats perfect to learn about OO programing . Great video, excelent explanation
Thanks for your tutorial. I learned a lot and actually won .. eventually. 😉
I find this tutorial so helpful and itneresting! But I got stuck very fast, because I keep getting the error “Unknow option “-Height” when runing the code after having added the top_frame. Anyone who has any idea what I am doing wrong? Her is my code:
from tkinter import *
root = Tk()
# Override the setting of the window
root.configure(bg=’yellow’)
root.geometry(‘1200×600’)
root.title(‘Minesweeper Game’)
root.resizable(False, False)
top_frame = Frame(
root,
bg=”red”,
width=1200,
hight=150
)
top_frame.place(x=0, y=0)
)
# Run the window
root.mainloop()
Typo in “hight=150”
Te felicito, te segui desde el inicio y me andubo perfecto el juego!!; solo que la salida por perder no me funciona bien, osea, si solo escrivo exit() sale en la segunda vez que perdes.