Casterbridge - Python Apps
This is a small collection of well commented Python apps for learning or customisation. The apps are written in Python 3 and Tkinter which are commonly available on most platforms. You should be comfortable running python programs and basic git operations.
This collection started when I wanted a clock widget for my desktop and it was easier to whip up a little application than hunt down an existing program that allowed customisation. Each app is given a short background and some ideas for further exercises. Comments in the code describe how they work.
Geting Started
You should have these tools installed and be familiar with basic operation of them:
- a console / shell e.g. bash
- git
- python3
One more optional app is pylint, if you make changes to a file, you can run it through pylint (e.g. pylint clock.py) which will report on your code quality. This is super helpful to all coders at all levels so it is good to get into the habits early.
For the news app, you should have Newsboat installed and configured with some RSS feeds. This site has an RSS feed if you need one. The link is at the foot of each page.
The programs are stored in a git repository on GitHub. Here is how to get them onto your computer:
git clone https://github.com/daftspaniel/simplepythonapps.git cd simplepythonapps cd apps python3 clock.py
Clock
GUI programs are event driven mostly. User clicks a button and the application performs a task. Tkinter like other interface frameworks provides a timer facility which provides an event after a time interval. This timer can be used to give the clock its 'tick'.
Further exercises:
- EASY - Change the colour and window position
- MEDIUM - Also show the time from a city across the world
- HARD - Make the clock talk on the hour!
Scratchpad
Text is handy to keep around when working between apps. A Scratchpad lets the user put in some text for later reference or use and automatically saves it so the user does not have to think about files and paths.
Further exercises:
- EASY - Make the Scratchpad bigger
- MEDIUM - Add a button to clear the text area
- HARD - Have multiple text areas
News
Newsboat is a command line RSS news reader that stores the stories in a standard SQLite database. This can quickly become a sizable collection of useful information. This app is not a GUI, it displays the output goes to the console.
Further exercises:
- EASY - Show the date for the story
- MEDIUM - Allow the user to pass a parameter to request a number of stories
- HARD - Convert into a GUI app