Book description
Geometry Management, Event Handling, and more
About This Book
- A Practical, guide to learn the application of Python and GUI programming with tkinter
- Create multiple cross-platform real-world projects by integrating host of third party libraries and tools
- Learn to build beautiful and highly interactive user interfaces, targeting multiple devices.
Who This Book Is For
This book is for a beginner to intermediate-level Pythonists who want to build modern, cross-platform GUI applications with the amazingly powerful Tkinter. Prior knowledge of Tkinter is required.
What You Will Learn
- A Practical, guide to help you learn the application of Python and GUI programming with Tkinter
- Create multiple, cross-platform, real-world projects by integrating a host of third-party libraries and tools
- Learn to build beautiful and highly interactive user interfaces, targeting multiple devices.
In Detail
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.
Style and approach
An easy-to-follow guide, full of hands-on examples of real-world GUI programs. The first chapter is a must-read as it explains most of the things you need to get started with writing GUI programs with Tkinter. Each subsequent chapter is a stand-alone project that discusses some aspects of GUI programming in detail. These chapters can be read sequentially or randomly, depending on the reader's experience with Python.
Table of contents
- Title Page
- Copyright and Credits
- Packt Upsell
- Contributors
- Preface
-
Meet Tkinter
- Technical requirements
- Project overview
- Getting started
- GUI programming – the big picture
- The root window – your drawing board
- Widgets – the building blocks of GUI programs
- The Tkinter geometry manager
- Events and callbacks – adding life to programs
- Handling widget-specific variables
- Event unbinding and virtual events
- Doing it in style
- Some common root window options
- Getting interactive help
- Summary
- QA section
- Further reading
-
Making a Text Editor
- Project overview
- Getting started – setting up the editor skeleton
- Adding a menu and menu items
- Implementing the View menu
- Adding a built-in functionality
- Indexing and tagging
- Implementing the Select All feature
- Implementing the Find Text feature
- Types of Toplevel window
- Working with forms and dialogs
- Working with message boxes
- The icons toolbar and View menu functions
- Displaying line numbers
- Adding the cursor information bar
- Adding themes
- Creating a context/pop-up menu
- Summary
- QA section
- Further reading
-
Programmable Drum Machine
- Getting started
- Technical requirements
- Setting up the GUI in OOP
- Finalizing the data structure
- Creating broader visual elements
- Defining getter and setter methods
- The number of units and beats per unit features
- Loading drum samples
- Playing the drum machine
- Tkinter and threading
- Support for multiple beat patterns
- Saving beat patterns
- Working with ttk-themed widgets
- Summary
- QA section
- Further reading
-
Game of Chess
- An overview of the chapter
- Module requirements for this chapter
- Structuring our program
- Modeling the data structure
- Creating a Piece class
- Making the game functional
- Managing user preferences
- Summary
- QA section
- Further reading
-
Building an Audio Player
- An overview of the chapter
- External library requirements
- Program structure and broadview skeleton
- Deciding the data structure
- Creating the Player class
- Adding and removing items from a playlist
- Playing audio and adding audio controls
- Creating a seek bar
- One-time updates during audio playback
- Managing continuous updates
- Looping over tracks
- Adding a tooltip
- Summary
- QA section
- Further reading
-
Paint Application
- Overview of the application
- Creating a tiny framework
- Setting up a broad GUI structure
- Dealing with mouse events
- Adding toolbar buttons
- Drawing items on the canvas
- Adding a color palette
- Adding top bar options for draw methods
- Drawing irregular lines and super shapes
- Adding functionality to the remaining buttons
- Adding functionality to menu items
- Summary
- QA section
- Further reading
-
Piano Tutor
- Technical requirements
- A brief primer on piano terms
- Building the broad GUI structure
- Making the piano keyboard
- Playing audio
- Building the scales tutor
- Building the chord finder section
- Building the chord progression tutor
- Building the score maker
- A note on window responsiveness
- Summary
- QA section
- Further reading
- Fun with Canvas
-
Multiple Fun Projects
- Technical requirements
- Building a Snake game
- Creating a Weather Reporter application
- A simple socket demo
- Building a port scanner
- Building a chat application
- Creating a phone book application
- Using asyncio with Tkinter
- Interfacing with hardware/serial communication
- Summary
- QA section
- Further reading
-
Miscellaneous Tips
- Tracing Tkinter variables
- Widget traversal
- Validating user input
- Formatting widget data
- More on fonts
- Redirecting the command-line output to Tkinter
- The class hierarchy of Tkinter
- Tips for program design
- Handling cross-platform differences
- Tips for program optimization
- Distributing a Tkinter application
- The limitations of Tkinter
- Alternatives to Tkinter
- Tkinter in Python 2.x
- Summary
- QA section
- Other Books You May Enjoy
Product information
- Title: Tkinter GUI Application Development Blueprints - Second Edition
- Author(s):
- Release date: March 2018
- Publisher(s): Packt Publishing
- ISBN: 9781788837460
You might also like
book
Tkinter GUI Application Development Blueprints
Master GUI programming in Tkinter as you design, implement, and deliver ten real-world applications from start …
book
Tkinter GUI Programming by Example
Leverage the power of Python and its de facto GUI framework to build highly interactive interfaces …
book
Beginning Python Games Development : With Pygame, Second Edition
Beginning Python Games Development, Second Edition teaches you how to create compelling games using Python and …
book
Rapid GUI Programming with Python and Qt: The Definitive Guide to PyQt Programming
The Insider’s Best-Practice Guide to Rapid PyQt 4 GUI Development Whether you’re building GUI prototypes or …