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