Using ChatGPT to Build a 'Toil' Tracking Application
Introduction
A Python-based GUI application, dubbed the 'Toil Tracker,' came to life recently, thanks to OpenAI's ChatGPT and a user with a need. The goal was simple: create a straightforward yet functional tool to track and manage laborious tasks—often referred to as 'toil'. Toil, in the world of Site Reliability Engineering, signifies those mundane tasks that, while not providing enduring value, are essential to keep things running smoothly.
The application, as envisioned by its creator, James Curtis, would be the first of it's kind. After an extensive search and finding no similar tool out there, he decided to build one himself, and he enlisted the help of AI to accomplish this. The resulting program was 360 lines of Python Code. Links to the code and the corresponding chat can be found at the bottom of this article.
The author during his creation was intentional in not writing code, but allowing the AI to invent it's own program with guidance, like requesting new features. Stating when things didn't work as intended, and pasting in existing code and stating what errors were present.
Journey With ChatGPT
The initial prompt for this program was as follows.
Starting with a simple Python GUI skeleton, James and ChatGPT embarked on a journey to bring the application to life. Initially, they set up the basic GUI layout using tkinter, Python's de facto standard GUI package. After the layout was finalized, they moved onto the next task—data entry.
ChatGPT provided step-by-step guidance for creating an 'Add Toil' button that could take input from the entry fields and append it to the tkinter Treeview widget. Following this, they added functionality for removing existing records by right-clicking a row in the Treeview.
The next step was implementing the ability to delete selected records. This was achieved through two functions: one for deleting a single row and another for deleting multiple rows at once.
Next it was time to add a Dark Mode, while not perfect, after several iterations a mostly usable Dark Mode was added as a new feature to the fledgling application.
In each of these steps, ChatGPT's responses were detailed, accurate, and understandable, which greatly sped up the development process.
To achieve these things James iterated on the processing, asking ChatGPT simple things like "add an option to remove toil form the database", "Add a GUI to this Program", and "Allow the user to modify the items in the treeview". As the program became more complex, more complex prompts were required.
领英推荐
More complext prompts started to look like the following statements
The Dark Mode doesn't work on Windows 11, make it compatible with Windows 11
Make sure the text in treeview when changing to darkmode also changes to a light Grey font
Database Integration
After ensuring that the GUI functioned as intended, the next step was to add data persistence. For this, they integrated an SQLite3 database with the application. ChatGPT helped set up the database connection, create a table, and implement CRUD operations.
The SQLite3 database synchronizes with the GUI. Any operation—be it the creation, modification, or deletion of a record—is immediately reflected in the database.
Saving Time with AI
Over the course of development, James found that using ChatGPT significantly reduced his time spent searching for information and troubleshooting issues. Instead of browsing multiple resources or forums for each problem, he could ask ChatGPT directly and get a detailed and accurate response. It's estimated that using ChatGPT cut down the development time by around 50%, a significant gain in productivity.
Limitations
While ChatGPT was highly beneficial in accelerating the process, it's important to note that it is not a perfect solution. Understanding the generated code and implementing it correctly required a good understanding of Python and tkinter. Additionally, while ChatGPT's responses were generally accurate, there were instances where James had to lead ChatGPT into the right direction to get usable code.
Overall ChatGPT did well with most tasks, though it struggled as the program got more complex and it had difficulties in creating Dark Mode and optimizing the user experience. Though it did better than I envisioned overall.
Conclusion
The development of the Toil Tracker stands as a testament to the potential benefits of AI-assisted coding. Through its interaction with ChatGPT, the application came to life efficiently and effectively, filling a gap in the market for this kind of tool. Despite its limitations, using AI in this manner opens up an exciting path for the future of coding and software development.
The resulting Project can be found on github here: https://github.com/administrativetrick/SRE_Toil_Tracker
A full link to the Chat can be found here: https://chat.openai.com/share/8be50688-994d-48b2-a879-e2c4ba2a9792
Thanks for sharing!!