Skip to content

Commit

Permalink
Kivy/Android
Browse files Browse the repository at this point in the history
- Demo now waits for animation end before next step.
- Demo command closes menu after selection.
- Hint arrow is kept on top during demo
- Hint arrow fading animation.
  • Loading branch information
lufebe16 committed Jan 4, 2024
1 parent e1b74be commit f6b5672
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 4 deletions.
2 changes: 1 addition & 1 deletion pysollib/kivy/menubar.py
Original file line number Diff line number Diff line change
Expand Up @@ -523,7 +523,7 @@ def buildTree(self, tv, node):
# text='Find Card', command=self.menubar.mFindCard))

tv.add_node(LTreeNode(
text=_('Demo'), command=self.menubar.mDemo))
text=_('Demo'), command=self.auto_close(self.menubar.mDemo)))

# -------------------------------------------
# TBD. How ?
Expand Down
14 changes: 13 additions & 1 deletion pysollib/kivy/tkcanvas.py
Original file line number Diff line number Diff line change
Expand Up @@ -476,6 +476,11 @@ def __init__(self, canvas, *args, **kwargs):

def delete_deferred(self, seconds):
# print('MfxCanvasLine: delete_deferred(%s)' % seconds)
from kivy.animation import Animation
z = 0
t = 'in_expo'
anim = Animation(opacity=z, t=t, d=seconds/1.5)
anim.start(self.line)
Clock.schedule_once(lambda dt: self.delete(), seconds)

def delete(self):
Expand Down Expand Up @@ -783,11 +788,18 @@ def yview(self):
def tag_raise(self, itm, abitm=None):
# print('MfxCanvas: tag_raise, itm=%s, aboveThis=%s' % (itm, abitm))

def findTop(itm):
t = type(itm)
for c in self.children:
if type(c) is t:
return self.children.index(c)
return 0

if (itm is not None):
if (abitm is None):
# print('MfxCanvas: tag_raise: to top')
self.remove_widget(itm)
self.add_widget(itm)
self.add_widget(itm, index=findTop(itm))
else:
# print('MfxCanvas: tag_raise: to specified position')
self.remove_widget(itm)
Expand Down
14 changes: 12 additions & 2 deletions pysollib/kivy/tkutil.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,12 +180,22 @@ def unbind_destroy(widget):
# * timer wrapper - Tkinter doesn't properly delete all commands
# ************************************************************************


def after(widget, ms, func, *args):
# print('tkutil: after(%s, %s, %s, %s)' % (widget, ms, func, args))
if (ms == 'idle'):
print('demo use')
Clock.schedule_once(lambda dt: func(), 1.0)

def mkcb(func):
def cb():
Clock.schedule_once(lambda dt: func(), 0.5)
return cb

from pysollib.kivy.LApp import LAnimationManager
if LAnimationManager.checkRunning():
# run after animation terminated
LAnimationManager.addEndCallback(mkcb(func))
else:
Clock.schedule_once(lambda dt: func(), 0.5)
elif (isinstance(ms, int)):
# print('ms: play timer (accounting)')
# Clock.schedule_once(lambda dt: func(), float(ms)/1000.0)
Expand Down

0 comments on commit f6b5672

Please sign in to comment.