0%

Book Description

Discover solutions to all your Tkinter and Python GUI development problems

About This Book

  • Integrate efficient Python GUI programming techniques with Tkinter
  • Efficiently implement advanced MVC architectures in your Python GUI apps
  • Solve all your problems related to Tkinter and Python GUI development

Who This Book Is For

This book is for Python developers who are familiar with the basics of the language syntax, data structures, and OOP. You do not need previous experience with Tkinter or other GUI development libraries.

What You Will Learn

  • Add widgets and handle user events
  • Lay out widgets within windows using frames and the different geometry managers
  • Configure widgets so that they have a customized appearance and behavior
  • Improve the navigation of your apps with menus and dialogs
  • Apply object-oriented programming techniques in Tkinter applications
  • Use threads to achieve responsiveness and update the GUI
  • Explore the capabilities of the canvas widget and the types of items that can be added to it
  • Extend Tkinter applications with the TTK (themed Tkinter) module

In Detail

As one of the more versatile programming languages, Python is well-known for its batteries-included philosophy, which includes a rich set of modules in its standard library; Tkinter is the library included for building desktop applications. Due to this, Tkinter is a common choice for rapid GUI development, and more complex applications can benefit from the full capabilities of this library. This book covers all of your Tkinter and Python GUI development problems and solutions.

Tkinter GUI Application Development Cookbook starts with an overview of Tkinter classes and at the same time provides recipes for basic topics, such as layout patterns and event handling. Next, we cover how to develop common GUI patterns, such as entering and saving data, navigating through menus and dialogs, and performing long-running actions in the background. You will then make your apps leverage network resources effectively, perform 2D and 3D animation-related tasks, create 3D objects, and perform advanced graphical operations. Finally, this book covers using the canvas and themed widgets.

By the end of the book, you will have an in-depth knowledge of Tkinter classes, and will know how to use them to build efficient and rich GUI applications.

Style and approach

A practical recipe-based guide that will help you find solutions to all your Tkinter and Python GUI development-related problems.

Downloading the example code for this book You can download the example code files for all Packt books you have purchased from your account at http://www.PacktPub.com. If you purchased this book elsewhere, you can visit http://www.PacktPub.com/support and register to have the files e-mailed directly to you.

Table of Contents

  1. Title Page
  2. Copyright and Credits
    1. Tkinter GUI Application Development Cookbook
  3. Dedication
  4. Packt Upsell
    1. Why subscribe?
    2. PacktPub.com
  5. Contributors
    1. About the author
    2. About the reviewers
    3. Packt is searching for authors like you
  6. Preface
    1. Who this book is for
    2. What this book covers
    3. To get the most out of this book
      1. Download the example code files
      2. Download the color images
      3. Conventions used
    4. Get in touch
      1. Reviews
  7. Getting Started with Tkinter
    1. Introduction
    2. Structuring a Tkinter application
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There's more...
    3. Working with buttons
      1. How to do it...
      2. How it works...
      3. There's more...
    4. Creating text entries
      1. How to do it...
      2. How it works...
      3. There's more...
      4. See also
    5. Tracing text changes
      1. How to do it...
      2. How it works...
      3. There's more...
      4. See also
    6. Validating a text entry
      1. How to do it...
      2. How it works...
      3. There's more...
      4. See also
    7. Selecting numerical values
      1. How to do it...
      2. How it works...
      3. There's more...
      4. See also
    8. Creating selections with radio buttons
      1. How to do it...
      2. How it works...
      3. There's more...
    9. Implementing switches with checkboxes
      1. How to do it...
      2. How it works...
      3. There's more...
      4. See also
    10. Displaying a list of items
      1. How to do it...
      2. How it works...
      3. There's more...
      4. See also
    11. Handling mouse and keyboard events
      1. How to do it...
      2. How it works...
      3. There's more...
      4. See also
    12. Setting the main window's icon, title, and size
      1. How to do it...
      2. How it works...
      3. There's more...
  8. Window Layout
    1. Introduction
    2. Grouping widgets with frames
      1. Getting ready
      2. How to do it…
      3. How it works…
      4. There's more…
      5. See also
    3. Using the Pack geometry manager
      1. Getting ready
      2. How to do it…
      3. How it works…
      4. There's more…
      5. See also
    4. Using the Grid geometry manager
      1. Getting ready
      2. How to do it…
      3. How it works…
      4. There's more…
      5. See also
    5. Using the Place geometry manager
      1. Getting ready
      2. How to do it…
      3. How it works…
      4. There's more…
      5. See also
    6. Grouping inputs with the LabelFrame widget
      1. Getting ready
      2. How to do it…
      3. How it works…
    7. Dynamically laying out widgets
      1. Getting ready
      2. How to do it…
      3. How it works…
    8. Creating horizontal and vertical scrollbars
      1. Getting ready
      2. How to do it…
      3. How it works…
      4. There's more…
      5. See also
  9. Customizing Widgets
    1. Introduction
    2. Working with colors
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There's more...
    3. Setting widget fonts
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There's more...
      5. See also
    4. Using the options database
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There's more...
      5. See also
    5. Changing the cursor icon
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There's more...
    6. Introducing the Text widget
      1. Getting ready
      2. How to do it...
      3. How it works...
    7. Adding tags to the Text widget
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There's more...
      5. See also
  10. Dialogs and Menus
    1. Introduction
    2. Showing alert dialogs
      1. Getting ready
      2. How to do it...
      3. How it works...
    3. Asking for user confirmation
      1. Getting ready
      2. How to do it...
      3. How it works...
    4. Choosing files and directories
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There's more...
    5. Saving data into a file
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There's more...
      5. See also
    6. Creating a menu bar
      1. Getting ready
      2. How to do it...
      3. How it works...
    7. Using variables in menus
      1. Getting ready
      2. How to do it...
      3. How it works...
    8. Displaying context menus
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There's more...
    9. Opening a secondary window
      1. Getting ready
      2. How to do it...
      3. How it works...
    10. Handling window deletion
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There's more...
    11. Passing variables between windows
      1. Getting ready
      2. How to do it...
      3. How it works...
  11. Object-Oriented Programming and MVC
    1. Introduction
    2. Structuring our data with a class
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There's more...
    3. Composing widgets to display information
      1. Getting ready
      2. How to do it...
      3. How it works...
    4. Reading records from a CSV file
      1. Getting ready
      2. How to do it...
      3. How it works...
    5. Persisting data into a SQLite database
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. See also
    6. Refactoring using the MVC pattern
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There's more...
  12. Asynchronous Programming
    1. Introduction
    2. Scheduling actions
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There's more...
      5. See also
    3. Running methods on threads
      1. How to do it...
      2. How it works...
      3. There's more...
        1. Thread methods - start, run, and join
        2. Parameterizing the target method
    4. Performing HTTP requests
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. See also
    5. Connecting threads with a progress bar
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. See also
    6. Canceling scheduled actions
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There's more...
    7. Handling idle tasks
      1. Getting ready
      2. How to do it...
      3. How it works...
    8. Spawning separate processes
      1. Getting ready
      2. How to do it...
      3. How it works...
  13. Canvas and Graphics
    1. Introduction
    2. Understanding the coordinate system
      1. How to do it...
      2. How it works...
      3. There's more...
    3. Drawing lines and arrows
      1. Getting ready
      2. How to do it...
      3. How it works...
    4. Writing text on a canvas
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There's more...
        1. Placing the text by its upper-left corner
        2. Setting line wrapping
    5. Adding shapes to the canvas
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. See also
    6. Finding items by their position
      1. Getting ready
      2. How to do it...
      3. How it works...
    7. Moving canvas items
      1. How to do it...
      2. How it works...
      3. There's more...
      4. See also
    8. Detecting collisions between items
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There's more...
    9. Deleting items from a canvas
      1. Getting ready
      2. How to do it...
      3. How it works...
    10. Binding events to canvas items
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There's more...
      5. See also
    11. Rendering a canvas into a PostScript file
      1. How to do it...
      2. How it works...
      3. There's more...
  14. Themed Widgets
    1. Introduction
    2. Replacing basic widget classes
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. See also
    3. Creating an editable drop-down with Combobox
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There's more...
    4. Using the Treeview widget
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There's more...
        1. Using tags in Treeview items
      5. See also
    5. Populating nested items in a Treeview
      1. Getting ready
      2. How to do it...
      3. How it works...
    6. Displaying tabbable panes with Notebook
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. There's more...
    7. Applying Ttk styling
      1. How to do it...
      2. How it works...
    8. Creating a datepicker widget
      1. Getting ready
      2. How to do it...
      3. How it works...
      4. See also
  15. Other Books You May Enjoy
    1. Leave a review - let other readers know what you think