From a8ea8f332f7d5386c230cf141fce894374b534ae Mon Sep 17 00:00:00 2001 From: yumoqing Date: Wed, 12 May 2021 00:55:46 +0800 Subject: [PATCH] bugfix --- kivyblocks/dg.py | 18 ++++-------------- kivyblocks/pagepanel.py | 11 +++++++++-- kivyblocks/tree.py | 2 ++ 3 files changed, 15 insertions(+), 16 deletions(-) diff --git a/kivyblocks/dg.py b/kivyblocks/dg.py index 2eaf5d6..ec79b22 100644 --- a/kivyblocks/dg.py +++ b/kivyblocks/dg.py @@ -30,13 +30,14 @@ from .widget_css import WidgetCSS def field_widget(desc, rec): viewer = desc.get('viewer') if viewer: - if not isinstance(viewer,'str'): + if not isinstance(viewer,str): viewer = json.dumps(viewer) - rendered = string_template_render(desc.get('viewer'), rec) + rendered = string_template_render(viewer, rec) dic = json.loads(rendered) if dic is None: return None - return Factory.Blocks(dic) + blocks = Factory.Blocks() + return blocks.widgetBuild(dic) uitype = desc.get('uitype', 'str') if uitype is None: @@ -91,17 +92,6 @@ class Cell(ButtonBehavior, WidgetCSS, BoxLayout): height = self.row.part.datagrid.rowHeight(), csscls=csscls ) - if not self.row.header and self.desc.get('viewer'): - viewer = self.desc.get('viewer') - blocks = Factory.Blocks() - if isinstance(viewer,str): - l = self.desc.copy() - l['row'] = self.row - viewer = blocks.eval(viewer,l) - if isinstance(viewer,dict): - w = blocks.widgetBuild(viewer) - self.add_widget(w) - return if desc['header']: bl = Text(i18n=True, text=str(desc['value']), font_size=CSize(1),wrap=True, diff --git a/kivyblocks/pagepanel.py b/kivyblocks/pagepanel.py index 1122a91..220eb7a 100644 --- a/kivyblocks/pagepanel.py +++ b/kivyblocks/pagepanel.py @@ -131,12 +131,17 @@ sub-widget's description file format ## """ - def __init__(self, bar_size=2, bar_css='default',csscls='default', - bar_at='top', enable_on_close=False, + def __init__(self, bar_size=2, + bar_css='default', + csscls='default', + singlepage=False, + bar_at='top', + enable_on_close=False, left_menu=None, **kw): print('PagePanel().__init__():', bar_size, bar_at, left_menu) self.bar_size = bar_size self.bar_at = bar_at + self.singlepage = singlepage self.swipe_buffer = [] self.swipe_right = False @@ -276,6 +281,8 @@ sub-widget's description file format self.clear_widgets() if len(self.sub_widgets) > 0: pass + if self.singlepage: + self.sub_widgets = [] self.sub_widgets.append(w) self.show_currentpage() diff --git a/kivyblocks/tree.py b/kivyblocks/tree.py index 6ab875b..60e2a13 100644 --- a/kivyblocks/tree.py +++ b/kivyblocks/tree.py @@ -8,12 +8,14 @@ from kivy.logger import Logger from kivy.graphics import Color, Rectangle, Triangle from kivy.uix.boxlayout import BoxLayout from kivy.uix.label import Label +from kivy.uix.image import AsyncImage from kivy.uix.widget import Widget from kivy.uix.button import ButtonBehavior from kivyblocks.widgetExt import ScrollWidget from kivyblocks.utils import CSize from appPublic.dictObject import DictObject from appPublic.jsonConfig import getConfig +from appPublic.registerfunction import getRegisterFunctionByName from .baseWidget import PressableLabel, Text, HBox, VBox from .color_definitions import getColors from .widget_css import WidgetCSS