Skip to content

Instantly share code, notes, and snippets.

@hansent
Created March 4, 2010 14:47
Show Gist options
  • Save hansent/321756 to your computer and use it in GitHub Desktop.
Save hansent/321756 to your computer and use it in GitHub Desktop.
def draw_connection_in_progress(touch):
drawLine([touch.userdata['connection_start'], touch.pos])
class ConnectionButton(MTWidget):
instances = []
def __init__(self, **kwargs):
super().__init__(**kwargs)
ConnectionButton.instances.append(self)
def check_connection(self, touch):
for target in ConnectionButton.instances:
if target.coolide_point(*touch.pos):
self.connect(target)
def on_touch_down(self, touch):
touch.userdata['connection_start'] = self.to_window(*self.pos)
touch.push_handler(draw=draw_connection_in_progress)
touch.push_handler(up=self.check_connection())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment