Skip to content

Commit

Permalink
refactor some of examples
Browse files Browse the repository at this point in the history
  • Loading branch information
gottadiveintopython committed Sep 18, 2023
1 parent 15e8638 commit 2c45418
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
4 changes: 2 additions & 2 deletions examples/reorderable_stacklayout.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'''
When you want to make a :class:`kivy.uix.stacklayout.StackLayout` re-orderable, you may want to disable the
``size_hint`` of each child, or may want to limit the maximum size of each child, otherwise the layout will be messed
up. You can confirm that by commenting/uncommenting the part of ``SampleApp.on_start()``.
``size_hint`` of its children, or may want to limit the maximum size of them, otherwise the layout will be messed
up. You can confirm that by commenting/uncommenting the specified part of ``SampleApp.on_start()``.
'''

from kivy.lang import Builder
Expand Down
7 changes: 5 additions & 2 deletions examples/using_other_widget_as_an_emitter.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
size_hint_x: .1
# Put the board inside a RelativeLayout just to confirm the coordinates are properly transformed.
# It's not necessary for this example to work though.
# This is not necessary for this example to work.
RelativeLayout:
GridLayout:
id: board
Expand Down Expand Up @@ -88,10 +88,13 @@ class Deck(Label):
def on_touch_down(self, touch):
if self.collide_point(*touch.opos):
if (text := next(self.text_iter, None)) is not None:
card = Card(text=text, size=self.board.children[0].size)
card = Card(text=text, size=self._get_cell_size())
card.start_dragging_from_others_touch(self, touch)
return True

def _get_cell_size(self):
return self.board.children[0].size


class SampleApp(App):
def build(self):
Expand Down

0 comments on commit 2c45418

Please sign in to comment.