Week 11 - Interface and Application Programming
The assignment this week was to write an application that interfaces with an input or output device that we have made. I decided to build upon the transmit-receive capacitance touch from Week 10. This is particularly useful for my final project because I want to build an interactive patent map and for that, I would need a window to pop up stating whether an object is patented or not and if it is patented, exactly what component, design, or function is patented.
Learning Python
As every TA has taught me thus far, I decided the best way to learn a new programming language was to copy and edit. So, I decided to use Neil's python from Week 11 and edit the contents of the window that pops up. To begin though, Yuval taught me that Python is an interpreter language, meaning that it reads line by line. He also introduced me to TKinter, a library for Python. After writing up a simple test python code, which listed out names, I decided to edit Neil's Python file.
First I added a threshold, such that a screen would pop up only when the difference between current and the last rx value was bigger than 10000. I added "canvas.delete("all")" such that a canvas is deleted except when the difference between current and rx value was greater than 10000. I then added an if statement and moved all the "canvas.create", "canvas.itemconfigure" and "canvas.coords" into my if statement. It works!
Next step was learning to edit the content within the window. Taking out the boxes were easy as "canvas.coords" seemed to be the command that was adding boxes. I simply changed those lines to comments and voila!
The last step was to edit the text. This took a few tries, as Python wasn't as inituitive for me. I looked at where I thought text might be defined and tried various edits.
Here is the final python file.
The one thing I could not figure out was why the first few letters were not showing up on the canvas. I had to manually add in spaces before the text I wanted to show, which is probably not the smartest way to solve this problem. I tried editing the coefficients in front of WINDOW within "canvas.create_text", but that only changed the size of the window itself and not the content within it. Either way, here is the final interface!
Thank you Yuval, Rob, and Brian for your help!