Game description: the user receives certain amount of money that he can easily dissipate making bets on horse races.

Requirements to a programmer: knowledge of basic mechanics of working in the programming language which includes working with data input, data processing, data output, conditions and the while loop; understanding of functions and methods, ability to use them. Recommended age 16+ .

Purpose of the game: study of the Tkinter library with which it's quite simple to create modern program interface - not like all these characters and digits in the black background of the text editor, but full-fledged windows with cute buttons and menus.

Example of working with Tkinter:

Program text:

from tkinter import * root = Tk() root.geometry("640x280") root.title("Python programming") label1 = Label(root, text="HELLO, I AM TKINTER!", font="Consolas 20") label1.place(x=190, y=100) okButton = Button(root, text="OK", width="20", font="Consolas 10") okButton.place(x=250, y=150) root.mainloop()

Not complicated, is it? If you worked with the previous sections attentively, you can edit the program right now, adding some buttons and changing the inscriptions. Cause everything in programming works by the same rules and in the same style!

The library is standard, that is, we don't have to download and install it.

What awaits us? There will be the main window of the program that allows to make a bet on a certain horse (or on some horses, or even on all of them); saving the sum to a file and loading it from there (just copying the previous functions); a message box that contains information about the weather, the day and the horses.

Since I draw badly even when I do my best, I took the images of the chess knights - let the horses be knights. All images are available for download, the link will be granted. The main window of the program:

Bets are made using the drop-down list of set values:

Message box:

After the player has made a bet, he presses the "START" button, and horses run. There won't be movement animation (see the paragraph when I draw badly), the horses just move from left to right at different speeds. The speed is calculated according to the horse state and some random values:

Accidents are also included in the game, for example, when a horse may suddenly rush in the opposite direction. To implement this, we'll use special Tkinter tools like this:

...or something like that:

You can generate all these events in your own way, keeping the idea and extend its functionality. It will be fun, turn your imagination on! You can even joke knock-knock normal jokes!

The game is conceived as demonstration of working with the Tkinter library, the author doesn't support gambling, as he is used to earning by honest, reliable and decent work.

Good luck, friends! The horses are whinnying, the jockeys are nervously rubbing their hands, the bookmakers are greeting us with а friendly smile and expecting phenomenal profit... and it's time for us to delve into development!

© 2019-2021 Viktor Trofimov
© 2019-2021 Translation and adaptation by Danil Shentsov
[ Top page ]