This commit is contained in:
yumoqing 2020-11-18 10:29:57 +08:00
parent 78213544fd
commit 619f6d4718
4 changed files with 51 additions and 10 deletions

View File

@ -261,6 +261,7 @@ class Blocks(EventDispatcher):
return obj
def __build(self,desc:dict,ancestor=None):
print('__build(),desc=',desc)
widgetClass = desc.get('widgettype',None)
if not widgetClass:
print("__build(), desc invalid", desc)
@ -304,19 +305,33 @@ class Blocks(EventDispatcher):
def build_rest(self, widget,desc,ancestor,t=None):
bcnt = 0
btotal = len(desc.get('subwidgets',[]))
def doit(self,widget,bcnt,btotal,desc,o,w):
bcnt += 1
params={
'blocks':self,
'bcnt':bcnt,
'btotal':btotal,
'desc':desc,
'widget':widget
}
def doit(params,o,w):
params['bcnt'] += 1
bcnt = params['bcnt']
btotal = params['btotal']
blocks = params['blocks']
desc = params['desc']
widget = params['widget']
if hasattr(widget,'parenturl'):
w.parenturl = widget.parenturl
widget.add_widget(w)
print('bcnt=',bcnt,'btotal=',btotal,'desc=',desc)
if bcnt >= btotal:
for b in desc.get('binds',[]):
self.buildBind(widget,b)
print('buildBind() called',b)
blocks.buildBind(widget,b)
def doerr(o,e):
raise e
f = partial(doit,self,widget,bcnt,btotal,desc)
f = partial(doit,params)
for sw in desc.get('subwidgets',[]):
b = Blocks()
b.bind(on_built=f)
@ -335,6 +350,7 @@ class Blocks(EventDispatcher):
return
f = self.buildAction(widget,desc)
w.bind(**{event:f})
print('w=',w,event,desc)
def uniaction(self,widget,desc, *args):
acttype = desc.get('actiontype')
@ -475,6 +491,7 @@ class Blocks(EventDispatcher):
return
def doerr(o,e):
print('blocks.py:wigetBuild() failed,desc=',desc)
self.dispatch('on_failed',e)
name = desc['widgettype']

View File

@ -394,7 +394,4 @@ class DataGrid(WidgetReady, BoxLayout):
fs.append(f)
return fs
def on_ready(self,o,v=None):
print('***********onRadey*************')
Factory.register('DataGrid',DataGrid)

View File

@ -1,10 +1,36 @@
from kivy.core.window import Window
from kivy.uix.floatlayout import FloatLayout
from kivy.uix.boxlayout import BoxLayout
from kivy.uix.button import Button
from kivy.uix.label import Label
from kivy.app import App
from .utils import CSize
class TwinShapeMenuBar(BoxLayout):
def __init__(self,**kw):
pass
class MultiPanel(BoxLayout):
def __init__(self,bar_width=CSize(2),**kw):
BoxLayout.__init__(self,**kw)
self.panels = []
self.bar_width = bar_width
self.menubar = TwinShapeMenuBar(self,bar_width=bar_width)
self.cur_panel = None
self.bind(on_size=self.sizeChanged)
def sizeChanged(self,*args):
if len(self.panels) == 0:
return
if len(self.panels) == 1:
self.cur_panel.height = self.height - self.menubar.height
self.cur_panel.width = self.height - self.menubar.width
return
self.menubar.sizeChanged(self)
self.cur_panel.height = self.height - self.menubar.height
self.cur_panel.width = self.height - self.menubar.width
class PageContainer(FloatLayout):
def __init__(self,**kw):
super().__init__(**kw)

View File

@ -1,5 +1,5 @@
from functools import partial
from kivy.uix.button import Button, ButtonBehavior
from kivy.uix.behaviors import TouchRippleButtonBehavior
from kivy.graphics import Color, Rectangle
from kivy.uix.boxlayout import BoxLayout
from kivy.factory import Factory
@ -7,7 +7,7 @@ from kivy.factory import Factory
from kivyblocks.ready import WidgetReady
from kivyblocks.bgcolorbehavior import BGColorBehavior
class PressableBox(ButtonBehavior, BoxLayout):
class PressableBox(TouchRippleButtonBehavior, BoxLayout):
def __init__(self,border_width=1,
bgcolor=[0,1,0,1],
selected_color=[1,0,0,1],
@ -17,7 +17,7 @@ class PressableBox(ButtonBehavior, BoxLayout):
border_width,
border_width],
**kw)
ButtonBehavior.__init__(self)
TouchRippleButtonBehavior.__init__(self)
self.b_bgcolor = bgcolor
self.border_width = border_width
self.b_selected_color = selected_color
@ -93,6 +93,7 @@ class ToggleItems(BGColorBehavior, BoxLayout):
self.register_event_type('on_changed')
def on_changed(self,v=None):
print('Toggle on_changed fired')
pass
def select_item(self,o=None):