This commit is contained in:
yumoqing 2021-05-12 00:55:46 +08:00
parent 34c7c5a6f7
commit a8ea8f332f
3 changed files with 15 additions and 16 deletions

View File

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

View File

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

View File

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