bugfix
This commit is contained in:
parent
11d02d218e
commit
39bd3e0791
@ -1,4 +1,5 @@
|
|||||||
import time
|
import time
|
||||||
|
import ujson as json
|
||||||
from kivy.uix.gridlayout import GridLayout
|
from kivy.uix.gridlayout import GridLayout
|
||||||
from kivy.uix.boxlayout import BoxLayout
|
from kivy.uix.boxlayout import BoxLayout
|
||||||
from kivy.uix.scrollview import ScrollView
|
from kivy.uix.scrollview import ScrollView
|
||||||
@ -14,6 +15,7 @@ from kivy.factory import Factory
|
|||||||
from appPublic.dictObject import DictObject
|
from appPublic.dictObject import DictObject
|
||||||
from appPublic.timecost import TimeCost
|
from appPublic.timecost import TimeCost
|
||||||
from appPublic.uniqueID import getID
|
from appPublic.uniqueID import getID
|
||||||
|
from appPublic.myTE import string_template_render
|
||||||
|
|
||||||
from .utils import CSize, setSizeOptions, loading, loaded, absurl, alert
|
from .utils import CSize, setSizeOptions, loading, loaded, absurl, alert
|
||||||
from .baseWidget import Text
|
from .baseWidget import Text
|
||||||
@ -24,7 +26,20 @@ from .toolbar import Toolbar
|
|||||||
from .bgcolorbehavior import BGColorBehavior
|
from .bgcolorbehavior import BGColorBehavior
|
||||||
|
|
||||||
def field_widget(desc, rec):
|
def field_widget(desc, rec):
|
||||||
|
viewer = desc.get('viewer')
|
||||||
|
if viewer:
|
||||||
|
if not isinstance(viewer,'str'):
|
||||||
|
viewer = json.dumps(viewer)
|
||||||
|
rendered = string_template_render(desc.get('viewer'), rec)
|
||||||
|
dic = json.loads(rendered)
|
||||||
|
print('field_widget(), dic=', dic)
|
||||||
|
if dic is None:
|
||||||
|
return None
|
||||||
|
return Factory.Blocks(dic)
|
||||||
|
|
||||||
uitype = desc.get('uitype', 'str')
|
uitype = desc.get('uitype', 'str')
|
||||||
|
if uitype is None:
|
||||||
|
uitype = desc.get('datatype')
|
||||||
if uitype in [ 'str' 'date', 'time', 'timestamp' ]:
|
if uitype in [ 'str' 'date', 'time', 'timestamp' ]:
|
||||||
return BLabel(text = str(desc['value']),
|
return BLabel(text = str(desc['value']),
|
||||||
font_size=CSize(1),wrap=True,
|
font_size=CSize(1),wrap=True,
|
||||||
@ -41,11 +56,13 @@ def field_widget(desc, rec):
|
|||||||
font_size=CSize(1), wrap=True,
|
font_size=CSize(1), wrap=True,
|
||||||
halign='right', valign='middle'
|
halign='right', valign='middle'
|
||||||
)
|
)
|
||||||
|
|
||||||
return BLabel(text = str(desc['value']),
|
return BLabel(text = str(desc['value']),
|
||||||
font_size=CSize(1),wrap=True,
|
font_size=CSize(1),wrap=True,
|
||||||
halign='left', valign='middle'
|
halign='left', valign='middle'
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
class BLabel(ButtonBehavior, Text):
|
class BLabel(ButtonBehavior, Text):
|
||||||
def __init__(self, **kw):
|
def __init__(self, **kw):
|
||||||
ButtonBehavior.__init__(self)
|
ButtonBehavior.__init__(self)
|
||||||
@ -87,6 +104,7 @@ class Cell(BoxLayout):
|
|||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
bl = field_widget(desc,self.row.row_data)
|
bl = field_widget(desc,self.row.row_data)
|
||||||
|
if bl:
|
||||||
self.add_widget(bl)
|
self.add_widget(bl)
|
||||||
bl.bind(on_press=self.cell_press)
|
bl.bind(on_press=self.cell_press)
|
||||||
|
|
||||||
@ -150,7 +168,9 @@ class Header(WidgetReady, BGColorBehavior, ScrollWidget):
|
|||||||
|
|
||||||
def init(self,t):
|
def init(self,t):
|
||||||
rd = [ f.copy() for f in self.part.rowdesc ]
|
rd = [ f.copy() for f in self.part.rowdesc ]
|
||||||
[ f.update({'value':self.part.fields[i]['label']}) for i,f in enumerate(rd) ]
|
[ f.update({'value':self.part.fields[i].get('label', \
|
||||||
|
self.part.fields[i].get('name'))}) \
|
||||||
|
for i,f in enumerate(rd) ]
|
||||||
self.header = Row(self.part,rd,header=True)
|
self.header = Row(self.part,rd,header=True)
|
||||||
self.add_widget(self.header)
|
self.add_widget(self.header)
|
||||||
self.height = self.header.height
|
self.height = self.header.height
|
||||||
|
@ -53,10 +53,29 @@ description file format
|
|||||||
|
|
||||||
def update(self, o, text):
|
def update(self, o, text):
|
||||||
print('text=',text, type(text))
|
print('text=',text, type(text))
|
||||||
|
text = ''.join(text.split('\r'))
|
||||||
|
"""
|
||||||
|
org_boxs = re.findall(r"\n```\n(.*)\n```\n", text)
|
||||||
|
org_boxs_widget = [ \
|
||||||
|
Factory.Blocks().widgetBuild({ \
|
||||||
|
"widgettype":f"Title{level}", \
|
||||||
|
"options":{ \
|
||||||
|
"text":txt, \
|
||||||
|
"size_hint_x":None, \
|
||||||
|
"width":self.width, \
|
||||||
|
"size_hint_y":None, \
|
||||||
|
"markup":True, \
|
||||||
|
"bgcolor":self.options.source_bgcolor, \
|
||||||
|
"wrap":True, \
|
||||||
|
"halign":"left", \
|
||||||
|
"valign":"middle" \
|
||||||
|
} \
|
||||||
|
}) for t in org_boxs ]
|
||||||
|
other_texts = re.split(r"\n```\n(.*)\n```\n", text)
|
||||||
|
"""
|
||||||
if not text:
|
if not text:
|
||||||
return
|
return
|
||||||
for l in text.split('\n'):
|
for l in text.split('\n'):
|
||||||
l = ''.join([i for i in l if i != '\r'])
|
|
||||||
self.parse_line(l)
|
self.parse_line(l)
|
||||||
|
|
||||||
def parse_title(self, txt, level):
|
def parse_title(self, txt, level):
|
||||||
|
Loading…
Reference in New Issue
Block a user