diff --git a/kivyblocks/boxViewer.py b/kivyblocks/boxViewer.py index 230a81a..a6be19c 100755 --- a/kivyblocks/boxViewer.py +++ b/kivyblocks/boxViewer.py @@ -122,15 +122,9 @@ class BoxViewer(VBox): idx = data['idx'] 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: - self.showObject(widgets, r, index=idx) - with self.canvas: - self._fbo_rect = Rectangle(size=self.size, - texture=self._fbo.texture) + with self.fboContext(): + for r in recs: + self.showObject(widgets, r, index=idx) self.subwidgets += widgets diff --git a/kivyblocks/container.py b/kivyblocks/container.py new file mode 100644 index 0000000..a41228c --- /dev/null +++ b/kivyblocks/container.py @@ -0,0 +1,66 @@ +# container is ScrollView with a dataloader +from kivy.uix.scrollview import ScroppView +from kivy.properties import DictProperty, ListProperty, BooleanProperty +from .paging import Paging, RelatedLoader + +class LayoutBuildFailed(Exception): + def __init__(self, desc): + self.desc = desc + + def __str__(self): + return str(self.desc) + + def __expr__(self): + return str(self) + +class Container(ScrollView): + """ + "loader":{ + "page":1, + "rows":60, + "dataurl":"eeee", + "params":{ + k:v + } + }, + """ + loader = DictProperty({}) + data = ListProperty(None) + layout = DictProperty({}) + viewer = DictProperty({}) + extend_x = BooleanProperty(False) + content = None + def __init__(self, **kw): + super(Container, self).__init__(**kw) + self.content = Blocks.widgetBuild(self.layout, self) + if not self.content: + raise LayoutBuildFailed + if self.do_scroll_x: + self.content.bind(minimum_height=layout.setter('width')) + if self.do_scroll_y: + self.content.bind(minimum_height=layout.setter('height')) + super().add_widget(self.content) + self.dataloader = RelatedLoader(target=self, **self.loader) + self.dataloader.bind(on_deletepage=self.delete_page) + self.dataloader.bind(on_pageloaded=self.add_page) + self.dataloader.bind(on_pageloaded=self.update_tailer_info) + self.dataloader.bind(on_newbegin=self.clearRows) + + def delete_page(self, ): + def add_page(self, ): + def clear_records(self, ): + + def add_widget(self, w, index=0): + return self.content.add_widget(w,index=index) + + def remove_widget(self, w): + return self.content.remove_widget(w) + + def clear_widgets(self): + return self.content.clear_widgets() + + def add_data(self, row_data): + desc = self.transfer(row_data) + w = Blocks.widgetBuild(desc) + if w: + self.add_widget(w) diff --git a/kivyblocks/dg.py b/kivyblocks/dg.py index ecce274..0a2b7a3 100755 --- a/kivyblocks/dg.py +++ b/kivyblocks/dg.py @@ -10,7 +10,6 @@ from kivy.uix.gridlayout import GridLayout from kivy.uix.boxlayout import BoxLayout from kivy.uix.scrollview import ScrollView from kivy.uix.label import Label -from kivy.graphics import Fbo from kivy.uix.button import ButtonBehavior from kivy.clock import Clock from kivy.properties import BooleanProperty, StringProperty, \ @@ -533,19 +532,6 @@ class DataGrid(VBox): for r in recs1: id = self.addRow(r,index=idx) ids.append(id) - """ - 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: - id = self.addRow(r,index=idx) - ids.append(id) - with self.canvas: - self._fbo_rect = Rectangle(size=self.size, - texture=self._fbo.texture) - """ - data['idx'] = idx data['ids'] = ids data['data'] = recs2 @@ -557,16 +543,9 @@ class DataGrid(VBox): page = data['page'] idx = data['idx'] 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: id = self.addRow(r,index=idx) ids.append(id) - with self.canvas: - self._fbo_rect = Rectangle(size=self.size, - texture=self._fbo.texture) self._dataloader.bufferObjects(page,ids) x = self._dataloader.getLocater() self.locater(x) @@ -576,12 +555,13 @@ class DataGrid(VBox): self.delRow(id) def addRow(self,data, **kw): - # print('addRow()', data) + # print('#########addRow() ---------') id = getID() f_row = None if self.freeze_part: self.freeze_part.body.addRow(id, data, **kw) self.normal_part.body.addRow(id, data, **kw) + # print('#########addRow()==========') return id def delRow(self,id,**kw): diff --git a/kivyblocks/newvideo.py b/kivyblocks/newvideo.py index a5bf5c5..d94a4e8 100755 --- a/kivyblocks/newvideo.py +++ b/kivyblocks/newvideo.py @@ -19,14 +19,14 @@ class NewVideo(Video): center_screen = BooleanProperty(False) h_pattern = DictProperty(None) def __init__(self, **kw): - hack_mediaplayer() - Video.__init__(self, **kw) - Window.allow_screensaver = False - set_log_callback(self.ffplayerLog) self.register_event_type('on_open_failed') self.register_event_type('on_leave_focus') self.register_event_type('on_enter_focus') self.register_event_type('on_load_success') + hack_mediaplayer() + Video.__init__(self, **kw) + Window.allow_screensaver = False + set_log_callback(self.ffplayerLog) self.bind(source=self.record_start_time) self.bind(loaded=self.on_video_loaded) self.load_status = None @@ -34,6 +34,9 @@ class NewVideo(Video): if self.h_pattern: [ set_headers_pattern(k,v) for k,v in self.h_pattern.items() ] + def on_h_pattern(self, o, v): + pass + def set_patternheaders(self, pattern, headers_str): set_headers_pattern(pattern, headers_str) diff --git a/kivyblocks/videobehavior.py b/kivyblocks/videobehavior.py index 72c15e1..8358384 100755 --- a/kivyblocks/videobehavior.py +++ b/kivyblocks/videobehavior.py @@ -23,6 +23,7 @@ from kivyblocks.baseWidget import Running from appPublic.registerfunction import getRegisterFunctionByName class VideoBehavior(object): + _player = None v_src = StringProperty(None) status = OptionProperty('stop', \ options=['stop', 'play', 'pause']) @@ -41,7 +42,6 @@ class VideoBehavior(object): renderto = OptionProperty('foreground', options=['background', 'foreground', 'cover']) def __init__(self, **kwargs): - self._player = None self.change_size_task = None self._update_task = None self.running = None