-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdlg.py
141 lines (111 loc) · 3.95 KB
/
dlg.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
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
from kivy.lang import Builder
from kivy.properties import ColorProperty, StringProperty, ObjectProperty
from kivy.uix.modalview import ModalView
Builder.load_string("""
<FullscreenTimedModal>:
#:set button_size 48
canvas.before:
Color:
rgba: root.background_color
Rectangle:
pos: self.pos
size: self.size
canvas:
#:set button_radius 5
Color:
rgba: root.border_color
Line:
rounded_rectangle: self.pos[0]+2, self.pos[1]+2, self.size[0]-4, self.size[1]-4, 5, 100
Line:
points:
self.size[0]-8-button_size, self.size[1]-8, \
self.size[0]-8-button_size, self.size[1]-8-button_size+button_radius
width: 1
cap: 'none'
Line:
points:
self.size[0]-8-button_size+button_radius, self.size[1]-8-button_size, \
self.size[0]-8, self.size[1]-8-button_size
width: 1
cap: 'none'
Line:
circle:
self.size[0]-8-button_size+button_radius, self.size[1]-8-button_size+button_radius,\
button_radius, \
180, 270, \
4
width: 1
cap: 'none'
Line:
points:
8, self.size[1]-8-button_size, \
self.size[0]-button_size-12, self.size[1]-8-button_size
width: 1
cap: 'none'
AnchorLayout:
anchor_x: 'right'
anchor_y: 'top'
padding: 4
Button:
id: CloseBtn
text: ''
size: [button_size, button_size]
size_hint: [None, None]
background_normal: ''
background_down: ''
background_color: 0, 0, 0, 0
Image:
source: 'assets/close.png'
x: self.parent.x + (button_size/4) - 2
y: self.parent.y + (button_size/4) - 2
size: (button_size/2, button_size/2)
color: root.text_color
AnchorLayout:
anchor_x: 'center'
anchor_y: 'top'
padding: -20
Label:
size_hint: [1, None]
text: root.title
color: root.text_color
valign: 'middle'
font_size: 24
""")
class FullscreenTimedModal(ModalView):
background_color = ColorProperty([0, 0, 0, 1])
"""Background color, in the format (r, g, b, a).
:attr:`background_color` is a :class:`~kivy.properties.ColorProperty` and
defaults to [1, 1, 1, 1].
"""
border_color = ColorProperty([77 / 256, 77 / 256, 76 / 256, 1])
"""Border color, in the format (r, g, b, a).
:attr:`border_color` is a :class:`~kivy.properties.ColorProperty` and
defaults to [77 / 256, 77 / 256, 76 / 256, 1].
"""
text_color = ColorProperty([249 / 256, 176 / 256, 0 / 256, 1])
"""Border color, in the format (r, g, b, a).
:attr:`text_color` is a :class:`~kivy.properties.ColorProperty` and
defaults to [249 / 256, 176 / 256, 0 / 256, 1].
"""
title = StringProperty("")
screensaver = ObjectProperty(None, allownone=True)
""" Expects a screensaver instance. If set, the dialog will disable the screensaver
while it is open.
"""
def __init__(self, title=None, **kwargs):
super(FullscreenTimedModal, self).__init__(**kwargs)
self.ids.CloseBtn.bind(on_press=self.dismiss)
self.bind(on_open=self._on_open)
self.bind(on_dismiss=self._on_dismiss)
if title is not None:
self.title = title
def is_inactive(self):
return self._window is None
def _on_open(self, _e):
if self.screensaver:
self.screensaver.disabled = True
def _on_dismiss(self, _e):
if self.screensaver:
self.screensaver.disabled = False
# return False to actually dismiss the window
return False