diff --git a/kivyblocks/backendfunction.py b/kivyblocks/backendfunction.py index cee0713..cb9ac38 100644 --- a/kivyblocks/backendfunction.py +++ b/kivyblocks/backendfunction.py @@ -1,6 +1,26 @@ +# from appPublic.background import Background +from threading import Thread from kivy.event import EventDispatcher -from appPublic.background import Background -class BackendFunction(EventDispatcher, Background): - def __init__(self, func, *args, **kw): - self.fu +class BackendFunction(EventDispatcher, Thread): + def __init__(self, callee, *args, **kw): + EventDispatcher.__init__(self) + Thread.__init__(self) + self._callee = callee + self._args = args + self._kw = kw + self.register_event_type('on_success') + self.register_event_type('on_failed') + + def on_success(self, ret): + print('BackendFunction(), on_success fired') + + def on_failed(self, e): + print('BackendFunciton(), on_failed fired', e) + + def run(self): + try: + x = self._callee(*self._args, **self._kw) + self.dispatch('on_success', x) + except Exception as e: + self.dispatch('on_failed',e) diff --git a/kivyblocks/blocks.py b/kivyblocks/blocks.py index c22eb39..1784d7f 100755 --- a/kivyblocks/blocks.py +++ b/kivyblocks/blocks.py @@ -219,7 +219,7 @@ class Blocks(EventDispatcher): try: hc = HttpClient() resp=hc(url,method=method,params=params,files=files) - print('Blocks.py :resp=',resp) + # print('Blocks.py :resp=',resp) return resp except Exception as e: if errback: @@ -612,7 +612,6 @@ class Blocks(EventDispatcher): if Window.fullscreen == True: w = app.fs_widget if w: - print('full screen ...............................') return find_widget_by_id(id, w) return None ids = id.split('.')