This commit is contained in:
yumoqing 2021-01-23 06:13:42 +08:00
parent b9c975ef48
commit b87cd5af45
4 changed files with 26 additions and 10 deletions

View File

@ -150,18 +150,30 @@ class Blocks(EventDispatcher):
globals()[name] = widget
def buildAction(self,widget,desc):
self.action_id += 1
fname = 'action%d' % self.action_id
conform_desc = desc.get('conform')
blocks = Blocks()
if not conform_desc:
return partial(blocks.uniaction, widget, desc)
l = {
}
body="""def %s(widget,obj=None, *args, **kw):
body="""def action(widget, *args, **kw):
jsonstr='''%s'''
desc = json.loads(jsonstr)
conform_desc = desc.get('conform')
blocks = Blocks()
if not conform_desc:
blocks.uniaction(widget, desc,*args, **kw)
""" % (fname, json.dumps(desc))
return
w = blocks.widgetBuild({
"widgettype":"Conform",
"options":conform_desc
})
w.bind(on_conform=partial(blocks.uniaction, widget, desc))
w.open()
print('Conform show.....')
""" % (json.dumps(desc))
exec(body,globals(),l)
f = l.get(fname,None)
f = l.get('action',None)
if f is None:
raise Exception('None Function')
func =partial(f,widget)
@ -358,6 +370,8 @@ class Blocks(EventDispatcher):
def uniaction(self,widget,desc, *args):
Logger.info('Block: uniaction() called, desc=%s', str(desc))
acttype = desc.get('actiontype')
if acttype=='blocks':
return self.blocksAction(widget,desc, *args)

Binary file not shown.

Before

Width:  |  Height:  |  Size: 26 KiB

After

Width:  |  Height:  |  Size: 29 KiB

View File

@ -21,8 +21,10 @@ from .graph import Graph, MeshLinePlot, MeshStemPlot, LinePlot, \
PointPlot
from .mapview import MapView
from .chart2d import Chart2d
from .message import Conform
r = Factory.register
r('Conform', Conform)
r('Chart2d', Chart2d)
r('Popup', Popup)
r('Graph', Graph)

View File

@ -85,12 +85,12 @@ class ToggleItems(BGColorBehavior, BoxLayout):
for desc in items_desc:
c = PressableBox(**kw)
d = desc.get('data')
if d:
c.setValue(d)
self.item_widgets.append(c)
self.add_widget(c)
c.bind(on_press=self.select_item)
if desc.get('data'):
c.setValue(desc['data'])
b = Factory.Blocks()
def cb(c,o,w):
c.add_widget(w)
@ -107,7 +107,7 @@ class ToggleItems(BGColorBehavior, BoxLayout):
self.register_event_type('on_press')
def on_press(self,v=None):
print('Toggle on_changed fired')
print('Toggle on_press fired')
pass
def select_item(self,o=None):