-
Notifications
You must be signed in to change notification settings - Fork 1
/
front.py
executable file
·108 lines (98 loc) · 3.43 KB
/
front.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
#!/usr/bin/env python3
from kivy.uix.screenmanager import Screen
from kivymd.app import MDApp
from kivymd.uix.button import MDRectangleFlatButton, MDFlatButton
from kivymd.uix.dialog import MDDialog
from kivymd.uix.list import OneLineListItem
import json
rooms_json = """{
"rooms":
[
{
"name": "переговорка 1",
"intervals":
[
{
"id": 1,
"start": "12:00",
"end": "12:30",
"owner": "Марина"
},
{
"id": 2,
"start": "12:30",
"end": "13:00",
"owner": "Марина"
},
{
"id": 3,
"start": "13:00",
"end": "13:30",
"owner": "Марина"
},
{
"id": 4,
"start": "13:30",
"end": "14:00",
"owner": null
},
{
"id": 5,
"start": "14:00",
"end": "14:30",
"owner": null
}
]
}
]
}
"""
rooms_dict = json.loads(rooms_json)
class room_1(MDApp):
def build(self):
screen = Screen()
for i in range(len(rooms_dict["rooms"][0]["intervals"])):
if rooms_dict["rooms"][0]["intervals"][i]["owner"] is None:
screen.add_widget(
OneLineListItem(
text=rooms_dict["rooms"][0]["intervals"][i]["start"]
+ "-"
+ rooms_dict["rooms"][0]["intervals"][i]["end"],
pos_hint={"center_x": 0.5, "center_y": 0.9 - 0.1 * i},
on_release=self.show_data_i(i),
bg_color=(0, 1, 0, 1),
text_color=(0, 0, 0, 1),
theme_text_color="Custom",
)
)
else:
screen.add_widget(
OneLineListItem(
text=rooms_dict["rooms"][0]["intervals"][i]["start"]
+ "-"
+ rooms_dict["rooms"][0]["intervals"][i]["end"],
pos_hint={"center_x": 0.5, "center_y": 0.9 - 0.1 * i},
on_release=self.show_data_i(i),
bg_color=(1, 0, 0, 1),
text_color=(0, 0, 0, 1),
theme_text_color="Custom",
)
)
return screen
def show_data_i(self, i):
def show_data(obj):
close_button = MDFlatButton(text="close", on_release=self.close_dialog)
book_button = MDFlatButton(text="book")
owner_name = rooms_dict["rooms"][0]["intervals"][i]["owner"]
if owner_name is None:
text = "СВОБОДНО НАХУЙ"
else:
text = f"ЗАНЯТО существом по имени {owner_name}, СВАЛИ НАХУЙ"
self.dialog = MDDialog(
title=obj.text, text=text, buttons=[close_button, book_button]
)
self.dialog.open()
return show_data
def close_dialog(self, obj):
self.dialog.dismiss()
room_1().run()