This commit is contained in:
yumoqing 2020-07-12 08:42:42 +08:00
parent 97da3d6207
commit 08f34c65e7
2 changed files with 30 additions and 11 deletions

View File

@ -9,7 +9,7 @@ from functools import partial
from appPublic.dictExt import dictExtend
from appPublic.folderUtils import ProgramPath
from appPublic.dictObject import DictObject
from appPublic.Singleton import SingletonDecorator
from appPublic.Singleton import SingletonDecorator, GlobalEnv
from appPublic.datamapping import keyMapping
from kivy.config import Config
@ -117,6 +117,7 @@ class Blocks(EventDispatcher):
self.action_id = 0
self.register_event_type('on_built')
self.register_event_type('on_failed')
self.env = GlobalEnv()
def register_widget(self,name,widget):
globals()[name] = widget
@ -158,6 +159,7 @@ class Blocks(EventDispatcher):
g['__builtins__']['__import__'] = None
g['__builtins__']['__loader__'] = None
g['__builtins__']['open'] = None
g.update(self.env)
return eval(s,g,l)
@ -180,12 +182,14 @@ class Blocks(EventDispatcher):
def strValueExpr(self,s:str,localnamespace:dict={}):
if not s.startswith('py::'):
print('normal value')
return s
s = s[4:]
try:
v = self.eval(s[4:],localnamespace)
print('return result')
return v
except Exception as e:
if s.startswith('CSize'):
print('Exception .... ',e,s)
print_exc()
return s
@ -227,11 +231,18 @@ class Blocks(EventDispatcher):
return d
def valueExpr(self,obj,localnamespace={}):
if type(obj) == type(''):
print('1')
return self.strValueExpr(obj,localnamespace)
if type(obj) == type([]):
print('2')
return self.arrayValueExpr(obj,localnamespace)
if type(obj) in [ type({}), type(DictObject) ]:
if type(obj) == type({}):
print('3')
return self.dictValueExpr(obj,localnamespace)
if isinstance(obj,DictObject):
print('4')
return self.dictValueExpr(obj,localnamespace)
print('5',type(obj))
return obj
def __build(self,desc:dict,ancestor=None):
@ -427,7 +438,9 @@ class Blocks(EventDispatcher):
}
"""
def doit(desc):
Logger.info("blocks:%s",str(desc))
desc = self.valueExpr(desc)
Logger.info("blocks:%s",str(desc))
try:
widget = self.__build(desc,ancestor=ancestor)
self.dispatch('on_built',widget)

View File

@ -38,11 +38,10 @@ logger_func = {'quiet': Logger.critical, 'panic': Logger.critical,
othersplatforms=['ios','android']
class BaseVPlayer(FloatLayout, SwipeBehavior):
class BaseVPlayer(FloatLayout):
fullscreen = BooleanProperty(False)
def __init__(self,vfile=None,loop=None,mute=False):
FloatLayout.__init__(self)
SwipeBehavior.__init__(self)
self.loop = loop
self.muteFlg = mute
self.register_event_type('on_source_error')
@ -61,8 +60,8 @@ class BaseVPlayer(FloatLayout, SwipeBehavior):
if loop:
self.eos = 'loop'
self.bind(on_swipe_down=self.previous)
self.bind(on_swipe_up=self.next)
# self.bind(on_swipe_down=self.previous)
# self.bind(on_swipe_up=self.next)
set_log_callback(self.ffplayerLog)
if hasattr(self._video._video, '_ffplayer'):
self.ffplayer = self._video._video._ffplayer
@ -227,7 +226,14 @@ class BaseVPlayer(FloatLayout, SwipeBehavior):
def __del__(self):
self.stop()
class OSCController:
class Swipe_VPlayer(BaseVPlayer, SwipeBehavior):
def __init__(self,vfile=None, loop=False, mute=False):
BaseVPlayer.__init__(self,vfile=vfile, loop=loop, mute=mute)
SwipeBehavior.__init__(self)
self.bind(on_swipe_down=self.previous)
self.bind(on_swipe_up=self.next)
class OSC_VPlayer(BaseVPlayer):
def __init__(self,ip,port,vfile=None):
self.ip = ip
self.port = port
@ -250,7 +256,7 @@ class OSCController:
def map(self,p,f):
self.dispatcher.map(p,f,None)
class VPlayer(BaseVPlayer):
class VPlayer(Swipe_VPlayer):
def __init__(self,vfile=None, loop=False,mute=False, opbar=True):
self.opbar = opbar
self.menubar = None