Created
March 30, 2015 21:53
-
-
Save kived/742397a80d61e6be225a to your computer and use it in GitHub Desktop.
Kivy: confirmation popup dialog
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<-ConfirmPopup>: | |
GridLayout: | |
cols: 1 | |
padding: '12dp' | |
pos_hint: {'center': (0.5, 0.5)} | |
size_hint_x: 0.66 | |
size_hint_y: None | |
height: self.minimum_height | |
canvas: | |
Color: | |
rgba: root.background_color[:3] + [root.background_color[-1] * root._anim_alpha] | |
Rectangle: | |
size: root._window.size if root._window else (0, 0) | |
Color: | |
rgb: 1, 1, 1 | |
BorderImage: | |
source: root.background | |
border: root.border | |
pos: self.pos | |
size: self.size | |
Label: | |
text: root.text | |
size_hint_y: None | |
height: self.texture_size[1] + dp(16) | |
text_size: self.width - dp(16), None | |
halign: 'center' | |
BoxLayout: | |
size_hint_y: None | |
height: sp(48) | |
Button: | |
text: root.cancel_text | |
on_press: root.cancel() | |
Button: | |
text: root.ok_text | |
on_press: root.ok() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from kivy.properties import StringProperty | |
from os.path import join, dirname | |
from kivy.lang import Builder | |
from kivy.uix.popup import Popup | |
Builder.load_file(join(dirname(__file__), 'confirmpopup.kv')) | |
class ConfirmPopup(Popup): | |
text = StringProperty('') | |
ok_text = StringProperty('OK') | |
cancel_text = StringProperty('Cancel') | |
__events__ = ('on_ok', 'on_cancel') | |
def ok(self): | |
self.dispatch('on_ok') | |
self.dismiss() | |
def cancel(self): | |
self.dispatch('on_cancel') | |
self.dismiss() | |
def on_ok(self): | |
pass | |
def on_cancel(self): | |
pass |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment