From 7e3d2f2a8ca07ea54fdde6cd12d065ffb9b89c28 Mon Sep 17 00:00:00 2001 From: yumoqing Date: Wed, 3 Jun 2020 11:23:34 +0800 Subject: [PATCH] bugfix --- kivyblocks/baseWidget.py | 7 +++++-- kivyblocks/blocksapp.py | 19 +++++++++++++------ kivyblocks/pagescontainer.py | 3 ++- kivyblocks/threadcall.py | 7 ++++--- kivyblocks/vplayer.py | 15 +++++++-------- 5 files changed, 31 insertions(+), 20 deletions(-) diff --git a/kivyblocks/baseWidget.py b/kivyblocks/baseWidget.py index 2bad48e..a473775 100755 --- a/kivyblocks/baseWidget.py +++ b/kivyblocks/baseWidget.py @@ -125,7 +125,10 @@ class FILEDataHandler(EventDispatcher): for i in range(self.page_rows): try: r = self.files[page * self.page_rows + i] - d['rows'].append({'filename':r}) + d['rows'].append({'filename':r, + 'id':r, + 'url':r + }) except: break self.dispatch('on_success',d) @@ -154,7 +157,7 @@ class HTTPDataHandler(EventDispatcher): pass def onSuccess(self,o,v): - print(__file__,'onSuccess():v=',v) + # print(__file__,'onSuccess():v=',v) self.dispatch('on_success',v) def onError(self,o,e): diff --git a/kivyblocks/blocksapp.py b/kivyblocks/blocksapp.py index b7ee0fe..254a8af 100644 --- a/kivyblocks/blocksapp.py +++ b/kivyblocks/blocksapp.py @@ -6,6 +6,7 @@ import signal from appPublic.jsonConfig import getConfig from appPublic.folderUtils import ProgramPath +from kivy.factory import Factory from kivy.config import Config from kivy.metrics import sp,dp,mm from kivy.core.window import WindowBase, Window @@ -107,13 +108,19 @@ def appBlocksHack(app): class BlocksApp(App): def build(self): + appBlocksHack(self) root = PageContainer() x = None config = getConfig() - x = self.blocks.widgetBuild(config.root) - if x is None: - alert(str(self.config.root)+': cannt build widget') - return root - root.add_widget(x) + blocks = Factory.Blocks() + blocks.bind(on_built=self.addTopWidget) + blocks.bind(on_error=self.showError) + blocks.widgetBuild(config.root) return root - + + def addTopWidget(self,o,w): + self.root.add_widget(w) + + def showError(self,o,e): + alert(str(self.config.root)+': cannt build widget') + diff --git a/kivyblocks/pagescontainer.py b/kivyblocks/pagescontainer.py index 43de520..244ed88 100644 --- a/kivyblocks/pagescontainer.py +++ b/kivyblocks/pagescontainer.py @@ -12,7 +12,7 @@ class PageContainer(FloatLayout): self.pageWidgets = [] self.backButton = Button(text='<',size_hint=(None,None), font_size=CSize(1), - height=CSize(1.8),width=CSize(1.8)) + height=CSize(1.8),width=CSize(4)) self.backButton.bind(on_press=self.previous) Window.bind(size=self.on_window_size) @@ -36,6 +36,7 @@ class PageContainer(FloatLayout): if self.show_back: return super(PageContainer,self).add_widget(self.backButton) + self.backButton.text = '<%d' % len(self.pageWidgets) self.show_back = True def showLastPage(self): diff --git a/kivyblocks/threadcall.py b/kivyblocks/threadcall.py index 4d4c404..aa50f1e 100644 --- a/kivyblocks/threadcall.py +++ b/kivyblocks/threadcall.py @@ -1,6 +1,7 @@ import time from threading import Thread, Lock, BoundedSemaphore import requests +from functools import wraps from kivy.event import EventDispatcher from kivy.clock import Clock @@ -101,13 +102,13 @@ class HttpClient: headers.update({'session':sessionid}) elif app.getAuthHeader(): headers.update(app.getAuthHeader()) - print('headers=',headers) + # print('headers=',headers) if method in ['GET']: req = requests.Request(method,url, - params=params,headers=headers) + params=params,headers=headers,verify=False) else: req = requests.Request(method,url, - data=params,files=files,headers=headers) + data=params,files=files,headers=headers,verify=False) prepped = self.s.prepare_request(req) resp = self.s.send(prepped) if resp.status_code == 200: diff --git a/kivyblocks/vplayer.py b/kivyblocks/vplayer.py index 83381a9..43c5f91 100644 --- a/kivyblocks/vplayer.py +++ b/kivyblocks/vplayer.py @@ -70,14 +70,13 @@ class BaseVPlayer(FloatLayout, SwipeBehavior): self.setSource(vfile) def positionChanged(self,o,v): - pass + if self.muteFlg: + self._video.volume = 0 def playVideo(self,o=None,v=None): # print('-------------VPlayer():playVideo()') self._video.state = 'play' self.nextdir = None - if self.muteFlg: - self.setVolume(None,0) def setSource(self,s): self.stop() @@ -123,8 +122,6 @@ class BaseVPlayer(FloatLayout, SwipeBehavior): def on_state(self,o=None,v=None): if self._video.state == 'play': Window.allow_screensaver = False - if self.muteFlg: - self.setVolume(None,0) else: Window.allow_screensaver = True if self._video.state == 'stop': @@ -203,6 +200,10 @@ class BaseVPlayer(FloatLayout, SwipeBehavior): def setVolume(self,obj,v): self._video.volume = v + if v >= 0.01: + self.muteFlg = False + else: + self.muteFlg = True def setPosition(self,obj,v): self._video.seek(v) @@ -251,16 +252,14 @@ class OSCController: class VPlayer(BaseVPlayer): def __init__(self,vfile=None, loop=False,mute=False, opbar=True): - super().__init__(vfile=vfile,loop=loop,mute=mute) self.opbar = opbar self.menubar = None self._popup = None self.menu_status = False self.manualMode = False self.pb = None + super().__init__(vfile=vfile,loop=loop,mute=mute) self._video.bind(on_touch_down=self.show_hide_menu) - if self.loop: - self.eos = 'loop' def totime(self,dur): h = dur / 3600