This commit is contained in:
yumoqing 2021-06-26 21:40:20 +08:00
parent 116113eb02
commit 6a98efec88

View File

@ -569,12 +569,23 @@ class MenuTree(TextTree):
self.menucall(node) self.menucall(node)
def menucall(self, node): def menucall(self, node):
data = {}
dw = node.data.get('datawidget')
if dw:
data_widget = Factory.Blocks.getWidgetById(dw)
if data_widget:
vn = node.data.get('datamethod', 'getValue')
if hasattr(data_widget, vn):
f = getattr(data_widget, vn)
data = f()
if not isinstance(data, dict):
data = {}
url = node.data.get('url') url = node.data.get('url')
target = Factory.Blocks.getWidgetById(node.data.get('target',self.target),self)
if url: if url:
params = node.data.get('params',{}) params = node.data.get('params',{})
target = Factory.Blocks.getWidgetById(self.target,self) params.update(data)
if not target:
return
blocks = Factory.Blocks() blocks = Factory.Blocks()
desc = { desc = {
"widgettype":"urlwidget", "widgettype":"urlwidget",
@ -583,8 +594,9 @@ class MenuTree(TextTree):
"params":params "params":params
} }
} }
print('menucall(), params=', params)
w = blocks.widgetBuild(desc) w = blocks.widgetBuild(desc)
if w: if w and target:
target.add_widget(w) target.add_widget(w)
return return
@ -592,15 +604,16 @@ class MenuTree(TextTree):
if rfname: if rfname:
f = getRegisterFunctionByName(rfname) f = getRegisterFunctionByName(rfname)
if f: if f:
f(self,node.data) f(self, **data)
return return
script = node.data.get('script') script = node.data.get('script')
if script: if script:
target_name = node.data.get('target', self.target) target_name = node.data.get('target', self.target)
target = Factory.Blocks.getWidgetById(target_name, self) target = Factory.Blocks.getWidgetById(target_name, self)
data.update({'self':target})
if target: if target:
eval(script,{'self':target}) eval(script,data)
return return