This commit is contained in:
yumoqing 2020-07-23 21:21:23 +08:00
parent 3dcc395d65
commit ffd595097a
2 changed files with 32 additions and 6 deletions

View File

@ -295,7 +295,7 @@ class Blocks(EventDispatcher):
b = Blocks() b = Blocks()
b.bind(on_built=f) b.bind(on_built=f)
b.bind(on_failed=doerr) b.bind(on_failed=doerr)
w = b.widgetBuild(sw, ancestor=ancestor) b.widgetBuild(sw, ancestor=ancestor)
if btotal == 0: if btotal == 0:
for b in desc.get('binds',[]): for b in desc.get('binds',[]):

View File

@ -1,14 +1,14 @@
""" """
{ {
"widgettype":"BLKTabbedPanel", "widgettype":"BLKTabbedPanel",
"tab_pos":"top_left", "options":{
"color_level":0, "tab_pos":"top_left"
"width", },
"height",
"size_hint",
"tabs":[ "tabs":[
{ {
"text":"tab1", "text":"tab1",
"icon":"/img/hhhh.png",
"refresh_press":Fasle,
"content":{ "content":{
"widgettype":"urlwidegt", "widgettype":"urlwidegt",
"url":"reggtY", "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): class BLKTabItem(BGColorBehavior, TabbedPanelItem):
def __init__(self,parent,color_level=0,text="",content={}): def __init__(self,parent,color_level=0,text="",content={}):
self.parent=parent self.parent=parent