Skip to content

Instantly share code, notes, and snippets.

@me2beats
Last active October 22, 2019 18:27
Show Gist options
  • Save me2beats/a649648f6aa942fae31bbd8621889ba3 to your computer and use it in GitHub Desktop.
Save me2beats/a649648f6aa942fae31bbd8621889ba3 to your computer and use it in GitHub Desktop.
Shared pattern?
from kivy.app import App
from kivy.lang import Builder
from MyWidget import MyWidget
from kivy.core.window import Window
from Shared import Shared
class MyApp(App):
def build(self):
self.root = MyWidget()
def on_start(self, *_):
Window.bind(mouse_pos=lambda w, p: setattr(Shared, 'mouse_pos', p))
MyApp().run()
from kivy.uix.widget import Widget
from Shared import Shared
class MyWidget(Widget):
def on_touch_down(self, touch):
print (Shared.mouse_pos)
class Shared: pass
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment