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!
i would recommend at some point installing linux on *something.* i would say run it from q, but q is no longer supported on the mac (in linux it is qemu.)
from swift and brew i can tell youre learning to code on a mac. thats fine, i was playing with my own g4 a few weeks ago: http://i.imgur.com/Cxhrf2Z.png but everything python is just a little more work on a mac. (even a newer, intel-based one.)
im not trying to get you to switch platforms as much as explore python in different situations… when you can find the time. enjoy your journey, it is a great language.
LikeLike
definitely something I’ll find time for. thank you for this!
LikeLiked by 1 person