-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAdmin_window.py
More file actions
94 lines (74 loc) · 3.96 KB
/
Copy pathAdmin_window.py
File metadata and controls
94 lines (74 loc) · 3.96 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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
from kivy.app import App
from kivy.uix.label import Label
from kivy.uix.boxlayout import BoxLayout
from kivy.uix.spinner import Spinner
from kivy.uix.textinput import TextInput
from kivy.uix.button import Button
from Admin import Administrateur
class GiveRole(BoxLayout):
def build(self):
self.orientation = "vertical"
self.welcome()
self.label_admin()
self.input_admin()
self.label_user()
self.input_user()
self.label_role()
self.choose_role()
self.validation_button()
def welcome(self):
self.label_welcome = Label(text="Welcome in the Admin Page", color=[0.59, 0.239, 0.89, 1],
pos_hint={'x': 0.25, 'y': 0.9}, size_hint=(.5, .01))
self.add_widget(self.label_welcome)
# ----------------------------------------------------------- ADMIN SPACE -----------------------------------------------------------#
def label_admin(self):
self.label_id_admin = Label(text="Please enter your username", color=[0.59, 0.239, 0.89, 1],
pos_hint={'x': 0.25, 'y': 0.9}, size_hint=(.5, .01))
self.add_widget(self.label_id_admin)
def input_admin(self):
self.input_admin_user = TextInput(pos_hint={'x': 0.25, 'y': 0.9}, size_hint=(.5, .01))
self.add_widget(self.input_admin_user)
# ----------------------------------------------------------- USER SPACE -----------------------------------------------------------#
def label_user(self):
self.label_id_user_to_up = Label(text="Enter the name of the user to whom to give a role",
color=[0.59, 0.239, 0.89, 1],
pos_hint={'x': 0.25, 'y': 0.9}, size_hint=(.5, .01))
self.add_widget(self.label_id_user_to_up)
def input_user(self):
self.input_user = TextInput(pos_hint={'x': 0.25, 'y': 0.9}, size_hint=(.5, .01))
self.add_widget(self.input_user)
# ----------------------------------------------------------- ROLE SPACE -----------------------------------------------------------#
def label_role(self):
self.user_roles_label = Label(text="New role of the user : ", color=[0.59, 0.239, 0.89, 1],
pos_hint={'x': 0.25, 'y': 0.9}, size_hint=(.5, .01))
self.add_widget(self.user_roles_label)
def choose_role(self):
self.option_list = Spinner(text="Choose the role",
values=("Admin", "Modo", "User"),
size_hint=(0.4, .17), pos_hint={'x': 0.3, 'y': 0.8},
background_color=[0.59, 0.239, 0.89, 1])
self.add_widget(self.option_list)
def validation_button(self):
self.button_of_validation = Button(text="Change role", size_hint=(.3, .02),
pos_hint={'x': 0.35, 'y': 0.1}, color=[1, 1, 1, 1],
background_color=[0.59, 0.239, 0.89, 1])
self.button_of_validation.bind(on_press=self.validation)
self.add_widget(self.button_of_validation)
# ----------------------------------------------------------- Space Graphic -----------------------------------------------------------#
def black_space(self):
self.black = Label(size_hint=(.4, .1))
self.add_widget(self.black)
def validation(self, instance):
self.admin = self.input_admin_user.text
self.user = self.input_user.text
self.role = self.option_list.text
admin = Administrateur(self.admin)
self.label_welcome.text = str(admin.manage_non_admin_role(self.user, self.role))
admin.manage_non_admin_role(self.user, self.role)
class Window(App):
def build(self):
Layout = GiveRole()
Layout.build()
return Layout
if __name__ == '__main__':
Window().run()