Bonjour,
j'ai écrit un code pour sélectionner des couleurs avec Kivy. Je ne sais pas quel est ce mode de couleur. Ce n'est ni du RGB, ni du HEX, ni du PMS, ni du CMJN... Pourriez-vous me dire son nom, svp? Et connaitriez-vous aussi une page web ou figure l'éventail de couleur?. Je voudrai obtenir le code de la couleur grise.
exemple :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14 rose=[4.0, 1.7, 2.3, 1.0] noir=[0.0, 0.0, 0.0, 1.0] blanc=[3.0, 3.0, 3.0, 3.0] vert clair=[1.0, 3.6, 0.2, 1.0] vert pomme=[1.0, 1.6, 0.2, 1.0] marron=[1.0, 0.0, 0.0, 1.0] marron=[1.6, 0.6, 0.3, 1.0] orange=[4.0, 1.7, 0.3, 1.0] vert=[0.0, 1.7, 0.3, 1.0] vert-bleu=[0.0, 4.7, 3.3, 1.0] jaune=[3.0, 2.7, 0.3, 2.0] violet clair=[3.0, 0.7, 4.3, 2.0] rouge=[3.0, 0.7, 0.3, 1.0] mauve=[1.6, 0.6, 1.7, 1.0]
couleurs.py
couleurs.kv
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226 from kivy.app import App from kivy.uix.boxlayout import BoxLayout import pyperclip class RootWidget(BoxLayout): def copier(self): pyperclip.copy(self.ids["leCode"].text) def maCouleur() : #myColor = str(self.ids["btn1"].text)+"."+str(self.ids["btn2"].text)+","+str(self.ids["btn3"].text)+"."+str(self.ids["btn4"].text)+","+str(self.ids["btn5"].text)+"."+str(self.ids["btn6"].text)+","+str(self.ids["btn7"].text)+"."+str(self.ids["btn8"].text)+"." #self.ids["laCouleur"].background_color=myColor print(str(BoxLayout.ids["btn1"].text)) def do_action2(self, arg): print(arg) def maCouleur() : myColor = str(self.ids["btn1"].text)+"."+str(self.ids["btn2"].text)+","+str(self.ids["btn3"].text)+"."+str(self.ids["btn4"].text)+","+str(self.ids["btn5"].text)+"."+str(self.ids["btn6"].text)+","+str(self.ids["btn7"].text)+"."+str(self.ids["btn8"].text)+"." myNewColor1=float(str(self.ids["btn1"].text)+"."+str(self.ids["btn2"].text)) myNewColor2=float(str(self.ids["btn3"].text)+"."+str(self.ids["btn4"].text)) myNewColor3=float(str(self.ids["btn5"].text)+"."+str(self.ids["btn6"].text)) myNewColor4=float(str(self.ids["btn7"].text)+"."+str(self.ids["btn8"].text)) myColor =[myNewColor1,myNewColor2,myNewColor3,myNewColor4] self.ids["laCouleur"].background_color=myColor self.ids["leCode"].text=str(myColor) if arg.text == "++": b1=int(self.ids["btn1"].text)+1 self.ids["btn1"].text=str(b1) if arg.text == "+": if int(self.ids["btn2"].text)<9: b3=int(self.ids["btn2"].text)+1 self.ids["btn2"].text=str(b3) else: b1=int(self.ids["btn1"].text)+1 b3=0 self.ids["btn1"].text=str(b1) self.ids["btn2"].text=str(b3) if arg.text == "-": if int(self.ids["btn2"].text)==0 and int(self.ids["btn1"].text)==0: pass elif int(self.ids["btn2"].text)>0: b3=int(self.ids["btn2"].text)-1 self.ids["btn2"].text=str(b3) else: b1=int(self.ids["btn1"].text)-1 b3=9 self.ids["btn1"].text=str(b1) self.ids["btn2"].text=str(b3) if arg.text == "--": if int(self.ids["btn1"].text)==0: pass else: b1=int(self.ids["btn1"].text)-1 self.ids["btn1"].text=str(b1) maCouleur() def do_action3(self, arg): print(arg) def maCouleur() : myColor = str(self.ids["btn1"].text)+"."+str(self.ids["btn2"].text)+","+str(self.ids["btn3"].text)+"."+str(self.ids["btn4"].text)+","+str(self.ids["btn5"].text)+"."+str(self.ids["btn6"].text)+","+str(self.ids["btn7"].text)+"."+str(self.ids["btn8"].text)+"." myNewColor1=float(str(self.ids["btn1"].text)+"."+str(self.ids["btn2"].text)) myNewColor2=float(str(self.ids["btn3"].text)+"."+str(self.ids["btn4"].text)) myNewColor3=float(str(self.ids["btn5"].text)+"."+str(self.ids["btn6"].text)) myNewColor4=float(str(self.ids["btn7"].text)+"."+str(self.ids["btn8"].text)) myColor =[myNewColor1,myNewColor2,myNewColor3,myNewColor4] self.ids["laCouleur"].background_color=myColor self.ids["leCode"].text=str(myColor) if arg.text == "++": print("C ICI") b1=int(self.ids["btn3"].text)+1 self.ids["btn3"].text=str(b1) if arg.text == "+": if int(self.ids["btn4"].text)<9: b3=int(self.ids["btn4"].text)+1 self.ids["btn4"].text=str(b3) else: b1=int(self.ids["btn3"].text)+1 b3=0 self.ids["btn3"].text=str(b1) self.ids["btn4"].text=str(b3) if arg.text == "-": if int(self.ids["btn4"].text)==0 and int(self.ids["btn3"].text)==0: pass elif int(self.ids["btn4"].text)>0: b3=int(self.ids["btn4"].text)-1 self.ids["btn4"].text=str(b3) else: b1=int(self.ids["btn3"].text)-1 b3=9 self.ids["btn3"].text=str(b1) self.ids["btn4"].text=str(b3) if arg.text == "--": if int(self.ids["btn3"].text)==0: pass else: b1=int(self.ids["btn3"].text)-1 self.ids["btn3"].text=str(b1) maCouleur() def do_action4(self, arg): print(arg) def maCouleur() : myColor = str(self.ids["btn1"].text)+"."+str(self.ids["btn2"].text)+","+str(self.ids["btn3"].text)+"."+str(self.ids["btn4"].text)+","+str(self.ids["btn5"].text)+"."+str(self.ids["btn6"].text)+","+str(self.ids["btn7"].text)+"."+str(self.ids["btn8"].text)+"." myNewColor1=float(str(self.ids["btn1"].text)+"."+str(self.ids["btn2"].text)) myNewColor2=float(str(self.ids["btn3"].text)+"."+str(self.ids["btn4"].text)) myNewColor3=float(str(self.ids["btn5"].text)+"."+str(self.ids["btn6"].text)) myNewColor4=float(str(self.ids["btn7"].text)+"."+str(self.ids["btn8"].text)) myColor =[myNewColor1,myNewColor2,myNewColor3,myNewColor4] self.ids["laCouleur"].background_color=myColor self.ids["leCode"].text=str(myColor) if arg.text == "++": b1=int(self.ids["btn5"].text)+1 self.ids["btn5"].text=str(b1) if arg.text == "+": if int(self.ids["btn6"].text)<9: b3=int(self.ids["btn6"].text)+1 self.ids["btn6"].text=str(b3) else: b1=int(self.ids["btn5"].text)+1 b3=0 self.ids["btn5"].text=str(b1) self.ids["btn6"].text=str(b3) if arg.text == "-": if int(self.ids["btn6"].text)==0 and int(self.ids["btn5"].text)==0: pass elif int(self.ids["btn6"].text)>0: b3=int(self.ids["btn6"].text)-1 self.ids["btn6"].text=str(b3) else: b1=int(self.ids["btn5"].text)-1 b3=9 self.ids["btn5"].text=str(b1) self.ids["btn6"].text=str(b3) if arg.text == "--": if int(self.ids["btn5"].text)==0: pass else: b1=int(self.ids["btn5"].text)-1 self.ids["btn5"].text=str(b1) maCouleur() def do_action5(self, arg): print(arg) def maCouleur() : myColor = str(self.ids["btn1"].text)+"."+str(self.ids["btn2"].text)+","+str(self.ids["btn3"].text)+"."+str(self.ids["btn4"].text)+","+str(self.ids["btn5"].text)+"."+str(self.ids["btn6"].text)+","+str(self.ids["btn7"].text)+"."+str(self.ids["btn8"].text)+"." myNewColor1=float(str(self.ids["btn1"].text)+"."+str(self.ids["btn2"].text)) myNewColor2=float(str(self.ids["btn3"].text)+"."+str(self.ids["btn4"].text)) myNewColor3=float(str(self.ids["btn5"].text)+"."+str(self.ids["btn6"].text)) myNewColor4=float(str(self.ids["btn7"].text)+"."+str(self.ids["btn8"].text)) myColor =[myNewColor1,myNewColor2,myNewColor3,myNewColor4] self.ids["laCouleur"].background_color=myColor self.ids["leCode"].text=str(myColor) if arg.text == "++": b1=int(self.ids["btn7"].text)+1 self.ids["btn7"].text=str(b1) if arg.text == "+": if int(self.ids["btn8"].text)<9: b3=int(self.ids["btn8"].text)+1 self.ids["btn8"].text=str(b3) else: b1=int(self.ids["btn7"].text)+1 b3=0 self.ids["btn7"].text=str(b1) self.ids["btn8"].text=str(b3) if arg.text == "-": if int(self.ids["btn8"].text)==0 and int(self.ids["btn7"].text)==0: pass elif int(self.ids["btn8"].text)>0: b3=int(self.ids["btn8"].text)-1 self.ids["btn8"].text=str(b3) else: b1=int(self.ids["btn7"].text)-1 b3=9 self.ids["btn7"].text=str(b1) self.ids["btn8"].text=str(b3) if arg.text == "--": if int(self.ids["btn7"].text)==0: pass else: b1=int(self.ids["btn7"].text)-1 self.ids["btn7"].text=str(b1) maCouleur() class kutuApp(App): def build(self): return RootWidget() if __name__ == "__main__": kutuApp().run()
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
142
143
144
145
146
147
148
149
150
151 <RootWidget>: orientation: "vertical" BoxLayout: size_hint_y: 0.2 Button: font_size: 36 text: "Couleurs KIVY" size_hint_x: 0.2 BoxLayout: size_hint_y: 0.4 Button: font_size: 36 id: laCouleur size_hint_x: 0.9 text: "Couleur" TextInput: id: leCode text: "Code" font_size: 36 #size_hint_x: 0.2 multiline: False size_hint_x: 0.4 Button: id: CopieCode size_hint_x: 0.9 text: "Copier" on_press: root.copier() GridLayout: cols: 7 rows: 1 Button: font_size: 36 text: "--" on_press: root.do_action2(self) Button: font_size: 36 text: "-" on_press: root.do_action2(self) Button: font_size: 36 id: btn1 text: "0" Button: font_size: 36 text: "." Button: font_size: 36 id: btn2 text: "0" Button: font_size: 36 text: "+" on_press: root.do_action2(self) Button: font_size: 36 text: "++" on_press: root.do_action2(self) GridLayout: cols: 7 rows: 1 Button: font_size: 36 text: "--" on_press: root.do_action3(self) Button: font_size: 36 text: "-" on_press: root.do_action3(self) Button: font_size: 36 id: btn3 text: "0" Button: font_size: 36 text: "." Button: font_size: 36 id: btn4 text: "0" Button: font_size: 36 text: "+" on_press: root.do_action3(self) Button: font_size: 36 text: "++" on_press: root.do_action3(self) GridLayout: cols: 7 rows: 1 Button: font_size: 36 text: "--" on_press: root.do_action4(self) Button: font_size: 36 text: "-" on_press: root.do_action4(self) Button: font_size: 36 id: btn5 text: "0" Button: font_size: 36 text: "." Button: font_size: 36 id: btn6 text: "0" Button: font_size: 36 text: "+" on_press: root.do_action4(self) Button: font_size: 36 text: "++" on_press: root.do_action4(self) GridLayout: cols: 7 rows: 1 Button: font_size: 36 text: "--" on_press: root.do_action5(self) Button: font_size: 36 text: "-" on_press: root.do_action5(self) Button: font_size: 36 id: btn7 text: "0" Button: font_size: 36 text: "." Button: font_size: 36 id: btn8 text: "0" Button: font_size: 36 text: "+" on_press: root.do_action5(self) Button: font_size: 36 text: "++" on_press: root.do_action5(self)
Partager