This commit is contained in:
yumoqing 2021-04-22 15:52:39 +08:00
parent 7a9cbf194f
commit b4474b5e21
3 changed files with 21 additions and 9 deletions

View File

@ -188,7 +188,9 @@ class Header(WidgetReady, ScrollWidget):
class Body(WidgetReady, ScrollWidget):
def __init__(self,part,**kw):
self.part = part
kw.update({'spacing':self.part.datagrid.linewidth})
super(Body, self).__init__(**kw)
self.size_hint=(1,1)
self.idRow = {}
self.bind(on_scroll_stop=self.part.datagrid.on_scrollstop)
if self.part.freeze_flag:
@ -259,6 +261,7 @@ class DataGridPart(WidgetReady, BoxLayout):
kw['size_hint'] = (1,None)
kw['height'] = self.datagrid.rowHeight()
self.header = None
if not self.datagrid.noheader:
self.header = Header(self,**kw)
self.add_widget(self.header)
@ -274,6 +277,15 @@ class DataGridPart(WidgetReady, BoxLayout):
def addRow(self,id, data):
return self.body.addRow(id, data)
def on_size(self, o, s=None):
if not hasattr(self, 'body'):
return
self.body.size_hint_y = None
if self.header:
self.body.height = self.height - self.header.height
else:
self.body.height = self.height
class DataGrid(WidgetReady, BoxLayout):
"""
@ -408,9 +420,6 @@ class DataGrid(WidgetReady, BoxLayout):
return self.row_height
def calculateShowRows(self,t):
print('body height=',self.normal_part.body.height
,'row_height=',self.rowHeight()
)
self.show_rows = int(self.normal_part.body.height/self.rowHeight())
self.dataloader.setPageRows(self.show_rows)

View File

@ -6,11 +6,14 @@ from kivy.graphics import Color, Ellipse,Rectangle
class ScrollWidget(ScrollView):
def __init__(self,**kw):
super(ScrollWidget,self).__init__(**kw)
super(ScrollWidget,self).__init__()
self.effect_cls = ScrollEffect
self.sized_widgets = []
self._inner = BoxLayout(orientation='vertical',padding=5,
spacing=8,size_hint=(None,None))
kw.update({
'size_hint':(None,None),
'orientation':'vertical'
})
self._inner = BoxLayout(**kw)
self._inner.bind(
minimum_height=self._inner.setter('height'))
self._inner.bind(

View File

@ -69,10 +69,10 @@ class WidgetCSS(object):
self.width = CSize(self.width_cm)
def set_child_fgcolor(self, c):
if not hasattr(c,'fgcolor'):
return
if c.fgcolor:
if not self.fgcolor:
return
if isinstance(c, WidgetCSS):
return
if isinstance(c, TextInput):
c.foreground_color = self.fgcolor
return