Today I read up on how to create GUI calculator using Python (yep, done with Swift for now).
I referred to this for the full code as I have no idea where to start. I read through his code once to have an idea and I’m thrilled to say I understood most of it and I tried it out.
Well, first I had to install a third-party module called tkinter (a standard Graphic User Interface (GUI) package) using by keying brew install homebrew/dupes/tcl-tk followed by brew install python –with-tcl-tk into Terminal. Based on what I read, there are several other toolkits available and once you learn the basics of tkinter, it is easy to adapt to the others.
I encountered a few syntax errors while working on it but they were easy to debug. One thing on that code that did not work for me was this:
When I ran it, it indicated the following:
So instead of that I used self.newdiv = self.div.encode().decode() and it worked! My end product looked like that:
This isn’t a code I wrote but reading the codes people wrote actually helps me see how the various concepts are being applied. I’m quite proud of myself for moving away from the books (something I’d so stubbornly hung on to). I use them as reference books now for when I come across concepts (for example, “Class” and “Exception Handling”) that I needed clarifications on.
I’m eager to attempt another mini project! Any suggestions?
On a side note, I’m leaving for a vacation tomorrow and it’s unlikely I’ll be updating this space until I get back end next week. Hopefully the trip will bring me all the inspiration and motivation that I need to keep fighting!