From 5935b309ccd57dfa6cc20647ee32fd90b2020ebd Mon Sep 17 00:00:00 2001 From: Alexandre Gobbo Date: Mon, 7 Oct 2019 14:05:32 +0200 Subject: [PATCH] Script execution --- script/test/invoking.py | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 script/test/invoking.py diff --git a/script/test/invoking.py b/script/test/invoking.py new file mode 100644 index 0000000..9bf595b --- /dev/null +++ b/script/test/invoking.py @@ -0,0 +1,31 @@ +from javax.swing.SwingUtilities import invokeLater, invokeAndWait + + +def invoke(f, wait = False): + """ Execute function in event thread + + Args: + f(function reference) + wait (boolean, optional) + """ + if is_list(f): [m, a] = f; f = lambda: m(*a) + if wait: invokeAndWait(f) + else: invokeLater(f) + + +def x(): + plot([time.time()-start,time.time()-start,time.time()-start,]) +#plot([time.time()-start,time.time()-start,time.time()-start,]) + + +start = time.time() +invoke(lambda: plot([time.time()-start,time.time()-start,time.time()-start,]), False) +invoke(x, False) +invoke([plot,[[time.time()-start,time.time()-start,time.time()-start,],]], True) + + + + +print time.time() -start + +