This document describes choices made and problems solved in the Python implementation of Conway's Game of Life. This was my first implementation of the game, and I chose Python because it's a popular, widely available scripting language, that I have some familiarity but not really a lot of experience.
I have very limited experience in Python, so I'm starting from scratch here. However, my experience in other languages guides me as to what to ask, and I arrived at the following selections fairly rapidly
- Coding Language Python (3.8.5)
- GUI Toolkit tkinter
- File Format: JSON, GeeksForGeek-Reading and Writing JSON in python
I knew I wanted some clickable main area, and since I'm initially writing on a desktop, I thought a standard main window type thing would be good. A mobile interface might be fun too, but, programming is still a desktop-first activity. Sooo.
I googled "Python Main Window with clickable main window Hello world", and found this description of PySimpleGui on the RealPython website. There, they discuss four available toolkits, and state that the TKinter toolkit is the most common and built in, although maybe not the easiest.
Created hello world by following this Python GUI: Build your first application using TKInter I Choose "grid" layout manager: There are 3 layout managers: auto-layout: pack(), pixel based: place(x=10,y=10), and grid(row=0, column=1)
Overall implementation was pretty straightforward, and took about 1 day of work, despite me having to look up EVERYTHING, such as "GUI Hello World", "Python Avoid Globals", "Object oriented python", "tkinter frames", avoiding globals, how to use ENUMs, string formatting, loops, etc. etc
- Was not running from command line (bcause it exited). added window.mainloop(), based on StackOverflow: tkinter not working from command line script
- Gui Structure (wrap in App function, create self) Runestone Academy: GUI Program Structure
- Implemented color screen using an emum to choose colors found at: Wellesley tkinter colors
- Avoid Null Objects - appending .grid(row,col) to object definition results in a null object, because .grid() returns 0. This caused me a bunch of pain.
- Timer object: Cribbed from examples here, here, and stackOverflow tkinter use after method
I only needed a simple file format, and files are probably not very large. A bit of googling shows that the common "JSON" format is natively supported in Python. Easy peasy.