Fun with threads in Python and wxPython

I have finally gotten back to programming in the last couple of days.  Our project has finally started to generate a lot of data, so I’ve been refactoring and improving my code that reads data stored in LabView binaries.  Today I spent a lot of time creating a GUI for browsing data.  Arguably, this wasn’t the best use of my time, but I learned a lot about multi-threaded Python GUI programming with wxPython.  You can find a gold mine of information on the multi-threaded wx programming at the wxPython wiki.  Because the LabView binary data has to be read sequentially, and the files are rather large, it takes a long time to read in a file.  I spawn a thread to handle the file reading,  while allowing the GUI to remain responsive.  The thread posts messages to the GUI window, which are used to update the user on the status of the file reading operation.  When the file is read, a final message containing the data is posted to the window.  It’s really pretty slick now that I’ve figured out how to do it.
I will soon post a clever scheme to capture text output from the file-reading function, and display it in the GUI, without making substantial changes to the file-reading function.

Leave a Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.