diff --git a/kivyblocks/dg.py b/kivyblocks/dg.py index fc67ac4..3a90652 100644 --- a/kivyblocks/dg.py +++ b/kivyblocks/dg.py @@ -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) diff --git a/kivyblocks/widgetExt/scrollwidget.py b/kivyblocks/widgetExt/scrollwidget.py index 61b0b7d..75d8c2c 100755 --- a/kivyblocks/widgetExt/scrollwidget.py +++ b/kivyblocks/widgetExt/scrollwidget.py @@ -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( diff --git a/kivyblocks/widget_css.py b/kivyblocks/widget_css.py index ce49c53..6814218 100644 --- a/kivyblocks/widget_css.py +++ b/kivyblocks/widget_css.py @@ -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