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

The requests module


Requests was written to make HTTP requests very simple and human-readable. In simple terms, it lets us visit a web address directly in Python code instead of having to use a browser. This also gives us back the data returned from the server, meaning we can make use of it in our Python code.

We can use requests to grab data back from our flask web service and use it in some Python code. We will begin with a small demo script which will make use of the data which is being returned from our index function.

First things first; we need to install the requests module via pip. Make sure your virtual environment is sourced and run  pip install requests in your command line.

Sending a GET request

A GET request allows the requester (often called a client) to receive some information from a server. We can use a GET request to ask our server for some data in JSON format, which we can then use in the rest of the script.

Ensure your flask server is still running, then, open up a new Python...