From ffd595097ac3f0745ef3618aebe911129963b718 Mon Sep 17 00:00:00 2001 From: yumoqing Date: Thu, 23 Jul 2020 21:21:23 +0800 Subject: [PATCH] bugfix --- kivyblocks/blocks.py | 2 +- kivyblocks/tab.py | 36 +++++++++++++++++++++++++++++++----- 2 files changed, 32 insertions(+), 6 deletions(-) diff --git a/kivyblocks/blocks.py b/kivyblocks/blocks.py index 91572e6..a729f5b 100755 --- a/kivyblocks/blocks.py +++ b/kivyblocks/blocks.py @@ -295,7 +295,7 @@ class Blocks(EventDispatcher): b = Blocks() b.bind(on_built=f) b.bind(on_failed=doerr) - w = b.widgetBuild(sw, ancestor=ancestor) + b.widgetBuild(sw, ancestor=ancestor) if btotal == 0: for b in desc.get('binds',[]): diff --git a/kivyblocks/tab.py b/kivyblocks/tab.py index 472da07..ecb6799 100644 --- a/kivyblocks/tab.py +++ b/kivyblocks/tab.py @@ -1,14 +1,14 @@ """ { "widgettype":"BLKTabbedPanel", - "tab_pos":"top_left", - "color_level":0, - "width", - "height", - "size_hint", + "options":{ + "tab_pos":"top_left" + }, "tabs":[ { "text":"tab1", + "icon":"/img/hhhh.png", + "refresh_press":Fasle, "content":{ "widgettype":"urlwidegt", "url":"reggtY", @@ -19,7 +19,33 @@ ] } """ +from kivy.uix.tabbedpanel import TabbedPanel +from kivy.clock import Clock +from kivyblocks.blocks import Blocks +class TabsPanel(BGColorBehavior, TabbedPanel): + def __init__(self,**options): + self.tabs_list = options.get('tabs') + self.color_level = options.get('color_level',0) + opts = {k:v for k,v in options.items() if k not in ['tabs','color_level']} + TabbedPanel.__init__(self,**opts) + BGColorBehavior.__init__(self) + Clock.schedule_once(self.addTabs,0) + + def add_tab(self,text,desc): + def add(o,w): + self.add_widget(TabbedPanelItem(text=text,content=w)) + blocks = Blocks() + blocks.bind(on_built=add) + blocks.widgetBuild(desc,ancestor=self) + + def add_tabs(self,*args): + for d in self.tabs_list: + text = d['text'] + desc = d['content'] + self.add_tab(text,desc) + + w = block.widgetBuild(( class BLKTabItem(BGColorBehavior, TabbedPanelItem): def __init__(self,parent,color_level=0,text="",content={}): self.parent=parent