bugfix
This commit is contained in:
parent
52aff9d1e1
commit
3120174a48
@ -123,11 +123,11 @@ class Blocks(EventDispatcher):
|
|||||||
fname = 'action%d' % self.action_id
|
fname = 'action%d' % self.action_id
|
||||||
l = {
|
l = {
|
||||||
}
|
}
|
||||||
body="""def %s(widget,obj=None, v=None):
|
body="""def %s(widget,obj=None, *args):
|
||||||
jsonstr='''%s'''
|
jsonstr='''%s'''
|
||||||
desc = json.loads(jsonstr)
|
desc = json.loads(jsonstr)
|
||||||
app = App.get_running_app()
|
blocks = Blocks()
|
||||||
app.blocks.uniaction(widget, desc)
|
blocks.uniaction(widget, desc,*args)
|
||||||
""" % (fname, json.dumps(desc))
|
""" % (fname, json.dumps(desc))
|
||||||
exec(body,globals(),l)
|
exec(body,globals(),l)
|
||||||
f = l.get(fname,None)
|
f = l.get(fname,None)
|
||||||
@ -312,21 +312,21 @@ class Blocks(EventDispatcher):
|
|||||||
f = self.buildAction(widget,desc)
|
f = self.buildAction(widget,desc)
|
||||||
w.bind(**{event:f})
|
w.bind(**{event:f})
|
||||||
|
|
||||||
def uniaction(self,widget,desc):
|
def uniaction(self,widget,desc, *args):
|
||||||
acttype = desc.get('actiontype')
|
acttype = desc.get('actiontype')
|
||||||
if acttype=='blocks':
|
if acttype=='blocks':
|
||||||
return self.blocksAction(widget,desc)
|
return self.blocksAction(widget,desc, *args)
|
||||||
if acttype=='urlwidget':
|
if acttype=='urlwidget':
|
||||||
return self.urlwidgetAction(widget,desc)
|
return self.urlwidgetAction(widget,desc, *args)
|
||||||
if acttype == 'registedfunction':
|
if acttype == 'registedfunction':
|
||||||
return self.registedfunctionAction(widget,desc)
|
return self.registedfunctionAction(widget,desc, *args)
|
||||||
if acttype == 'script':
|
if acttype == 'script':
|
||||||
return self.scriptAction(widget, desc)
|
return self.scriptAction(widget, desc, *args)
|
||||||
if acttype == 'method':
|
if acttype == 'method':
|
||||||
return self.methodAction(widget, desc)
|
return self.methodAction(widget, desc, *args)
|
||||||
alert("actiontype(%s) invalid" % acttype,title='error')
|
alert("actiontype(%s) invalid" % acttype,title='error')
|
||||||
|
|
||||||
def blocksAction(self,widget,desc):
|
def blocksAction(self,widget,desc, *args):
|
||||||
target = self.getWidgetByIdPath(widget, desc.get('target','self'))
|
target = self.getWidgetByIdPath(widget, desc.get('target','self'))
|
||||||
add_mode = desc.get('mode','replace')
|
add_mode = desc.get('mode','replace')
|
||||||
opts = desc.get('options')
|
opts = desc.get('options')
|
||||||
@ -347,7 +347,7 @@ class Blocks(EventDispatcher):
|
|||||||
b.bind(on_failed=doerr)
|
b.bind(on_failed=doerr)
|
||||||
b.widgetBuild(opts,ancestor=widget)
|
b.widgetBuild(opts,ancestor=widget)
|
||||||
|
|
||||||
def urlwidgetAction(self,widget,desc):
|
def urlwidgetAction(self,widget,desc, *args):
|
||||||
target = self.getWidgetByIdPath(widget, desc.get('target','self'))
|
target = self.getWidgetByIdPath(widget, desc.get('target','self'))
|
||||||
add_mode = desc.get('mode','replace')
|
add_mode = desc.get('mode','replace')
|
||||||
opts = desc.get('options')
|
opts = desc.get('options')
|
||||||
@ -373,7 +373,7 @@ class Blocks(EventDispatcher):
|
|||||||
b.bind(on_failed=doerr)
|
b.bind(on_failed=doerr)
|
||||||
b.widgetBuild(d,ancestor=widget)
|
b.widgetBuild(d,ancestor=widget)
|
||||||
|
|
||||||
def getActionData(self,widget,desc):
|
def getActionData(self,widget,desc, *args):
|
||||||
data = {}
|
data = {}
|
||||||
if desc.get('datawidget',False):
|
if desc.get('datawidget',False):
|
||||||
dwidget = self.getWidgetByIdPath(widget,
|
dwidget = self.getWidgetByIdPath(widget,
|
||||||
@ -383,7 +383,7 @@ class Blocks(EventDispatcher):
|
|||||||
data = keyMapping(data, desc.get('keymapping'))
|
data = keyMapping(data, desc.get('keymapping'))
|
||||||
return data
|
return data
|
||||||
|
|
||||||
def registedfunctionAction(self, widget, desc):
|
def registedfunctionAction(self, widget, desc, *args):
|
||||||
rf = RegisterFunction()
|
rf = RegisterFunction()
|
||||||
name = desc.get('rfname')
|
name = desc.get('rfname')
|
||||||
func = rf.get(name)
|
func = rf.get(name)
|
||||||
@ -395,21 +395,22 @@ class Blocks(EventDispatcher):
|
|||||||
d = self.getActionData(widget,desc)
|
d = self.getActionData(widget,desc)
|
||||||
params.update(d)
|
params.update(d)
|
||||||
print('registedfunctionAction(),params=',params)
|
print('registedfunctionAction(),params=',params)
|
||||||
func(**params)
|
func(*args, **params)
|
||||||
|
|
||||||
def scriptAction(self, widget, desc):
|
def scriptAction(self, widget, desc, *args):
|
||||||
script = desc.get('script')
|
script = desc.get('script')
|
||||||
if not script:
|
if not script:
|
||||||
return
|
return
|
||||||
target = self.getWidgetByIdPath(widget, desc.get('target','self'))
|
target = self.getWidgetByIdPath(widget, desc.get('target','self'))
|
||||||
d = self.getActionData(widget,desc)
|
d = self.getActionData(widget,desc)
|
||||||
ns = {
|
ns = {
|
||||||
"self":target
|
"self":target,
|
||||||
|
"args":args
|
||||||
}
|
}
|
||||||
ns.update(d)
|
ns.update(d)
|
||||||
self.eval(script, ns)
|
self.eval(script, ns)
|
||||||
|
|
||||||
def methodAction(self, widget, desc):
|
def methodAction(self, widget, desc, *args):
|
||||||
method = desc.get('method')
|
method = desc.get('method')
|
||||||
target = self.getWidgetByIdPath(widget, desc.get('target','self'))
|
target = self.getWidgetByIdPath(widget, desc.get('target','self'))
|
||||||
if hasattr(target,method):
|
if hasattr(target,method):
|
||||||
@ -417,7 +418,7 @@ class Blocks(EventDispatcher):
|
|||||||
kwargs = desc.get('options',{})
|
kwargs = desc.get('options',{})
|
||||||
d = self.getActionData(widget,desc)
|
d = self.getActionData(widget,desc)
|
||||||
kwargs.update(d)
|
kwargs.update(d)
|
||||||
f(**kwargs)
|
f(*args, **kwargs)
|
||||||
else:
|
else:
|
||||||
alert('%s method not found' % method)
|
alert('%s method not found' % method)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user