-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdialogs.py
More file actions
72 lines (61 loc) · 1.65 KB
/
dialogs.py
File metadata and controls
72 lines (61 loc) · 1.65 KB
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
from typing import Callable
from kivymd.uix.button import MDRaisedButton
from kivymd.uix.dialog import MDDialog
from kivymd.uix.textfield import MDTextField
from utilities import ColorType
def ask_text_dialog(*, title: str, hint: str, button_text1: str, button_text2: str, button_color: ColorType,
function: Callable) -> MDDialog:
text_field: MDTextField = MDTextField(hint_text=hint)
dialog: MDDialog = MDDialog(
title=title,
type='custom',
content_cls=text_field,
buttons=[
MDRaisedButton(
text=button_text1,
on_release=lambda *args: dialog.dismiss(),
size=('100dp', '40dp'),
),
MDRaisedButton(
text=button_text2.capitalize(),
md_bg_color=button_color,
on_release=function,
size=('100dp', '40dp'),
)
],
on_open=lambda *args: setattr(text_field, 'focus', True)
)
return dialog
def yes_no_dialog(*, title: str, description: str, button_text1: str, button_text2: str, button_color: ColorType,
function: Callable) -> MDDialog:
dialog: MDDialog = MDDialog(
title=title,
text=description,
buttons=[
MDRaisedButton(
text=button_text1.capitalize(),
on_release=lambda *args: dialog.dismiss(),
size=('100dp', '40dp'),
),
MDRaisedButton(
text=button_text2.capitalize(),
md_bg_color=button_color,
on_release=function,
size=('100dp', '40dp'),
)
]
)
return dialog
def info_dialog(*, title: str, text: str, button_text: str) -> MDDialog:
dialog: MDDialog = MDDialog(
title=title,
text=text,
buttons=[
MDRaisedButton(
text=button_text,
on_release=lambda *args: dialog.dismiss(),
size=('100dp', '40dp'),
)
]
)
return dialog