12345678910111213141516171819202122232425262728293031323334 |
- import threading
- from cura.CuraApplication import CuraApplication
- class InterCallObject:
- def __init__(self):
- self.finish_event = threading.Event()
- self.result = None
- def call_on_qt_thread(func):
- def _call_on_qt_thread_wrapper(*args, **kwargs):
- def _handle_call(ico, *args, **kwargs):
- ico.result = func(*args, **kwargs)
- ico.finish_event.set()
- inter_call_object = InterCallObject()
- new_args = tuple([inter_call_object] + list(args)[:])
- CuraApplication.getInstance().callLater(_handle_call, *new_args, **kwargs)
- inter_call_object.finish_event.wait()
- return inter_call_object.result
- return _call_on_qt_thread_wrapper
|