Book Image

Tkinter GUI Application Development Blueprints - Second Edition

By : Bhaskar Chaudhary
Book Image

Tkinter GUI Application Development Blueprints - Second Edition

By: Bhaskar Chaudhary

Overview of this book

Tkinter is the built-in GUI package that comes with standard Python distributions. It is a cross-platform package, which means you build once and deploy everywhere. It is simple to use and intuitive in nature, making it suitable for programmers and non-programmers alike. This book will help you master the art of GUI programming. It delivers the bigger picture of GUI programming by building real-world, productive, and fun applications such as a text editor, drum machine, game of chess, audio player, drawing application, piano tutor, chat application, screen saver, port scanner, and much more. In every project, you will build on the skills acquired in the previous project and gain more expertise. You will learn to write multithreaded programs, network programs, database-driven programs, asyncio based programming and more. You will also get to know the modern best practices involved in writing GUI apps. With its rich source of sample code, you can build upon the knowledge gained with this book and use it in your own projects in the discipline of your choice.
Table of Contents (12 chapters)

Creating a tiny framework

So why do we need another framework on top of Tkinter? If we need to build just a single program, we need not build a framework. However, if we find ourselves writing the same boilerplate code over and over again, a framework is what we need. That is, a framework is a tool that lets us easily generate generic and often-used patterns with ease.

Consider, for example, menus used in programs. A menu is such a common element in most programs, yet we need to handcraft each menu item every time we sit down to write a program. What if we could further abstract to simplify menu generation?

This is where frameworks come in handy.

Say you have a program that has 10 different top-level menus. Say each of the top-level menus has five menu items. We will have to then write 50 lines of code simply to display these 50 menu items. You have to link each of them manually...