From 774bd8cc67e3516d74910ed54626668af2531821 Mon Sep 17 00:00:00 2001 From: yumoqing Date: Sun, 31 Jan 2021 17:22:50 +0800 Subject: [PATCH] bugfix --- kivyblocks/backendfunction.py | 28 ++++++++++++++++++++++++---- kivyblocks/blocks.py | 3 +-- 2 files changed, 25 insertions(+), 6 deletions(-) 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('.')