Bonjour,

Je viens vers vous car j'ai quelques problèmes pour coder un programme tout simple qui doit executer une commande dos qui permet de gérer les horaires de connexion des sessions windows.

Donc j'ai créer un programme python a base de widget Listbox et Scrollbar pour présenter les possiblités horaires et ensuite récuperer les variables et les placer dans la commande qui doit etre équivalente à : net user %username% /time:L,variable_de_debut-variable_de_fin;Ma,etc...

Mais voila, lorsque je lance mon programme, il y a plusieurs processus qui se mettent en route sur mon windows et qui ne s'eteignent pas à la fin du programme.

Je ne sais pas pourquoi et je voudrais bien comprendre.

Vu mon petit niveau en Tkinter, (et vu la longueur de mon code), je pense que j'ai codé comme un petit goret, ceci expliquant cela, et je souhaiterais vos conseils avisés.

De plus, je n'arrive pas a récuperer les variables dans ma commande dos.

Si vous pouviez m'aider, ca serait super et je vous en remercie par avance.

Voici mon code commenté :
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
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
 
from Tkinter import *
import os
 
def essai(e):
	"recupération Variable"
	var=list.get(list.curselection())
 
def essai1(e):
	"recupération Variable"
	var1=list1.get(list1.curselection())
 
def essai2(e):
	"recupération Variable"
	var2=list2.get(list2.curselection())
 
def essai3(e):
	"recupération Variable"
	var3=list3.get(list3.curselection())
 
def essai4(e):
	"recupération Variable"
	var4=list4.get(list4.curselection())
 
def essai5(e):
	"recupération Variable"
	var5=list5.get(list5.curselection())
 
def essai6(e):
	"recupération Variable"
	var6=list6.get(list6.curselection())
 
def essai7(e):
	"recupération Variable"
	var7=list7.get(list7.curselection())
 
def essai8(e):
	"recupération Variable"
	var8=list8.get(list8.curselection())
 
def essai9(e):
	"recupération Variable"
	var9=list9.get(list9.curselection())
 
def essai10(e):
	"recupération Variable"
	var10=list10.get(list10.curselection())
 
def essai11(e):
	"recupération Variable"
	var11=list11.get(list11.curselection())
 
def essai12(e):
	"recupération Variable"
	var12=list12.get(list12.curselection())
 
def essai13(e):
	"recupération Variable"
	var13=list13.get(list13.curselection())
 
 
def valid():
	"Mise en place du script final d'autorisation de session"
	commande = os.system ('net user %username% 
 
/time:L,var-var7;Ma,var1-var8;Me,var2-var9;J,var3-var10;V,var4-var11;S,var5-var12;D,var6-v
ar13')
 
fen1=Tk()
fen1.title('Horaires de session')
ent1=Label(fen1,text='Lundi')
ent1.grid(row=0,column=0)
#Définition liste debut horaire lundi
list=Listbox(fen1)
list.configure(height=2)
list.grid(row=0,column=1)
for horaires in 
 
["00:00","01:00","02:00","03:00","04:00"
,"05:00","06:00","07:00","08:00","09:00"
,"10:00","11:00","12:00","13:00","14:00"
,"15
 
:00","16:00","17:00","18:00","19:00","20
:00","21:00","22:00","23:00","24:00"]:list.in
sert(END,horaires)
scrol=Scrollbar(fen1,command=list.yview)
scrol.grid(row=0,column=2)
 
ent2=Label(fen1,text='Mardi')
ent2.grid(row=1,column=0)
#Définition liste debut horaire Mardi
list1=Listbox(fen1)
list1.configure(height=2)
list1.grid(row=1,column=1)
for horaires1 in 
 
["00:00","01:00","02:00","03:00","04:00"
,"05:00","06:00","07:00","08:00","09:00"
,"10:00","11:00","12:00","13:00","14:00"
,"15
 
:00","16:00","17:00","18:00","19:00","20
:00","21:00","22:00","23:00","24:00"]:list1.i
nsert(END,horaires1)
scrol=Scrollbar(fen1,command=list1.yview)
scrol.grid(row=1,column=2)
 
ent3=Label(fen1,text='Mercredi')
ent3.grid(row=2,column=0)
#Définition liste debut horaire Mercredi
list2=Listbox(fen1)
list2.configure(height=2)
list2.grid(row=2,column=1)
for horaires2 in 
 
["00:00","01:00","02:00","03:00","04:00"
,"05:00","06:00","07:00","08:00","09:00"
,"10:00","11:00","12:00","13:00","14:00"
,"15
 
:00","16:00","17:00","18:00","19:00","20
:00","21:00","22:00","23:00","24:00"]:list2.i
nsert(END,horaires2)
scrol=Scrollbar(fen1,command=list2.yview)
scrol.grid(row=2,column=2)
 
ent4=Label(fen1,text='Jeudi')
ent4.grid(row=3,column=0)
#Définition liste debut horaire Jeudi
list3=Listbox(fen1)
list3.configure(height=2)
list3.grid(row=3,column=1)
for horaires3 in 
 
["00:00","01:00","02:00","03:00","04:00"
,"05:00","06:00","07:00","08:00","09:00"
,"10:00","11:00","12:00","13:00","14:00"
,"15
 
:00","16:00","17:00","18:00","19:00","20
:00","21:00","22:00","23:00","24:00"]:list3.i
nsert(END,horaires3)
scrol=Scrollbar(fen1,command=list3.yview)
scrol.grid(row=3,column=2)
 
ent5=Label(fen1,text='Vendredi')
ent5.grid(row=4,column=0)
#Définition liste debut horaire Vendredi
list4=Listbox(fen1)
list4.configure(height=2)
list4.grid(row=4,column=1)
for horaires4 in 
 
["00:00","01:00","02:00","03:00","04:00"
,"05:00","06:00","07:00","08:00","09:00"
,"10:00","11:00","12:00","13:00","14:00"
,"15
 
:00","16:00","17:00","18:00","19:00","20
:00","21:00","22:00","23:00","24:00"]:list4.i
nsert(END,horaires4)
scrol=Scrollbar(fen1,command=list4.yview)
scrol.grid(row=4,column=2)
 
ent6=Label(fen1,text='Samedi')
ent6.grid(row=5,column=0)
#Définition liste debut horaire Samedi
list5=Listbox(fen1)
list5.configure(height=2)
list5.grid(row=5,column=1)
for horaires5 in 
 
["00:00","01:00","02:00","03:00","04:00"
,"05:00","06:00","07:00","08:00","09:00"
,"10:00","11:00","12:00","13:00","14:00"
,"15
 
:00","16:00","17:00","18:00","19:00","20
:00","21:00","22:00","23:00","24:00"]:list5.i
nsert(END,horaires5)
scrol=Scrollbar(fen1,command=list5.yview)
scrol.grid(row=5,column=2)
 
ent7=Label(fen1,text='Dimanche')
ent7.grid(row=6,column=0)
#Définition liste debut horaire Dimanche
list6=Listbox(fen1)
list6.configure(height=2)
list6.grid(row=6,column=1)
for horaires6 in 
 
["00:00","01:00","02:00","03:00","04:00"
,"05:00","06:00","07:00","08:00","09:00"
,"10:00","11:00","12:00","13:00","14:00"
,"15
 
:00","16:00","17:00","18:00","19:00","20
:00","21:00","22:00","23:00","24:00"]:list6.i
nsert(END,horaires6)
scrol=Scrollbar(fen1,command=list6.yview)
scrol.grid(row=6,column=2)
 
ent7=Label(fen1,text='Heures de début')
ent7.grid(row=7,column=1)
#Définition liste fin horaire lundi
list7=Listbox(fen1)
list7.configure(height=2)
list7.grid(row=0,column=3)
for horaires7 in 
 
["00:00","01:00","02:00","03:00","04:00"
,"05:00","06:00","07:00","08:00","09:00"
,"10:00","11:00","12:00","13:00","14:00"
,"15
 
:00","16:00","17:00","18:00","19:00","20
:00","21:00","22:00","23:00","24:00"]:list7.i
nsert(END,horaires7)
scrol=Scrollbar(fen1,command=list7.yview)
scrol.grid(row=0,column=4)
 
#Définition liste fin horaire Mardi
list8=Listbox(fen1)
list8.configure(height=2)
list8.grid(row=1,column=3)
for horaires8 in 
 
["00:00","01:00","02:00","03:00","04:00"
,"05:00","06:00","07:00","08:00","09:00"
,"10:00","11:00","12:00","13:00","14:00"
,"15
 
:00","16:00","17:00","18:00","19:00","20
:00","21:00","22:00","23:00","24:00"]:list8.i
nsert(END,horaires8)
scrol=Scrollbar(fen1,command=list8.yview)
scrol.grid(row=1,column=4)
 
#Définition liste fin horaire Mercredi
list9=Listbox(fen1)
list9.configure(height=2)
list9.grid(row=2,column=3)
for horaires9 in 
 
["00:00","01:00","02:00","03:00","04:00"
,"05:00","06:00","07:00","08:00","09:00"
,"10:00","11:00","12:00","13:00","14:00"
,"15
 
:00","16:00","17:00","18:00","19:00","20
:00","21:00","22:00","23:00","24:00"]:list9.i
nsert(END,horaires9)
scrol=Scrollbar(fen1,command=list9.yview)
scrol.grid(row=2,column=4)
 
#Définition liste fin horaire Jeudi
list10=Listbox(fen1)
list10.configure(height=2)
list10.grid(row=3,column=3)
for horaires10 in 
 
["00:00","01:00","02:00","03:00","04:00"
,"05:00","06:00","07:00","08:00","09:00"
,"10:00","11:00","12:00","13:00","14:00"
,"15
 
:00","16:00","17:00","18:00","19:00","20
:00","21:00","22:00","23:00","24:00"]:list10.
insert(END,horaires10)
scrol=Scrollbar(fen1,command=list10.yview)
scrol.grid(row=3,column=4)
 
#Définition liste fin horaire Vendredi
list11=Listbox(fen1)
list11.configure(height=2)
list11.grid(row=4,column=3)
for horaires11 in 
 
["00:00","01:00","02:00","03:00","04:00"
,"05:00","06:00","07:00","08:00","09:00"
,"10:00","11:00","12:00","13:00","14:00"
,"15
 
:00","16:00","17:00","18:00","19:00","20
:00","21:00","22:00","23:00","24:00"]:list11.
insert(END,horaires11)
scrol=Scrollbar(fen1,command=list11.yview)
scrol.grid(row=4,column=4)
 
#Définition liste fin horaire Samedi
list12=Listbox(fen1)
list12.configure(height=2)
list12.grid(row=5,column=3)
for horaires12 in 
 
["00:00","01:00","02:00","03:00","04:00"
,"05:00","06:00","07:00","08:00","09:00"
,"10:00","11:00","12:00","13:00","14:00"
,"15
 
:00","16:00","17:00","18:00","19:00","20
:00","21:00","22:00","23:00","24:00"]:list12.
insert(END,horaires12)
scrol=Scrollbar(fen1,command=list12.yview)
scrol.grid(row=5,column=4)
 
#Définition liste fin horaire Dimanche
list13=Listbox(fen1)
list13.configure(height=2)
list13.grid(row=6,column=3)
for horaires13 in 
 
["00:00","01:00","02:00","03:00","04:00"
,"05:00","06:00","07:00","08:00","09:00"
,"10:00","11:00","12:00","13:00","14:00"
,"15
 
:00","16:00","17:00","18:00","19:00","20
:00","21:00","22:00","23:00","24:00"]:list13.
insert(END,horaires13)
scrol=Scrollbar(fen1,command=list13.yview)
scrol.grid(row=6,column=4)
 
ent7=Label(fen1,text='Heures de fin')
ent7.grid(row=7,column=3)
list.bind('<Double-1>',essai)
list1.bind('<Double-1>',essai1)
list2.bind('<Double-1>',essai2)
list3.bind('<Double-1>',essai3)
list4.bind('<Double-1>',essai4)
list5.bind('<Double-1>',essai5)
list6.bind('<Double-1>',essai6)
list7.bind('<Double-1>',essai7)
list8.bind('<Double-1>',essai8)
list9.bind('<Double-1>',essai9)
list10.bind('<Double-1>',essai10)
list11.bind('<Double-1>',essai11)
list12.bind('<Double-1>',essai12)
list13.bind('<Double-1>',essai13)
 
ent8=Button(fen1,text='Validez',command=(lambda:valid()))
ent8.grid(row=8,column=4)
fen1.mainloop()