Book Image

Tkinter GUI Programming by Example

Book Image

Tkinter GUI Programming by Example

Overview of this book

Tkinter is a modular, cross-platform application development toolkit for Python. When developing GUI-rich applications, the most important choices are which programming language(s) and which GUI framework to use. Python and Tkinter prove to be a great combination. This book will get you familiar with Tkinter by having you create fun and interactive projects. These projects have varying degrees of complexity. We'll start with a simple project, where you'll learn the fundamentals of GUI programming and the basics of working with a Tkinter application. After getting the basics right, we'll move on to creating a project of slightly increased complexity, such as a highly customizable Python editor. In the next project, we'll crank up the complexity level to create an instant messaging app. Toward the end, we'll discuss various ways of packaging our applications so that they can be shared and installed on other machines without the user having to learn how to install and run Python programs.
Table of Contents (18 chapters)
Title Page
Copyright and Credits
Packt Upsell
Contributors
Preface
Index

Chapter 2. Back to the Command Line – Basic Blackjack

Blackjack is a casino game involving just a deck of cards. The aim of the game is to get as close as possible to a hand worth 21 points – but go over and you're out!

Number cards are worth their face value, picture cards are worth 10, and an ace is worth either 1 or 11 depending on your other cards. Players are initially dealt two cards and can either choose to hit (receive another card) or stick (submit their current hand).

Players face off against the dealer, who has one card face down and one face up. When all players have chosen to stick or are out (having a hand over 21), the winner is the one with a hand closest to 21.

Why am I telling you about blackjack? Because we're going to make a blackjack game using Tkinter! Not only will this chapter introduce you to powerful widgets, such as the canvas and Frame widgets, but it will also teach something that I come across a lot in the world of GUI programming—having a CLI program and the desire...