From a36ada0574da6a1382f82df8d97271f512d0faf6 Mon Sep 17 00:00:00 2001 From: yumoqing Date: Fri, 4 Dec 2020 15:29:17 +0800 Subject: [PATCH] bugfix --- kivyblocks/form.py | 4 ++-- kivyblocks/tab.py | 15 ++++++++++++--- kivyblocks/widgetExt/inputext.py | 2 +- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/kivyblocks/form.py b/kivyblocks/form.py index 7693047..a36b886 100644 --- a/kivyblocks/form.py +++ b/kivyblocks/form.py @@ -181,8 +181,8 @@ class InputBox(BoxLayout): options = self.uidef.get('options',{}).copy() options.update(self.options.get('uiparams',{})) options['allow_copy'] = True - options['width'] = 1 - options['height'] = 2.5 + options['width'] = options.get('width',20) + options['height'] = options.get('height',1) if self.options.get('tip'): options['hint_text'] = i18n(self.options.get('tip')) diff --git a/kivyblocks/tab.py b/kivyblocks/tab.py index 478bc0a..e5e8614 100644 --- a/kivyblocks/tab.py +++ b/kivyblocks/tab.py @@ -19,6 +19,8 @@ }, } """ +from appPublic.uniqueID import getID + from kivy.uix.tabbedpanel import TabbedPanel, TabbedPanelItem from kivy.clock import Clock from kivy.factory import Factory @@ -28,15 +30,21 @@ from .bgcolorbehavior import BGColorBehavior class TabsPanel(BGColorBehavior, TabbedPanel): def __init__(self,color_level=-1, radius=[], + tabs=[], **options): - self.tabs_list = options.get('tabs') + self.tabs_list = tabs TabbedPanel.__init__(self,**options) BGColorBehavior.__init__(self,color_level=color_level, radius=radius) Clock.schedule_once(self.add_tabs,0) - def add_tab(self,text,desc): + def newname(self): + return getID() + + def add_tab(self,name,text,desc): def add(o,w): + if not hasattr(w,'widget_id'): + w.widget_id = name self.add_widget(TabbedPanelItem(text=text,content=w)) blocks = Factory.Blocks() blocks.bind(on_built=add) @@ -44,9 +52,10 @@ class TabsPanel(BGColorBehavior, TabbedPanel): def add_tabs(self,*args): for d in self.tabs_list: + name = d.get('name',self.newname()) text = d['text'] desc = d['content'] - self.add_tab(text,desc) + self.add_tab(name,text,desc) Factory.register('TabsPanel',TabsPanel) diff --git a/kivyblocks/widgetExt/inputext.py b/kivyblocks/widgetExt/inputext.py index 2e0e711..a105d45 100755 --- a/kivyblocks/widgetExt/inputext.py +++ b/kivyblocks/widgetExt/inputext.py @@ -71,7 +71,7 @@ class StrInput(TextInput): a['password'] = kv.get('password',False) a['multiline'] = kv.get('multiline',False) - Logger.info('TextInput:a=%s,h=%d,w=%d,CSize(1)=%d',a,h,w,CSize(1)) + Logger.info('TextInput:a=%s,kv=%s',a,kv) super(StrInput,self).__init__(**a) self.old_value = None self.register_event_type('on_changed')