Python Game Development Project Using OOP – Minesweeper Tutorial (w/ Tkinter)

Ecommerce Empire Academy

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:

36 thoughts on “Python Game Development Project Using OOP – Minesweeper Tutorial (w/ Tkinter)”

  1. Thank you for your effort freecodecamp.. Can you make Android dev tutorials like (kotlin, jet pack compose, android studio) 💖🎊

    1. @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

  2. JimShapedCoding

    Thanks a lot for posting this, I hope it will make a lot of developers comfortable developing Object Oriented Projects! 🙂

    1. i recently watched some of your videos on your channel (python OOP videos) and i found some useful things.

    2. I have a question.
      I want to randomixe the mines if the first click is mine.
      How can I do that?

    3. Tristan Carter

      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

  3. 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

    1. @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

    2. That issue makes me a little worried when developing cross-platform GUI apps. What GUI lib can be used cross-compile and using python?

    3. 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 `` add `messagebox` to this list of `tkinter` imports. Then, down in the `show_mine` method add: `messagebox.showinfo(“title here”, “message text here.”)`

  4. 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.

  5. CodeDreamer_Ben

    Wow, such a cool game, I remember playing this game when I’m small, it’s really cool

  6. 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!

  7. In order to test the success message, I added a static method to the class to show all the mines:

    def show_all_mines():
    for cell in Cell.all:
    if cell.is_mine:

    In the main program, after randomize the mine placement:


    Just for testing of course.

    1. HAHA I did something similar, I left a section of commented lines called “IDBEHOLDA 😈”

  8. Adalberto Caldeira Brant Filho

    Ubuntu 20 in show_min() , use activebackground=’red’ , so it is going to stop the transitioning effect in the button grid.

  9. 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

  10. 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.

  11. David Castillo

    Excelent. Thats perfect to learn about OO programing . Great video, excelent explanation

  12. Sigrid Stiberg

    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.title(‘Minesweeper Game’)
    root.resizable(False, False)

    top_frame = Frame(
    ), y=0)

    # Run the window

  13. Andres Gonzalez

    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.

Comments are closed.