'How to set up message handling in Python

I have a question on general design for a gui app. The task is to set up a gui based app displaying a continuos flow, of measurement data. I have done such a thing with wx-python and wx.lib.pubsub in the past. The app starts a separate thread which opens the measurement device, polls the data and uses wx.lib.pubsub.pub.sendMessage() to notify the gui of new data. The gui updates but the thread keeps running. wx.lib.pubsub is deprecated now and tells to use PyPubSub now. Last PyPubSub-release is from Jan 2019, which tells me, this probably not the standard python way to do this. I have read through the pythons threading. But I do not want the gui to wait for an event, I want the gui to "register a callback function" or whatever this is called in python.

What is the most pythonic way to set up such thing?

Thanks for any hints.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source