From 08f34c65e7ecbaf688fe59cae454b30ddcadce5e Mon Sep 17 00:00:00 2001 From: yumoqing Date: Sun, 12 Jul 2020 08:42:42 +0800 Subject: [PATCH] 'bugfix --- kivyblocks/blocks.py | 23 ++++++++++++++++++----- kivyblocks/vplayer.py | 18 ++++++++++++------ 2 files changed, 30 insertions(+), 11 deletions(-) diff --git a/kivyblocks/blocks.py b/kivyblocks/blocks.py index 3bf70b4..66bcb27 100755 --- a/kivyblocks/blocks.py +++ b/kivyblocks/blocks.py @@ -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,14 +182,16 @@ 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() + print('Exception .... ',e,s) + print_exc() return s def arrayValueExpr(self,arr:list,localnamespace:dict={}): @@ -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) diff --git a/kivyblocks/vplayer.py b/kivyblocks/vplayer.py index 43c5f91..e426cb5 100644 --- a/kivyblocks/vplayer.py +++ b/kivyblocks/vplayer.py @@ -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