Video Tutorial: Python Guessing Game (GUI Version)

Python Guessing Game (GUI)Python is a great language and there are a lot of resources on the Internet about how to program Python. One thing I find is that a lot of so-called "beginner" tutorials are actually pretty complicated. In particular, I set out to learn a little bit about GUI programming using Tkinter and found the explanations and examples pretty difficult to follow. So, I decided to create my own to share. The game was programmed in Python 2.7.  Be sure to watch the videos in HD (720p).

 

The Game
This is a simple guessing game. The computer randomly chooses a number between 1 and 10 and the user must guess. After each guess the user clicks the guess button to find the result: higher, lower, or correct. There is also a reset button so the user can start over with a new number.

The Tutorial
The tutorial is in four stages as follows:

STAGE I: VIDEO / CODE

  • Creating a Tkinter window
  • Adding widgets (Labels, Buttons, and a Text Entry box

STAGE II: VIDEO / CODE

  • Computer chooses a random number
  • Check if the user guess is correct and inform the user

STAGE III: VIDEO / CODE

  • Implementing a reset function

STAGE IV: VIDEO / CODE

  • Change the background color of the window and widgets
  • Change the window title
  • Change the size of the window (window geometry)
  • Clear the entry box

I hope you find this useful.  If so, please comment on the YouTube videos, subscribe to my YouTube channel, and follow me on Twitter (@tokyoedtech)

Comments

Post new comment

The content of this field is kept private and will not be shown publicly.

@TokyoEdTech

Poll

What LMS does your school use?: