Skip to content

Instantly share code, notes, and snippets.

@kived
Created April 11, 2016 20:16
Show Gist options
  • Save kived/8bd465544f6c7f554842b3e8f1e30be2 to your computer and use it in GitHub Desktop.
Save kived/8bd465544f6c7f554842b3e8f1e30be2 to your computer and use it in GitHub Desktop.
Kivy: auto-sized dialog
<AppDialog>:
size_hint: 1, None
height: grid.minimum_height
GridLayout:
id: grid
size_hint_x: 0.8
size_hint_y: None
height: self.minimum_height
on_height: root._align_center()
cols: 1
padding: 0, dp(24)
spacing: dp(16)
class AppDialog(ModalView):
def add_widget(self, *args, **kwargs):
if self.children:
return self.children[0].add_widget(*args, **kwargs)
return super(AppDialog, self).add_widget(*args, **kwargs)
def remove_widget(self, *args, **kwargs):
if self.children:
return self.children[0].remove_widget(*args, **kwargs)
return super(AppDialog, self).remove_widget(*args, **kwargs)
def clear_widgets(self, *args, **kwargs):
if self.children:
return self.children[0].clear_widgets(*args, **kwargs)
return super(AppDialog, self).clear_widgets(*args, **kwargs)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment