The Weather App Project

Desktop Weather Application

Joining Back-End Development in Python 3 and GUI in Tkinter

In this desktop weather application I used pure Python 3 for development of both the data handling and graphic user interface. The final product has its own installer for Windows and Linux.

The Weather Application v.1.01 in action

Building of the Weather App

The Evolution of the Program

The first thing before starting to code is to draw some general design and think what is necessary for the user to interact with the app smoothly. Careful consideration has to be applied when it comes eventually to converting this initial idea into lines of code.

After a while I changed the way the whole project is written from “all in one file” approach to separation of interests with the model-view-mediating controller approach.

This allowed for specification of classes and made the entire structure of the project much clearer.

You Can Have a Look at the Code for the Entire Project

The source can be viewed at: https://github.com/Tomasz-Kluczkowski/Weather-App

Initial version of the GUI

The Initial Version of the Graphic User Interface

I started from a simple conversion of the command line interface version of the application and transferred weather report display into a TKinter text-box.

It quickly became apparent that the user interface is too overblown and contains unnecessary buttons whilst not really using the whole screen estate available.

After consulting with my QA department (wife and child) I came up with a more user friendly and graphically pleasing version which is the one used now in the application.

Skills Gained and Problems Solved

Using Restful APIs

To obtain data for the application I had to learn to use 2 APIs:

  • The open weather for the weather report.
  • Geonames for the time zone information to make sure times are displayed locally and not in UTC format.

This lead to the need to handle user input and communication errors to make sure the application cannot crash.

Creating Graphic User Interface

To create the GUI I used TKinter library included in the standard Python installation. I had to learn how to design an interface that is intuitive and contains the minimum required amount of buttons and fields for the application to be usable with ease.

Making Application Faster

To optimise the way the application runs I had to move the data gathering part of the program into a sub-process to unfreeze the GUI. Also to make display snappy I introduced display class which pre-renders necessary report information so that when user selects a different report type it gets shown instantly by raising it to the top of the application’s window.

Using Model-View-Controller Structure

Initially the project was written in one large .py file but it was creating a difficulty in organising the code in a clean manner. After researching on the internet I chose Model-View-Mediating Controller(Adapter) as the application’s architecture. The separation of interests enhanced my ability to test and modify the whole project.

Applying Object Oriented Style

Coming from Pascal and Turbo Pascal and the procedural approach to coding I had to learn a new way of looking at data structure and implement OOP to this project. After a while this style become my favourite though.

Unit Testing & Integration Testing With Pytest

Good amount of time was spent by me unit testing and integration testing the project with the help of Pytest package. I find it much more preferable to the standard Unittest library and faster to write tests. I realised importance of tests when refactoring and it allowed me to find solutions to broken parts of code quicker.

Storing Information in a Database (SQL)

To create a permanent source of user data I had to use sqlite3 library and learn SQL. This allowed for persistence of user settings between application launches.

Converting Python Script to an Executable

To make the application easy to use for everyone I had to find a way of converting the .py file into an executable file appropriate for the platform of choice. I have used cx_Freeze package to help me in this task. For Windows OS I used an installer Inno Setup which compresses all files into one self extracting package.

Automating Build Process

To make the application easy to use for everyone I had to find a way of converting the .py file into an executable file appropriate for the platform of choice. I have used cx_Freeze package to help me in this task. For Windows OS I used an installer Inno Setup which compresses all files into one self extracting package.

Controlling Versions With Git

This project would be a total mess without version controlling. Git and GitFlow proved to be more than useful for that. These tools forced me to follow a certain regime during development and I will stick to it in the future for sure.

Created by: Tomasz Kluczkowski

Copyright © Tomasz Kluczkowski

Created by: Tomasz Kluczkowski

Copyright © 2017