Page 4 of 4

Re: Drawing graphs in EG

Posted: Sun Dec 01, 2019 5:04 pm
by HTPCanwender
Thank you for your very quick answer. There is one issue. The code

Code: Select all

            def do():
                global plt
                plt.close()
                del plt
    
            wx.CallAfter(do)
freezes Eventghost. Everything goes well, if I wipe the picture with

Code: Select all

            ax2.remove()
            ax1.remove()
and keep the empty picture in memory without closing it.

My second question refers to the loop. Is it also possible to start the thread for example with a "nomal" event and terminate it after the execution? This would enable me to exchange the existing script without any other modifications.

Re: Drawing graphs in EG

Posted: Sun Dec 01, 2019 8:30 pm
by HTPCanwender
Thank you for your script using a thread. I learned a lot from it. At the moment I solved my problem in a different and very simple way. I am only using a script like

Code: Select all

import threading

def f():
   print("Thread Sonoff-33 Start")
   # HERE IS THE PLOTTING CODE
   print("Thread Sonoff-33 Ende")
   
thread1 = threading.Thread(target = f)
thread1.start()
   
The script is triggerd from the MQTT event coming from the measuring device. The destroying of the picture woks with this construction.

Re: Drawing graphs in EG

Posted: Sun Dec 01, 2019 11:38 pm
by kgschlosser
you can do that.. but the problem is if you end up with a problem in the tread it is going to get hung and it could possibly do that with open files and you will end up with data corruption..