本文整理汇总了Python中kivy.uix.scatter.Scatter.on_touch_up方法的典型用法代码示例。如果您正苦于以下问题:Python Scatter.on_touch_up方法的具体用法?Python Scatter.on_touch_up怎么用?Python Scatter.on_touch_up使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类kivy.uix.scatter.Scatter
的用法示例。
在下文中一共展示了Scatter.on_touch_up方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: on_touch_up
# 需要导入模块: from kivy.uix.scatter import Scatter [as 别名]
# 或者: from kivy.uix.scatter.Scatter import on_touch_up [as 别名]
def on_touch_up (self, touch):
# calls same function in it's ancestor, and slides the workspace
Scatter.on_touch_up(self, touch)
if not 'markerid' in touch.profile:
return
hand_id = int(touch.fid / self.hand_gesture_offset)
gesture_id = touch.fid % self.hand_gesture_offset
self.canvas.clear()
self.draw()
"""
" starts sliding "
"""
if ('initial' in touch.ud) and touch.ud['initial'] != None and self.object_moving and hand_id != self.my_object.owner_id and self.x <= 0 and ((-1*self.x) % self.single_width() == 0):
print 'about to slide'
current = self.current_workspace()
if touch.ud['initial'] > touch.x:
if abs(touch.ud['initial'] - touch.x) > self.slide_threshold:
current = current + 1
if current >= len(self.frames):
current = len(self.frames) - 1
else:
self.workspace_slide_event()
else:
if abs(touch.ud['initial'] - touch.x) > self.slide_threshold:
current = current - 1
if current < 0:
current = 0
else:
self.workspace_slide_event()
self.slide(current)
touch.ud['initial'] = None
return False
示例2: on_touch_up
# 需要导入模块: from kivy.uix.scatter import Scatter [as 别名]
# 或者: from kivy.uix.scatter.Scatter import on_touch_up [as 别名]
def on_touch_up(self, touch):
"""
Defines action whe the criterion is touched up
:param touch: the touch point (position, type of touch, ...)
"""
if not self.destroyed:
from ZoneUtilisateur import ZoneUtilisateur
if self.collide_point(touch.x, touch.y) and self.parent is not None and self.support != "tablette" and not self.validated:
for child in self.parent.children:
if child.__class__ == ZoneUtilisateur and child.collide_point(self.center[0], self.center[1]) and child.is_connected():
data = '{"Criterion" : "' + self.texte + '", "IdUser" : "' + str(
self.createur.identifier) + '", "TextType" : "' + self.text_type + '", "Links" : ['
for link in self.links:
data += '{ "IdImage" :"' + str(link.id_img) + '",'
data += '"SrcImage" : "' + self.parent.get_animal(link.id_img).src_image + '",'
data += '"IdUser" :"' + str(link.id_usr) + '",'
data += '"Distance" :"' + str(link.distance) + '",'
data += '"Angle" :"' + str(link.angle) + '"},'
if len(self.links) > 0:
data = data[:-1]
data += '], "Fusionneurs" : ['
for participants in self.fusionneurs:
data += '{"IdUser" : "' + str(participants.identifier) + '"},'
if len(self.fusionneurs) > 0 :
data = data[:-1]
data += ']}\n'
self.parent.server.send_msg(data, child.user.socket)
self.canvas.clear()
self.destroyed = True
self.parent.criterions.remove(self)
self.parent.remove_widget(self)
Scatter.on_touch_up(self, touch)
示例3: on_touch_up
# 需要导入模块: from kivy.uix.scatter import Scatter [as 别名]
# 或者: from kivy.uix.scatter.Scatter import on_touch_up [as 别名]
def on_touch_up (self, touch):
# calls same function in it's ancestor, and slides the workspace
Scatter.on_touch_up(self, touch)
"""
" starts sliding "
"""
if ('initial' in touch.ud) and touch.ud['initial'] != None and (not self.object_moving or touch.uid != self.my_object.owner_id) and self.x <= 0 and ((-1*self.x) % self.single_width() == 0) and self.enable_slide:
current = self.current_workspace()
# self.current_trial.ws_switch += 1
#if self.x <= 0 and (-1*self.x) % self.single_width() != 0:
if touch.ud['initial'] > touch.x:
if abs(touch.ud['initial'] - touch.x) > self.slide_threshold:
current = current + 1
if current >= len(self.frames):
current = len(self.frames) - 1
else:
self.workspace_slide_event()
else:
if abs(touch.ud['initial'] - touch.x) > self.slide_threshold:
current = current - 1
if current < 0:
current = 0
else:
self.workspace_slide_event()
self.slide(current)
touch.ud['initial'] = None
# if touch lefts from a target trigger that target
"""
" release "
"""
if self.sliding and self.object_moving and touch.uid == self.my_object.owner_id:
self.stop_slide = True
if self.object_moving and touch.uid == self.my_object.owner_id and ((-1*self.x) % self.single_width() == 0):
self.object_moving = False
self.play_release_sound()
tx = touch.x
ty = touch.y
tx = self.push_out_border (tx, self.single_width())
ty = self.push_out_border (ty, self.height)
self.my_object.relocate(tx - self.x, ty - self.y)
self.object_released_event()
# if object is released on target, swap them and make a new target
if self.my_target.collide_point(touch.x-self.x, touch.y-self.y):
"""
" collide "
"""
self.object_collide_event()
self.swap_object_target()
self.play_collide_sound()
else:
self.my_object.move_back()
self.my_object.owner_id = None
# TODO no idea about this - to be removed
if self.my_target != None and self.my_target.collide_point(touch.x-self.x, touch.y-self.y):
self.my_target.dispatch('on_touch_up', touch)
return True
return False
示例4: on_touch_up
# 需要导入模块: from kivy.uix.scatter import Scatter [as 别名]
# 或者: from kivy.uix.scatter.Scatter import on_touch_up [as 别名]
def on_touch_up(self, touch):
"""
Define actions to perform when the token is touched up
:param touch: the touch point (position, type of touch, ...)
"""
if self.collide_point(touch.x, touch.y):
for criterion in self.parent.parent.criterions:
if self.collide_point(criterion.center[0], criterion.center[1]) and not self.collide_widget(
self.parent.parent.get_zone_utilisateur(self.user)):
criterion.validate_by_user(self.id_usr, self.value)
self.parent.parent.update_vote()
self.pos = self.Position
Scatter.on_touch_up(self, touch)
示例5: on_touch_up
# 需要导入模块: from kivy.uix.scatter import Scatter [as 别名]
# 或者: from kivy.uix.scatter.Scatter import on_touch_up [as 别名]
def on_touch_up(self, touch):
try:
self.touches.remove(touch.uid)
if not self.touches and not self.selected:
self.back_animation.start(self)
except:
pass
return Scatter.on_touch_up(self, touch)