Hey everyone! I've been working on a Python project to control and automate some instruments in my lab, and I decided to create a GUI for it, as future users might not be comfortable tweaking parameters directly in the code. Everything was going well until I hit a snag with the oscilloscope acquisition.
I set it up to run on a separate thread so that I could check a stop-flag and halt the acquisition via a button in the GUI. The problem is, I keep encountering random errors: for instance, I might set the number of signals to acquire to 100 and it works fine, but when I set it to 10, the oscilloscope thinks it already has 100 signals measured, which leads to odd behavior, like not resetting to 0 signals. This issue doesn't occur when I run the same code outside of the GUI in a synchronous manner.
Could the threading be causing these issues, or is it something related to the GUI itself? Are there best practices I might have overlooked, or is this a common problem when using custom GUIs with Tkinter?
1 Answer
It sounds like you've got quite a challenge! Without a second setup to test with, you'll probably face some tricky debugging. Have you thought about breaking down your code into smaller unit tests? This could help ensure things like the oscilloscope connection and the start/stop functionality are working correctly. Might also be worth documenting everything; using a YAML file for configurations could simplify things for future users too!

Thanks for the suggestions! I've considered documentation and a YAML file sounds useful. My bosses are insistent on the GUI, so I need to make it work! I'll definitely look into those unit tests for debugging.