Guest User

Untitled

a guest
Jan 17th, 2019
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.30 KB | None | 0 0
  1. from kivy.app import App
  2. from kivy.lang import Builder
  3. from kivy.uix.boxlayout import BoxLayout
  4. from kivy.uix.scatter import Scatter
  5. from kivy.uix.widget import Widget
  6.  
  7. Builder.load_string("""
  8. <MainWidget>
  9. Picture:
  10. size_hint: None, None
  11. width: 500
  12. height: 500
  13.  
  14. canvas.before:
  15. Color:
  16. rgba: 1, 0, 0, 1
  17. Rectangle:
  18. pos: self.pos
  19. size: self.size
  20.  
  21. MyWidget:
  22. size_hint: None, None
  23. width: 200
  24. height: 200
  25. pos: self.parent.right - (self.width/2), self.parent.top - (self.height/2)
  26.  
  27. canvas.before:
  28. Color:
  29. rgba: 0, 1, 0, 1
  30. Rectangle:
  31. pos: self.pos
  32. size: self.size
  33. """)
  34.  
  35. class Picture(Scatter):
  36. def on_touch_down(self, touch):
  37. super(Picture, self).on_touch_down(touch)
  38. print("Picture:" )
  39. print(" self.pos: {}".format(self.pos))
  40. print(" self.size: {}".format(self.size))
  41. print(" touch.pos: {}".format(touch.pos))
  42.  
  43. class MyWidget(Widget):
  44. def on_touch_down(self, touch):
  45. print("MyWidget:")
  46. print(" self.pos: {}".format(self.pos))
  47. print(" self.size: {}".format(self.size))
  48. print(" touch.pos: {}".format(touch.pos))
  49.  
  50.  
  51. class MainWidget(BoxLayout):
  52. def __init__(self, **kwargs):
  53. super(MainWidget, self).__init__(**kwargs)
  54.  
  55.  
  56. class MyApp(App):
  57. def build(self):
  58. return MainWidget()
  59.  
  60.  
  61. if __name__ == '__main__' or __name__ == 'android':
  62. MyApp().run()
Add Comment
Please, Sign In to add comment