This commit is contained in:
yumoqing 2021-01-31 17:22:50 +08:00
parent 804c0357b1
commit 774bd8cc67
2 changed files with 25 additions and 6 deletions

View File

@ -1,6 +1,26 @@
# from appPublic.background import Background
from threading import Thread
from kivy.event import EventDispatcher from kivy.event import EventDispatcher
from appPublic.background import Background
class BackendFunction(EventDispatcher, Background): class BackendFunction(EventDispatcher, Thread):
def __init__(self, func, *args, **kw): def __init__(self, callee, *args, **kw):
self.fu 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)

View File

@ -219,7 +219,7 @@ class Blocks(EventDispatcher):
try: try:
hc = HttpClient() hc = HttpClient()
resp=hc(url,method=method,params=params,files=files) resp=hc(url,method=method,params=params,files=files)
print('Blocks.py :resp=',resp) # print('Blocks.py :resp=',resp)
return resp return resp
except Exception as e: except Exception as e:
if errback: if errback:
@ -612,7 +612,6 @@ class Blocks(EventDispatcher):
if Window.fullscreen == True: if Window.fullscreen == True:
w = app.fs_widget w = app.fs_widget
if w: if w:
print('full screen ...............................')
return find_widget_by_id(id, w) return find_widget_by_id(id, w)
return None return None
ids = id.split('.') ids = id.split('.')