bugfi
This commit is contained in:
parent
1bb2fa02c6
commit
402b1ae1da
@ -190,6 +190,9 @@ class Blocks(EventDispatcher):
|
||||
callback=None,
|
||||
errback=None,**kw):
|
||||
|
||||
if url is None:
|
||||
errback(None,Exception('url is None'))
|
||||
|
||||
if url.startswith('file://'):
|
||||
filename = url[7:]
|
||||
with codecs.open(filename,'r','utf-8') as f:
|
||||
@ -299,9 +302,25 @@ class Blocks(EventDispatcher):
|
||||
widget.widget_id = desc.get('id')
|
||||
|
||||
widget.build_desc = desc
|
||||
self.build_attributes(widget,desc)
|
||||
self.build_rest(widget,desc)
|
||||
return widget
|
||||
|
||||
def build_attributes(self,widget,desc,t=None):
|
||||
excludes = ['widgettype','options','subwidgets','binds']
|
||||
for k,v in [(k,v) for k,v in desc.items() if k not in excludes]:
|
||||
if isinstance(v,dict) and v.get('widgettype'):
|
||||
b = Blocks()
|
||||
w = b.w_build(v)
|
||||
if hasattr(widgets,k):
|
||||
aw = getattr(widget,k)
|
||||
if isinstance(aw,Layout):
|
||||
aw.add_widget(w)
|
||||
continue
|
||||
setattr(widget,k,w)
|
||||
continue
|
||||
setattr(widget,k,v)
|
||||
|
||||
def build_rest(self, widget,desc,t=None):
|
||||
self.subwidget_total = len(desc.get('subwidgets',[]))
|
||||
self.subwidgets = [ None for i in range(self.subwidget_total)]
|
||||
@ -478,7 +497,6 @@ class Blocks(EventDispatcher):
|
||||
}
|
||||
"""
|
||||
name = desc['widgettype']
|
||||
print('desc=',desc,'type=',type(desc))
|
||||
|
||||
def doit(desc):
|
||||
if not isinstance(desc,dict):
|
||||
@ -498,7 +516,7 @@ class Blocks(EventDispatcher):
|
||||
print(e)
|
||||
|
||||
if name == 'urlwidget':
|
||||
opts = desc.get('options').copy()
|
||||
opts = desc.get('options',{}).copy()
|
||||
addon = desc.get('extend')
|
||||
url = opts.get('url')
|
||||
if url is None:
|
||||
|
@ -40,15 +40,15 @@ class BoxViewer(WidgetReady, BoxLayout):
|
||||
remind = ['toolbar',
|
||||
'dataloader',
|
||||
'orientation',
|
||||
'viewer',
|
||||
'boxwidth',
|
||||
'boxheight',
|
||||
'color_level',
|
||||
'radius',
|
||||
'viewer_url'
|
||||
'viewer_url',
|
||||
'viewer'
|
||||
]
|
||||
kwargs = {k:v for k,v in options.items() if k not in remind }
|
||||
print('BoxViewer():kwargs=',kwargs)
|
||||
BoxLayout.__init__(self, orientation='vertical', **kwargs)
|
||||
WidgetReady.__init__(self)
|
||||
self.selected_data = None
|
||||
@ -157,7 +157,7 @@ class BoxViewer(WidgetReady, BoxLayout):
|
||||
if self.options.get('viewer_url'):
|
||||
desc = {
|
||||
"widgettype":"urlwidget",
|
||||
"optons":{
|
||||
"options":{
|
||||
"params":rec,
|
||||
"method":"GET",
|
||||
"url":self.options.get('viewer_url')
|
||||
|
@ -11,6 +11,7 @@ from kivyblocks.utils import CSize
|
||||
class PressableBox(BGColorBehavior, TouchRippleButtonBehavior, BoxLayout):
|
||||
def __init__(self,border_width=1,
|
||||
color_level=-1,
|
||||
user_data=None,
|
||||
radius=[],
|
||||
**kw):
|
||||
BoxLayout.__init__(self, padding=[border_width,
|
||||
@ -22,7 +23,7 @@ class PressableBox(BGColorBehavior, TouchRippleButtonBehavior, BoxLayout):
|
||||
BGColorBehavior.__init__(self,color_level=color_level,
|
||||
radius=radius)
|
||||
self.border_width = border_width
|
||||
self.user_data = None
|
||||
self.user_data = user_data
|
||||
self.unselected()
|
||||
|
||||
def on_press(self,o=None):
|
||||
|
Loading…
Reference in New Issue
Block a user