This commit is contained in:
yumoqing 2023-10-12 18:29:15 +08:00
parent 313274b376
commit f1e493ca8e
5 changed files with 79 additions and 36 deletions

View File

@ -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

66
kivyblocks/container.py Normal file
View File

@ -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)

View File

@ -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):

View File

@ -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)

View File

@ -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