From 619f6d47184409ffc4d72ce9a7900c2fd0b1f8f9 Mon Sep 17 00:00:00 2001 From: yumoqing Date: Wed, 18 Nov 2020 10:29:57 +0800 Subject: [PATCH] bugfix --- kivyblocks/blocks.py | 25 +++++++++++++++++++++---- kivyblocks/dg.py | 3 --- kivyblocks/pagescontainer.py | 26 ++++++++++++++++++++++++++ kivyblocks/toggleitems.py | 7 ++++--- 4 files changed, 51 insertions(+), 10 deletions(-) diff --git a/kivyblocks/blocks.py b/kivyblocks/blocks.py index 259d2be..324721f 100755 --- a/kivyblocks/blocks.py +++ b/kivyblocks/blocks.py @@ -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'] diff --git a/kivyblocks/dg.py b/kivyblocks/dg.py index d2997e5..2f49888 100644 --- a/kivyblocks/dg.py +++ b/kivyblocks/dg.py @@ -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) diff --git a/kivyblocks/pagescontainer.py b/kivyblocks/pagescontainer.py index 244ed88..3b23121 100644 --- a/kivyblocks/pagescontainer.py +++ b/kivyblocks/pagescontainer.py @@ -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) diff --git a/kivyblocks/toggleitems.py b/kivyblocks/toggleitems.py index 2b0f425..3e5dd72 100644 --- a/kivyblocks/toggleitems.py +++ b/kivyblocks/toggleitems.py @@ -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):