修改 qsl4ahelper.fullscreenwrapper2.py —— 本次內容不是非常具體,但懂的話,會很快處理完成。
1、添加Timer並事件
1.1、在Layout 構造中添加
#觸發時間間隔
self.Interval=0
#觸發回調函數
self.TimeTick=None
#是否起作用
self.TimeEnable=False
1.2、在FullScreenWrapper2App中,處理Timer
t0 = time.time()
......
if None==evt:
if (cls.mlayout.Interval>0) and (cls.mlayout.TimeTick!=None) and cls.mlayout.TimeEnable:
if time.time()-cls.mlayout.Interval>t0:
cls.mlayout.TimeTick()
t0 = time.time()
continue
1.3、使用的地方,就容易了。
def ShowInfo():
print(timw.time())
def initialize():
MyScreen.Interval=0.5 #觸發間隔
MyScreen.TimeTick=ShowInfo #註冊回調
...............
MyScreen.TimeEnable=True #啓用
..............
MyScreen.TimeEnable=False #停用
2、其它修改,增加容錯
3、案例
做的簡易音樂播放,指定目錄中的mp3逐首播放、循環,,,,參考了B站的up主 “乘着船” 的文章。。。。