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.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',[]):

View File

@ -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