-
-
Save tito/321757 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ConnectionButton(MTWidget): | |
instances = [] | |
def __init__(self, **kwargs): | |
super().__init__(**kwargs) | |
ConnectionButton.instances.append(self) | |
def on_touch_down(self, touch): | |
if not self.collide_point(*touch.pos): | |
return | |
self.connect_touch(touch) | |
def connect_touch(self, touch): | |
def touch_up(touch): | |
for target in ConnectionButton.instances: | |
if target.collide_point(*touch.pos): | |
self.connect(target) | |
def touch_draw(touch): | |
drawLine([touch.userdata['connection_start'], touch.pos]) | |
touch.userdata['connection_start'] = self.to_window(*self.pos) | |
touch.grab(self, up=touch_up) | |
self.connect('on_draw', curry(touch_draw, touch)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment