Adding a GUI to my Existing Mileage Script

Last time on Dragonball Z well not last time but in a prior post I created a small python script to make tracking Vending Machine mileage a little easier. Using Google Maps History information I was able to pull my prior locations info, parse it and get a rough view of my driving. From that I really wanted to extend and dip my toes into a Python GUI framework. Seems like the perfect project for it. It’s a pickle!

I prefer to start with a rough sketch of the app and work from there. Understanding the basics of what the application should do will drive all of the proceeding decisions, including the gui framework. I’m a visual learner so the sketch or prototype helps.

With this basic UI I can select a file to import, list the details and leave the door open for enhancements in the future like sorting, search or even an Excel export! :)

All right so this is a simple data table type application. There are suprisingly a lot of GUI frameworks avaialble for python and initially I was a little overwhelmed. Kivy, PySimpleGUI, PyQt and others are detailed here My overall decision making processes is always laziness a thorough review for best fit. The most intersting of these options to me is a cross platform framework called kivywhich would allow for iOS, Android, macOS and Windows cross compatability of UI elements. It also teaches core concepts via the game PONG which is quite possibly the best way to teach anything. Ever.

Without much ado I set about enhancing my project. A wild pipenv install kivy appeared and almost immediately there was an error …

rocky start This probably explains why all of my memes are so pixelated- “Missing jpeg :]” If one bothers to RTFM Kivy requires Pillow which inturn requires a few additional libraries. Resolved by a brew install libjpeg and subsequent pipenv related functions behaved as expected.

Holy crap another error?

It needs pygame. I guess I should have seen that coming with the PONG tutorial thing. With a little further brew and pip magic I was able to resolve the web of dependencies and finally get an application window rendered. It was glorious and by default dark and not that awkward white/tan color that windows all seem to be. Soon enough I had a FileChooser running.

For v-zero point one I decided on a KISS mentality and used a lot of tongue simply dumped my previous cli output into a list which I render. In the future I would like to use a DataTable from KivyMd and parse the obtained kml information into it. For now though all I have managed to do is invert the color of the exact same kml string between two.