Originally written on OCT 12, 2015 via Codepen here.
Recently, I’ve been delving into learning Python as a bootcamp student and working on developing software GUI’s (graphical user interfaces) using libraries such as Tkinter and WxPython. I think writing out what I learned so far helps me simplify and verbalize what it’s all about. So here are some examples between using both tools and some sample programs created. Just to emphasize again, the GUI’s are software focused which means they may not be the most visually appealing as prototypes; I have a taste in design, trust me.
Benefits in Using Python GUI Tools
As a front-end developer that is open to learning server-side languages and work on software development projects, it’s a great way to prototype very basic interfaces quickly. There are some well-known, cloud-based system apps built using these tools in their early stages such as BitTorrent, Google Drive, and Dropbox. For more detailed explanations on reasons explained in a nutshell and simple comparisons between the two, read here.
This is a Python toolkit that has been around since 1998 (acc. to Wikipedia) and is pretty well-known as one of the classic toolkits. Thus, there are tons of tutorials and sources written on it in case you run into issues. However, it’s not perfect and you may come across some inconsistencies when applying information from those older tutorials. There is actually an upgraded version on Github released called Phoenix that can be installed on Windows, though I was having trouble getting it to run on Mac OSX (perhaps due to Python’s 3.5 recent release). So far, as of writing this, I’ve found the best documentation on WxWidgets to be from Andrea Gavana organized here. Below is a simple UI built using WxPython.
Tkinter is another popular toolkit that I explored into and contains a lot documentation sources. It comes included within the Python Windows installer, so it’s quite a quick set up process. While going through tutorials, I foundTkDocs to be an excellent resource of current documentation on the array of widgets and things possible with Tkinter. They even have an e-book written on it that goes more in depth on the things possible with it.
These programs can also be connected to a Relational Database Management System (RDBMS) like sqlite3 and MySQL to store and manage data a user inputs (i.e name, email, notes, etc). With Python, it takes a simple ‘import sqlite3’ module to do this for a start. For MySQL, PythonAnywhere is one free resource available to dynamically store data with a GUI application. From there, creating the appropriate database, tables and fields is all it takes which I won’t go into much detail here.
There are several libraries I’ve yet to explore that are out there, and each one is different – from the installation process to the documentation of widgets and classes. Hopefully, this provided a brief overview on the two toolkits with some useful resources to delve into. However, there is definatley some value in taking the time to learn these toolkits with Python if software GUI prototyping is something you want to tackle down the line. This whole process also made me realize and appreciate how much code goes behind one simple function like importing files into a folder, or the task bar on the top of window menu screens… it’s quite amazing. Without toolkits like these, it would take a longer process and more code to create the simple program prototypes above.