Drawing graphs in EG

Got a good idea? You can suggest new features here.
HTPCanwender
Experienced User
Posts: 87
Joined: Wed Feb 08, 2012 9:41 pm
Location: Germany

Re: Drawing graphs in EG

Post by HTPCanwender » Sun Dec 01, 2019 5:04 pm

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.

HTPCanwender
Experienced User
Posts: 87
Joined: Wed Feb 08, 2012 9:41 pm
Location: Germany

Re: Drawing graphs in EG

Post by HTPCanwender » Sun Dec 01, 2019 8:30 pm

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.

User avatar
kgschlosser
Site Admin
Posts: 5028
Joined: Fri Jun 05, 2015 5:43 am
Location: Rocky Mountains, Colorado USA

Re: Drawing graphs in EG

Post by kgschlosser » Sun Dec 01, 2019 11:38 pm

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..
If you like the work I have been doing then feel free to Image

Post Reply