This commit is contained in:
yumoqing 2022-12-16 18:14:59 +08:00
parent 8e9719ac57
commit 263636779b
9 changed files with 38 additions and 23 deletions

BIN
kivyblocks/imgs/.DS_Store vendored Normal file

Binary file not shown.

BIN
kivyblocks/imgs/photo.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

View File

@ -4,15 +4,16 @@ from kivy.uix.boxlayout import BoxLayout
from kivy.uix.button import Button from kivy.uix.button import Button
from kivy.uix.label import Label from kivy.uix.label import Label
from kivy.app import App from kivy.app import App
from .utils import CSize from .utils import CSize, SUPER
from .bgcolorbehavior import BGColorBehavior from .widget_css import WidgetCSS
from .ready import WidgetReady from .ready import WidgetReady
class PageContainer(WidgetReady, BGColorBehavior, FloatLayout): class PageContainer(WidgetReady, WidgetCSS, FloatLayout):
def __init__(self,**kw): def __init__(self,**kw):
FloatLayout.__init__(self, **kw) SUPER(PageContainer, self, kw)
BGColorBehavior.__init__(self) # FloatLayout.__init__(self, **kw)
WidgetReady.__init__(self) # BGColorBehavior.__init__(self)
# WidgetReady.__init__(self)
self.show_back = True self.show_back = True
self.pageWidgets = [] self.pageWidgets = []
self.backButton = Button(text='<',size_hint=(None,None), self.backButton = Button(text='<',size_hint=(None,None),

View File

@ -24,18 +24,15 @@ from appPublic.uniqueID import getID
from kivy.uix.tabbedpanel import TabbedPanel, TabbedPanelItem from kivy.uix.tabbedpanel import TabbedPanel, TabbedPanelItem
from kivy.clock import Clock from kivy.clock import Clock
from kivy.factory import Factory from kivy.factory import Factory
from .utils import SUPER
from .widget_css import WidgetCSS
from .bgcolorbehavior import BGColorBehavior class TabsPanel(WidgetCSS, TabbedPanel):
def __init__(self, tabs=[], **options):
class TabsPanel(BGColorBehavior, TabbedPanel):
def __init__(self,color_level=-1,
radius=[],
tabs=[],
**options):
self.tabs_list = tabs self.tabs_list = tabs
TabbedPanel.__init__(self,**options) SUPER(TabsPanel, self, options)
BGColorBehavior.__init__(self,color_level=color_level, # TabbedPanel.__init__(self,**options)
radius=radius) # BGColorBehavior.__init__(self)
Clock.schedule_once(self.add_tabs,0) Clock.schedule_once(self.add_tabs,0)
def newname(self): def newname(self):

View File

@ -1,10 +1,13 @@
import io
from traceback import print_exc from traceback import print_exc
import time import time
import numpy as np import numpy as np
from ffpyplayer.player import MediaPlayer from ffpyplayer.player import MediaPlayer
from ffpyplayer.tools import set_log_callback from ffpyplayer.tools import set_log_callback
from PIL import Image as PILImage
from ffpyplayer.pic import Image as FFImage
from kivy.factory import Factory from kivy.factory import Factory
from kivy.app import App from kivy.app import App
from kivy.core.window import Window from kivy.core.window import Window
@ -12,11 +15,12 @@ from kivy.uix.image import Image
from kivy.uix.widget import Widget from kivy.uix.widget import Widget
from kivy.clock import Clock from kivy.clock import Clock
from kivy.properties import StringProperty, BooleanProperty, \ from kivy.properties import StringProperty, BooleanProperty, \
OptionProperty, NumericProperty OptionProperty, NumericProperty, ListProperty
from kivy.graphics.texture import Texture from kivy.graphics.texture import Texture
from kivy.graphics import Color, Line, Rectangle from kivy.graphics import Color, Line, Rectangle
from kivyblocks.ready import WidgetReady from kivyblocks.ready import WidgetReady
from kivyblocks.baseWidget import Running from kivyblocks.baseWidget import Running
from appPublic.registerfunction import getRegisterFunctionByName
class VideoBehavior(object): class VideoBehavior(object):
v_src = StringProperty(None) v_src = StringProperty(None)
@ -31,6 +35,7 @@ class VideoBehavior(object):
volume = NumericProperty(-1) volume = NumericProperty(-1)
timeout = NumericProperty(5) timeout = NumericProperty(5)
auto_play=BooleanProperty(True) auto_play=BooleanProperty(True)
prehandlers = ListProperty([])
repeat=BooleanProperty(False) repeat=BooleanProperty(False)
in_center_focus = BooleanProperty(False) in_center_focus = BooleanProperty(False)
renderto = OptionProperty('foreground', options=['background', 'foreground', 'cover']) renderto = OptionProperty('foreground', options=['background', 'foreground', 'cover'])
@ -62,6 +67,15 @@ class VideoBehavior(object):
for k, v in kwargs.items(): for k, v in kwargs.items():
setattr(self, k, v) setattr(self, k, v)
def prehandle(self, img):
if len(self.prehandlers) == 0:
return img
for her in self.prehandlers:
f = getRegisterFunctionByName(her)
if f:
img = f(img)
return img
def video_blocked(self, *args): def video_blocked(self, *args):
self._play_stop() self._play_stop()
self.on_v_src(None, None) self.on_v_src(None, None)
@ -298,6 +312,7 @@ class VideoBehavior(object):
self.is_black = True self.is_black = True
def show_yuv420(self, img): def show_yuv420(self, img):
img = self.prehandle(img)
w, h = img.get_size() w, h = img.get_size()
w2 = int(w / 2) w2 = int(w / 2)
h2 = int(h / 2) h2 = int(h / 2)
@ -328,6 +343,7 @@ class VideoBehavior(object):
# self.texture = texture # self.texture = texture
def show_others(self, img): def show_others(self, img):
img = self.prehandle(img)
w, h = img.get_size() w, h = img.get_size()
texture = Texture.create(size=(w, h), colorfmt='rgb') texture = Texture.create(size=(w, h), colorfmt='rgb')
texture.blit_buffer( texture.blit_buffer(

View File

@ -52,7 +52,7 @@ class WidgetCSS(object):
bg_func = Rectangle bg_func = Rectangle
def on_canvas(self, o, s): def on_canvas(self, o, s):
#Logger.info('WidgetCSS:on_canvas():%s',self.__class__.__name__) Logger.info('WidgetCSS:on_canvas():%s',self.__class__.__name__)
self.set_background_color() self.set_background_color()
def on_size(self, o, s): def on_size(self, o, s):
@ -164,8 +164,8 @@ class WidgetCSS(object):
self.set_background_color() self.set_background_color()
def set_background_color(self, *args): def set_background_color(self, *args):
if self.width == 100 and self.height == 100: # if self.width == 100 and self.height == 100:
return # return
if not self.bgcolor: if not self.bgcolor:
return return
if not self.canvas: if not self.canvas:

View File

@ -4,7 +4,7 @@
"size_hint":[0.5, 0.5], "size_hint":[0.5, 0.5],
"ModalBehavior":{ "ModalBehavior":{
"auto_open":true, "auto_open":true,
"position":"tr", "anchor":"br",
"auto_dismiss":true "auto_dismiss":true
} }
}, },

View File

@ -2,8 +2,9 @@
"widgettype":"BoxLayout", "widgettype":"BoxLayout",
"options":{ "options":{
"VideoBehavior":{ "VideoBehavior":{
"v_src":"/home/ymq/c/songs/alone-braver.mkv", "v_src":"/Volumes/data/share/songs/alone-braver.mkv",
"renderto":"background", "renderto":"background",
"repeat":true,
"auto_play":true "auto_play":true
} }
}, },

View File

@ -2,7 +2,7 @@
"widgettype":"BoxLayout", "widgettype":"BoxLayout",
"options":{ "options":{
"VideoBehavior":{ "VideoBehavior":{
"v_src":"/home/ymq/c/songs/undr-sky.mkv", "v_src":"/home/ymq/d/share/songs/undr-sky.mkv",
"renderto":"background", "renderto":"background",
"auto_play":true "auto_play":true
} }