While I have been busy writing Python code, I have not had time to get any well documented for posting here or even on StackOverflow. There is so much going on that I forget the neater bits in the pursuit of various tasks.
However, I have acquired a new Cosmonaut stylus for writing on my tablet. It feels nice in my hand, with a pleasant heft to it.
Yesterday I updated my copy of BBEdit, a Mac-only text editor from Bare Bones Software that I have been using for over a decade. I never got far with the program during my English-teaching career, but this semester the program was particularly useful to me in writing Python code for the final project in ECE 463.
After installing the update, I opened the About… window and scrolled down to find a familiar name. I cannot recall what I might have done to get on the list, or whether that is coincidentally someone with the same name, but there I am:
One of my three electrical engineering electives for this final semester is ECE 463: Introduction to Computer Communication Networks. About two weeks ago, we were assigned a final project: Design a P2P Connect-Five game that communicates using the HTTP Protocol.
My partner, Jun Lin, and I quickly decided to use Python for the client-side GUI, since I had done a fair amount of GUI work in the course of my internship this past summer. We opted for Python 3 and used the Anaconda distribution. I did nearly all the Python GUI with the use of tkinter. Because the Spyder3 IDE was taking more time to adjust to than Spyder 2, I ended up relying on Bare Bones Software's BBEdit text editor--the power of which I am now beginning to appreciate--and Mac OS X Terminal. That was it!
Jun Lin worked some magic--the only word I can use, since I know nothing about PHP--for the server-side scripting. Initially we ran the server off my GoDaddy shared hosting account, but we found that it would block us after too many accesses from the same IP addresses. That forced us to turn to a different host, which we happened to have.
Anyway, we will demonstrate the game in class on Wednesday, but I wanted to put up some screenshots. I plan to make my Python GUI code available online at some point, because it would surely be helpful to others.
The following screenshot show the game at startup. We were required to have a 19x19 game board. I opted for check buttons, because they are easy to work with and make nice arrays.
The other screenshot shows a win. Every time black--you (peer is pink)--makes a valid move, my algorithms scan for a vertical, horizontal, SW–NE, or NW–SE win. If one is found, the peer is notified of their loss and scores are updated accordingly. If the peer logs out midway, that is correctly handled. We are rather proud of our game!
For my internship, I have been learning Python, particularly v2.7.11, with Learning Python the Hard Way, various online resources, and a couple of books. Usually I do my work in my office on a Windows machine, on which I typically use Spyder and Windows PowerShell—how had nobody ever heard of it?—for Python.
At home, in the past, I have used the text editor BBEdit to write the Python code and IDLE. Now I am trying to copy what I do in the office, which led me to discovering that Mac OS X' Terminal does not have tab-autocompletion enabled by default. A travesty!
Thankfully, MacDaddy.com has very helpful page that explains how to add tab-autocompletion functionality and make Terminal far more useful.
My senior design group is to create a radio simulator that will run on a Raspberry Pi with a 7" touchscreen. Last term, we collected information about the project and planned it. This term, we make it; my current responsibility is the GUI. We have chosen to use Kivy, which works very well with Python.
While I had looked a bit at Kivy last term, I only began working with it yesterday. Over the course of 11 hours, I used ScreenManager to make three Screen objects: start-up screen with two simulator choices, the linked screen for Simulator A , and the linked screen for Simulator B. The two simulators' graphics are in their respective screens' backgrounds and I have basic navigation button functionality.
In addition to Kivy's own Pong tutorial, I found the following videos by Brian MacD to be quite useful in setting up my ScreenManager and three Screens. The videos have also helped me get an understanding for using properties.
StackOverflow has been invaluable, too. Correctly setting background colors and images for Buttons is now possible for me and how to do it makes sense.
This summer term I have an introductory Python class through Ivy Tech. It is my first online course. So far it has gone quite well, since all the materials are online, and it is not set such that each of the sessions only becomes available on certain days: All have been there since the first day, but they all have staggered due dates. I am working on the 13th of the 16 sessions, since I have been able to put great amounts of time into the course.
Python has been interesting so far. I like that it is an interpreted language, so I needn't compile. The distinction between integer and float division (// vs. /) is nice. The structure seems looser than C; indentations define blocks instead of end-of-line semicolons or other things. Python's lists seem to be a big improvement on C's arrays.
It is still early days, but Python does seem a fairly easy-to-learn language, at least to get going.