Skip to Content
Tkinter GUI Application Development Blueprints, Second Edition - Second Edition
book

Tkinter GUI Application Development Blueprints, Second Edition - Second Edition

by Bhaskar Chaudhary
March 2018
Beginner to intermediate
422 pages
10h 33m
English
Packt Publishing
Content preview from Tkinter GUI Application Development Blueprints, Second Edition - Second Edition

Creating a Weather Reporter application

Let's now build a simple Weather Reporter application. The weather data for any given location will be fetched from the network, suitably formatted, and presented to the user.

We will use a higher level module named urllib to fetch weather data from the web. The urllib module is part of Python's standard library and it provides an easy to use API for working with URLs. It has four submodules:

  • urllib.request: For opening and reading URLs
  • urllib.error: For handling exceptions raised by urllib.request
  • urllib.parse: For parsing URLs
  • urllib.robotparser: For parsing robots.txt files

With urllib.request, fetching the contents of a web page turns into three lines of code (see 9.05_urllib_demo.py):

import ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Tkinter GUI Application Development Blueprints

Tkinter GUI Application Development Blueprints

Bhaskar Chaudhary

Publisher Resources

ISBN: 9781788837460Supplemental Content