This commit is contained in:
yumoqing 2022-01-29 22:09:10 +08:00
parent 656750b1b9
commit 87b17d287f
2 changed files with 7 additions and 4 deletions

View File

@ -58,7 +58,7 @@ class BoxViewer(WidgetReady, BoxLayout):
self.radius = self.options.get('radius',[]) self.radius = self.options.get('radius',[])
self.box_width = CSize(options['boxwidth']) self.box_width = CSize(options['boxwidth'])
self.box_height = CSize(options['boxheight']) self.box_height = CSize(options['boxheight'])
self.viewContainer = VResponsiveLayout(cols=2,box_width=self.box_width) self.viewContainer = VResponsiveLayout(box_width=self.box_width)
if options.get('toolbar'): if options.get('toolbar'):
self.toolbar = Toolbar(options['toolbar']) self.toolbar = Toolbar(options['toolbar'])
lopts = options['dataloader'].copy() lopts = options['dataloader'].copy()

View File

@ -27,10 +27,13 @@ class VResponsiveLayout(ScrollView):
def on_box_width(self, *args): def on_box_width(self, *args):
if not self._inner: if not self._inner:
return return
self._inner.col_default_width = self.box_width if self.box_width <= 1:
self._inner.col_default_width = self.width * self.box_width
else:
self._inner.col_default_width = self.box_width
for w in self._inner.children: for w in self._inner.children:
w.size_hint_x = None w.size_hint_x = None
w.width = self.box_width w.width = self._inner.col_default_width
self.setCols() self.setCols()
def on_orientation(self,o): def on_orientation(self,o):
@ -48,7 +51,7 @@ class VResponsiveLayout(ScrollView):
return a return a
def setCols(self,*args): def setCols(self,*args):
cols = floor(self.width / self.box_width) cols = floor(self.width / self._inner.col_default_width)
if cols < 1: if cols < 1:
cols = 1 cols = 1
self._inner.cols = cols self._inner.cols = cols