So my goal is to make something similar to rx.py from Week 8's project except with a button controlling when to start recording and when to stop recording. I started with python since rx.py was in python, so I looked up Tkinter tutorials. However, I noticed that Tkinter stops all execution of code once top. Upon googling for a workaround (like timer interrupts or something) I found a stack overflow thread about this exact problem.
It's a function that just sketchily calls on itself every millisecond (the fastest a Tkinter widget can go) and does ser.read() several times. However, I got an error when from the change_state() function when trying to change the variable "recording". Upon more googling, I learned this very strange quirk about python: functions assume that all variable are local unless it is very obvious that they are not (like specifying that the variable is nonlocal or global). I fixed this by being more hacky and encapsulating the global variables xlist and recording as lists!
At the moment, my code only creates a button. I'd like for it to plot the sound after each cycle of recording as part of the window.