Advertisement
Guest User

Untitled

a guest
Jan 22nd, 2020
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.06 KB | None | 0 0
  1. from kivy.uix.boxlayout import BoxLayout
  2. from kivy.uix.widget import Widget
  3. import functools
  4.  
  5. BLANK_ROW = functools.partial(Widget)
  6. ROWS_IN_LEDGER = 10 # TODO: make this dependent on height
  7.  
  8.  
  9. class LedgerLayout(BoxLayout):
  10. child_widgets: list
  11.  
  12. def __init__(self, *args, **kwargs):
  13. super(LedgerLayout, self).__init__(
  14. *args,
  15. orientation='vertical',
  16. **kwargs
  17. )
  18.  
  19. self.child_widgets = []
  20.  
  21. # initialize with blank rows
  22. for _ in range(ROWS_IN_LEDGER):
  23. self.add_widget(BLANK_ROW())
  24.  
  25. def add_widget(self, widget, *args, **kwargs):
  26. if ROWS_IN_LEDGER == len(self.child_widgets):
  27. super(LedgerLayout, self).remove_widget(self.child_widgets[0])
  28. self.child_widgets = self.child_widgets[1:]
  29.  
  30. super(LedgerLayout, self).add_widget(widget, *args, **kwargs)
  31. self.child_widgets.append(widget)
  32.  
  33. def click(self):
  34. print('click')
  35.  
  36. def buttonImage(self):
  37. return 'assets/graphics/clay.png'
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement