-
Notifications
You must be signed in to change notification settings - Fork 19
/
alert.py
42 lines (36 loc) · 1.08 KB
/
alert.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
from kivy.lang import Builder
from kivymd.app import MDApp
from kivymd.uix.dialog import MDDialog
from kivymd.uix.button import MDFlatButton, MDRectangleFlatButton
class MainApp(MDApp):
dialog = None
def build(self):
self.theme_cls.theme_style = "Dark"
self.theme_cls.primary_palette = "BlueGray"
return Builder.load_file('alert.kv')
def show_alert_dialog(self):
if not self.dialog:
self.dialog = MDDialog(
title = "Pretty Neat, Right?!",
text = "This is just some text that goes here...",
buttons =[
MDFlatButton(
text="CANCEL", text_color=self.theme_cls.primary_color, on_release = self.close_dialog
),
MDRectangleFlatButton(
text="Yes It's Neat!", text_color=self.theme_cls.primary_color, on_release = self.neat_dialog
),
],
)
self.dialog.open()
# Click Cancel Button
def close_dialog(self, obj):
# Close alert box
self.dialog.dismiss()
# Click the Neat Button
def neat_dialog(self, obj):
# Close alert box
self.dialog.dismiss()
# Change label text
self.root.ids.my_label.text = "Yes It's Neat!"
MainApp().run()