This commit is contained in:
yumoqing 2021-10-24 11:06:09 +08:00
parent edae551012
commit d357147625
2 changed files with 21 additions and 24 deletions

View File

@ -109,8 +109,15 @@ class BoxViewer(WidgetReady, BoxLayout):
idx = -1 idx = -1
recs1 = recs[:self.show_rows] recs1 = recs[:self.show_rows]
recs2 = recs[self.show_rows:] recs2 = recs[self.show_rows:]
self._fbo = Fbo(size=self.size)
with self._fbo:
self._background_color = Color(0,0,0,1)
self._background_rect = Rectangle(size=self.size)
for r in recs1: for r in recs1:
self.showObject(widgets, r, index=idx) self.showObject(widgets, r, index=idx)
with self.canvas:
self._fbo_rect = Rectangle(size=self.size,
texture=self._fbo.texture)
data['widgets'] = widgets data['widgets'] = widgets
data['idx'] = idx data['idx'] = idx
@ -124,8 +131,15 @@ class BoxViewer(WidgetReady, BoxLayout):
idx = data['idx'] idx = data['idx']
widgets = data['widgets'] widgets = data['widgets']
self._fbo = Fbo(size=self.size)
with self._fbo:
self._background_color = Color(0,0,0,1)
self._background_rect = Rectangle(size=self.size)
for r in recs: for r in recs:
self.showObject(widgets, r, index=idx) self.showObject(widgets, r, index=idx)
with self.canvas:
self._fbo_rect = Rectangle(size=self.size,
texture=self._fbo.texture)
self.subwidgets += widgets self.subwidgets += widgets

View File

@ -333,16 +333,6 @@ class DataGrid(WidgetReady, BoxLayout):
options['orientation'] = 'vertical' options['orientation'] = 'vertical'
BoxLayout.__init__(self, orientation='vertical') BoxLayout.__init__(self, orientation='vertical')
WidgetReady.__init__(self) WidgetReady.__init__(self)
"""
self._fbo = Fbo(size=self.size)
with self._fbo:
self._background_color = Color(0,0,0,1)
self._background_rect = Rectangle(size=self.size)
with self.canvas:
self._fbo_rect = Rectangle(size=self.size,
texture=self._fbo.texture)
"""
self.select_rowid = None self.select_rowid = None
self.options = options self.options = options
self.rowheight = None self.rowheight = None
@ -390,20 +380,6 @@ class DataGrid(WidgetReady, BoxLayout):
self.tailer_widgets = {} self.tailer_widgets = {}
self.build_tailer(self.options.get('tailer')) self.build_tailer(self.options.get('tailer'))
"""
def add_widget(self, widget, *args):
canvas = self.canvas
self.canvas = self._fbo
super(DataGrid, self).add_widget(widget, *args)
self.canvas = canvas
def remove_widget(self, widget,*args):
canvas = self.canvas
self.canvas = self._fbo
super(DataGrid, self).remove_widget(widget, *args)
self.canvas = canvas
"""
def build_tailer(self, tailer_desc): def build_tailer(self, tailer_desc):
kw = tailer_desc.get('options', {}) kw = tailer_desc.get('options', {})
kw.update({ kw.update({
@ -546,9 +522,16 @@ class DataGrid(WidgetReady, BoxLayout):
page = data['page'] page = data['page']
idx = data['idx'] idx = data['idx']
ids = data['ids'] ids = data['ids']
self._fbo = Fbo(size=self.size)
with self._fbo:
self._background_color = Color(0,0,0,1)
self._background_rect = Rectangle(size=self.size)
for r in recs: for r in recs:
id = self.addRow(r,index=idx) id = self.addRow(r,index=idx)
ids.append(id) ids.append(id)
with self.canvas:
self._fbo_rect = Rectangle(size=self.size,
texture=self._fbo.texture)
self.dataloader.bufferObjects(page,ids) self.dataloader.bufferObjects(page,ids)
x = self.dataloader.getLocater() x = self.dataloader.getLocater()
self.locater(x) self.locater(x)