This commit is contained in:
yumoqing 2022-11-10 16:47:38 +08:00
parent 8eea5b6882
commit 9e0510d4b7
6 changed files with 686 additions and 630 deletions

View File

@ -422,14 +422,14 @@ class Running(AsyncImage):
self.host_widget.disabled = True
def dismiss(self):
if self.parent:
self.parent.remove_widget(self)
Window.remove_widget(self)
self.host_widget.disabled = False
print('dismiss() called ..')
def set_size(self, *args):
self.size_hint = (None, None)
self.width = CSize(2)
self.height = CSize(2)
self.width = CSize(3)
self.height = CSize(3)
self.center = self.host_widget.center
class PressableImage(ButtonBehavior,AsyncImage):

View File

@ -56,6 +56,8 @@ class Cell(ButtonBehavior, WidgetCSS, BoxLayout):
"""
self.desc = desc
self.row = row
self.part = self.row.part
self.datagrid = self.part.datagrid
super().__init__(size_hint=(None,None),
width = self.desc['width'],
height = self.row.part.datagrid.rowHeight()
@ -72,6 +74,14 @@ class Cell(ButtonBehavior, WidgetCSS, BoxLayout):
else:
self.cell_type = 'data'
bl = UiFactory.build_view_widget(desc,self.row.row_data)
if self.row.header and desc['name'] == '_checkable_action_':
id = self.row.row_data[idfield]
if self.row.part.datagrid.is_checked(id):
bl.setValue(True)
else:
bl.setValue(False)
bl.bind(select_state=self.row.checkable_action)
self.colume_name = desc['name']
if bl:
self.add_widget(bl)
@ -89,6 +99,7 @@ class Row(BoxLayout):
"""
self.part = part
self.datagrid = self.part.datagrid
self.header = header
self.row_data = data
self.row_id = None
@ -103,6 +114,9 @@ class Row(BoxLayout):
self.height = self.part.datagrid.rowHeight()
self.init(0)
def checkable_action(self, o, *args):
self.datagrid.set_checked_rows(self.row_id, o.select_state)
def on_row_press(self, *args):
pass
@ -313,6 +327,7 @@ class DataGrid(VBox):
]
}
"""
checkable = BooleanProperty(False)
row_selected = BooleanProperty(False)
row_normal_css = StringProperty('default')
row_selected_css = StringProperty('default')
@ -326,6 +341,16 @@ class DataGrid(VBox):
fields = ListProperty(None)
tailer = DictProperty(None)
def __init__(self,**options):
if self.checkable:
self.fields.insert(0, {
"name":"_checkable_action_",
"label":" ",
"type":"checkbox",
"width":CSize(2),
"freeze_flag":True
})
self.checked_rows = []
self.select_rowid = None
self.rowheight = None
self.on_sizeTask = None
@ -363,6 +388,11 @@ class DataGrid(VBox):
self.tailer_widgets = {}
self.build_tailer(self.tailer)
def set_checked_rows(self, rowid, flag):
if flag and rowid not in self.checked_ids:
self.checked_ids.append(rowid)
if not flag:
self.checked_ids = [ id for id in self.checked_ids if id !=rowid]
def on_rowpress(self, *args):
print('on_rowpress fire, args=', args)

View File

@ -15,7 +15,7 @@ from kivy.properties import StringProperty, BooleanProperty, \
from kivy.graphics.texture import Texture
from kivy.graphics import Color, Line
from kivyblocks.ready import WidgetReady
from kivyblocks.baseWidget import Running
class FFVideo(WidgetReady, Image):
v_src = StringProperty(None)
@ -28,11 +28,13 @@ class FFVideo(WidgetReady, Image):
duration = NumericProperty(-1)
position = NumericProperty(-1)
volume = NumericProperty(-1)
timeout = NumericProperty(5)
in_center_focus = BooleanProperty(False)
def __init__(self, **kwargs):
self._player = None
self._update_task = None
self.running = None
self.vh_task = None
self.is_black = False
self.videosize = None
@ -43,6 +45,8 @@ class FFVideo(WidgetReady, Image):
self.headers_pattern = {}
super(FFVideo, self).__init__(**kwargs)
self.set_black()
self.start_task = None
self.block_task = None
self.register_event_type('on_frame')
self.register_event_type('on_open_failed')
self.register_event_type('on_leave_focus')
@ -50,8 +54,12 @@ class FFVideo(WidgetReady, Image):
self.register_event_type('on_load_success')
self.register_event_type('on_startplay')
def on_open_failed(self, *args):
pass
def video_blocked(self, *args):
self._play_stop()
self.on_v_src(None, None)
def on_open_failed(self, source):
print(f'{source} open failed')
def on_load_success(self, *args):
pass
@ -195,6 +203,7 @@ class FFVideo(WidgetReady, Image):
self._player.request_channel('audio', action='cycle')
def on_v_src(self, o, src):
# self.running = Running(self)
self.status = 'stop'
self.playing = False
@ -224,6 +233,13 @@ class FFVideo(WidgetReady, Image):
lib_opts=lib_opts)
# self._play_start()
self.status = 'play'
self.start_task = Clock.schedule_once(self.open_failed, self.timeout)
def open_failed(self, *args):
self.dispatch('on_open_failed', self.v_src)
def on_open_failed(self, source):
print(f'{source} open failed')
def file_opened(self, files):
self.v_src = files[0]
@ -366,6 +382,15 @@ class FFVideo(WidgetReady, Image):
self._update_task = Clock.schedule_once(self.do_update, 0)
def do_update(self, *args):
if self.start_task:
self.start_task.cancel()
self.start_task = None
if self.block_task:
self.block_task.cancel()
# if self.running:
# print('runnung dismiss ........')
# self.running.dismiss()
# self.running = None
self.position = self._player.get_pts()
self.volume = self._player.get_volume()
img, t = self.last_frame
@ -376,4 +401,5 @@ class FFVideo(WidgetReady, Image):
self.dispatch('on_frame', self.last_frame)
self.last_frame = None
self.vh_task = Clock.schedule_once(self.video_handle, 0)
self.block_task = Clock.schedule_once(self.video_blocked, self.timeout)

View File

@ -1 +1 @@
__version__ = '0.4.2'
__version__ = '0.4.3'