Bonjour,

Voilà, mon projet touche à sa fin, mon programme marche, et la liaison série aussi, l'affichage marche, tout marche.

MAIS
, lorsque la liaison série est en fonctionnement, mon programme s'arrête et attend que la réception des données soit terminée pour que je puisse continuer...

J'aimerai savoir si il existe une solution à mon problème !!!


Voici le code (GuiGui, j'ai fait attenton cette fois si, j'ai mis les balises CODE ):
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
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
# -*- coding: cp1252 -*-
import serial
from Tkinter import*
from math import*
from pylab import plot,axis,legend, show
from time import gmtime, strftime
from random import randrange
import threading
 
def seconde():
    global tex6
    if(fin==0):
        threading.Timer(1.0, seconde).start()
    tex6.config(text=strftime("%a, %d %b %Y\n%H:%M:%S", gmtime()))
###############################################################################
def liaison():
    global tex2
    global entree
    global liste
    global photoaff
    global can3
    global tex1
    global entree1
    global liste2
    global thermoaff
    global can
    global tex3
    global entree2
    global liste3
    global ventaff
    global can2
    global vit
    global temp
    global dire
 
    ser = serial.Serial(0)
    ser.baudrate = 4800
    i=0
    a=0
    b=0
    c=0
    temp=[]
    vit=[]
    dire=[]
    while (i<12):
        tt = ser.read(1)
        e=ord(tt)
        if e==253:
            d=ser.read(1)
            temp1=ord(d)
            temp.append(temp1)
            if(temp1<=-10):
                can.coords(liste2[thermoaff],-990,96)
                can.coords(liste2[0],90,96)
                thermoaff=0
                tex1.config(text=str(temp1)+u'°C')
 
            if((temp1<=0) & (temp1>-10)):
                can.coords(liste2[thermoaff],-990,96)
                can.coords(liste2[1],90,96)
                thermoaff=1
                tex1.config(text=str(temp1)+u'°C')
 
            if((temp1<=5) & (temp1>0)):
                can.coords(liste2[thermoaff],-990,96)
                can.coords(liste2[2],90,96)
                thermoaff=2
                tex1.config(text=str(temp1)+u'°C')
 
            if((temp1<=15) & (temp1>5)):
                can.coords(liste2[thermoaff],-990,96)
                can.coords(liste2[3],90,96)
                thermoaff=3
                tex1.config(text=str(temp1)+u'°C')
 
            if((temp1<=25) & (temp1>15)):
                can.coords(liste2[thermoaff],-990,96)
                can.coords(liste2[4],90,96)
                thermoaff=4
                tex1.config(text=str(temp1)+u'°C')
 
            if((temp1<=35) & (temp1>25)):
                can.coords(liste2[thermoaff],-990,96)
                can.coords(liste2[5],90,96)
                thermoaff=5
                tex1.config(text=str(temp1)+u'°C')
 
            if((temp1<=45) & (temp1>35)):
                can.coords(liste2[thermoaff],-990,96)
                can.coords(liste2[6],90,96)
                thermoaff=6
                tex1.config(text=str(temp1)+u'°C')
 
            if((temp1<=55) & (temp1>45)):
                can.coords(liste2[thermoaff],-990,96)
                can.coords(liste2[7],90,96)
                thermoaff=7
                tex1.config(text=str(temp1)+u'°C')
 
            if(temp1>55):
                can.coords(liste2[thermoaff],-990,96)
                can.coords(liste2[8],90,96)
                thermoaff=8
                tex1.config(text=str(temp1)+u'°C')
            a=a+1
            print temp
        if e==254:
            d=ser.read(1)
            vent1=ord(d)
            vit.append(vent1)
            if((vent1<=0) & (vent1>=5)):
                can2.coords(liste3[ventaff],-990,96)
                can2.coords(liste3[1],90,96)
                ventaff=1
                tex3.config(text=str(vent1)+' km/h')
 
            if((vent1<=19) & (vent1>5)):
                can2.coords(liste3[ventaff],-990,96)
                can2.coords(liste3[2],90,96)
                ventaff=2
                tex3.config(text=str(vent1)+' km/h')
 
            if((vent1<=38) & (vent1>19)):
                can2.coords(liste3[ventaff],-990,96)
                can2.coords(liste3[3],90,96)
                ventaff=3
                tex3.config(text=str(vent1)+' km/h')
 
            if((vent1<=50) & (vent1>38)):
                can2.coords(liste3[ventaff],-990,96)
                can2.coords(liste3[4],90,96)
                ventaff=4
                tex3.config(text=str(vent1)+' km/h')
 
            if((vent1<=74) & (vent1>50)):
                can2.coords(liste3[ventaff],-990,96)
                can2.coords(liste3[5],90,96)
                ventaff=5
                tex3.config(text=str(vent1)+' km/h')
 
            if((vent1<=88) & (vent1>74)):
                can2.coords(liste3[ventaff],-990,96)
                can2.coords(liste3[6],90,96)
                ventaff=6
                tex3.config(text=str(vent1)+' km/h')
 
            if((vent1<=102) & (vent1>88)):
                can2.coords(liste3[ventaff],-990,96)
                can2.coords(liste3[7],90,96)
                ventaff=7
                tex3.config(text=str(vent1)+' km/h')
 
            if(vent1>102):
                can2.coords(liste3[ventaff],-990,96)
                can2.coords(liste3[8],90,96)
                ventaff=8
                tex3.config(text=str(vent1)+' km/h')
            b=b+1
            print vit
        if e==255:
            d=ser.read(1)
            dir1=ord(d)
            dire.append(dir1)
            c=c+1
            print dire
            if(((dir1>=0) & (dir1<15)) | ((dir1>225) & (dir1<241))):
                can3.coords(liste[photoaff],-990,96)
                can3.coords(liste[1],90,96)
                photoaff=1
                tex2.config(text="NORD")
 
            if((dir1<46) & (dir1>15)):
                can3.coords(liste[photoaff],-990,96)
                can3.coords(liste[2],90,96)
                photoaff=2
                tex2.config(text="NORD EST")
 
            if((dir1<76) & (dir1>45)):
                can3.coords(liste[photoaff],-990,96)
                can3.coords(liste[3],90,96)
                photoaff=3
                tex2.config(text="EST")
 
            if((dir1<106) & (dir1>75)):
                can3.coords(liste[photoaff],-990,96)
                can3.coords(liste[4],90,96)
                photoaff=4
                tex2.config(text="SUD EST")
 
            if((dir1<136) & (dir1>105)):
                can3.coords(liste[photoaff],-990,96)
                can3.coords(liste[5],90,96)
                photoaff=5
                tex2.config(text="SUD")
 
            if((dir1<166) & (dir1>135)):
                can3.coords(liste[photoaff],-990,96)
                can3.coords(liste[6],90,96)
                photoaff=6
                tex2.config(text="SUD OUEST")
 
            if((dir1<196) & (dir1>165)):
                can3.coords(liste[photoaff],-990,96)
                can3.coords(liste[7],90,96)
                photoaff=7
                tex2.config(text="OUEST")
 
            if((dir1<226) & (dir1>195)):
                can3.coords(liste[photoaff],-990,96)
                can3.coords(liste[8],90,96)
                photoaff=8
                tex2.config(text="NORD OUEST")
        i=i+1
 
 
################################################################################
#################Fenêtre Convertisseur##########################################
################################################################################
def convertisseur():
 
    def beaufort(event):
        chaine1.configure(text=str(float(entr2.get())*0.54))
        chaine2.configure(text=str(float(entr2.get())*0.15))
        chaine3.configure(text=str(float(entr2.get())*0.28))
 
    fenetre=Toplevel()
    fenetre.title('Convertisseur du vent')
 
    txt19=Label(fenetre,text='Convertisseur de la vitesse du vent',font=('Chiller',25))
    txt11=Label(fenetre,text='km/h équivaut à ',font=('Chiller',20))
    txt12=Label(fenetre,text='km/h équivaut à ',font=('Chiller',20))
    txt13=Label(fenetre,text='km/h équivaut à ',font=('Chiller',20))
    txt3=Label(fenetre,text='Noeuds',font=('Chiller',20))
    txt4=Label(fenetre,text='Beauforts',font=('Chiller',20))
    txt5=Label(fenetre,text='M/sec',font=('Chiller',20))
    chaine1=Label(fenetre,text='      ',fg='navy',font=('Chiller',20))
    #entr1=Entry(fenetre)
    chaine2=Label(fenetre,text='      ',fg='navy',font=('Chiller',20))
    entr2=Entry(fenetre,font=('Chiller',20))
    chaine3=Label(fenetre,text='      ',fg='navy',font=('Chiller',20))
    #entr3=Entry(fenetre)
    #entr1.bind("<Return>",noeud)
    entr2.bind("<Return>",beaufort)
    #entr3.bind("<Return>",msec)
    can1=Canvas(fenetre,width=432,height=288,bg='navy')
    photo=PhotoImage(file='vagues.gif')
    item=can1.create_image(216,144,image=photo)
    b111=Button(fenetre,text='Quitter',fg='purple',font=('Chiller',15),command=fenetre.destroy)
 
 
    txt19.grid(row=1,column=1,columnspan=4)
    txt11.grid(row=2,column=2)
    txt12.grid(row=3,column=2)
    txt13.grid(row=4,column=2)
    txt3.grid(row=2,column=4)
    txt4.grid(row=3,column=4)
    txt5.grid(row=4,column=4)
    chaine1.grid(row=2,column=3)
    chaine2.grid(row=3,column=3)
    chaine3.grid(row=4,column=3)
    can1.grid(row=5,column=1,columnspan=5)
    #entr1.grid(row=2,column=1)
    entr2.grid(row=3,column=1)
    #entr3.grid(row=4,column=1)
    b111.grid(row=1,column=5)
 
    fenetre.mainloop()
 
#*******************************************************************************
 
def vitesse():
    global vit
    absc=[]
    a=len(absc)
    i=0
    while(i<a):
        absc.append(i)
        i=i+1
        print absc
 
    plot(absc,vit, 'go-', mfc='b')
    axis([-1, 4, -5, 150])
    legend()
    show()
 
 
def direction():
    global dire
    absc1=[]
 
    a=len(absc1)
    i=0
    while(i<a):
        absc1.append(i)
        i=i+1
        print absc1
 
    plot(absc1,dire, 'go-', mfc='b')
    axis([-1, r, -5, 250])
    legend()
    show()
 
 
def temperature():
    global temp
    absc2=[0,1,2,3]
 
    a=len(absc2)
    i=0
    while(i<a):
        absc2.append(i)
        i=i+1
        print absc2
 
    plot(absc2,temp, 'go-', mfc='b')
    axis([-1, r, -15, 60])
    legend()
    show()
 
 
#******************************************************************************
#******************************************************************************
#******************************************************************************
#initialisation des variables
vit=[]
temp=[]
dire=[]
fin=0
photoaff=0
thermoaff=0
ventaff=0
#fin d'initialisation
 
fen = Tk()
fen.title("Fenêtre Principale Station Météo")
fen.geometry("1280x1024")
f=Frame(fen,bd=2,relief=SOLID)
f.pack()
 
 
 
can = Canvas(f, width =180, height =192, bg ='white',bd=2,relief =SOLID)
can1 = Canvas(f,width=960,height=170,  bg ='white',bd=2,relief=SOLID)
can2 = Canvas(f, width =180, height =192, bg ='white',bd=2,relief =SOLID)
can3 = Canvas(f, width =180, height =192, bg ='white',bd=2,relief =SOLID)
 
photo = PhotoImage(file ='cherbourg.gif')
item = can1.create_image(481, 86, image =photo)
 
photo3 = PhotoImage(file ='boussole.gif')
photo4 = PhotoImage(file ='N.gif')
photo5 = PhotoImage(file ='NE.gif')
photo6 = PhotoImage(file ='E.gif')
photo7 = PhotoImage(file ='SE.gif')
photo8 = PhotoImage(file ='S.gif')
photo9 = PhotoImage(file ='SO.gif')
photo10 = PhotoImage(file ='O.gif')
photo11 = PhotoImage(file ='NO.gif')
 
liste=[can3.create_image(90, 86, image =photo3),
can3.create_image(-990, 86, image =photo4),
can3.create_image(-990, 86, image =photo5),
can3.create_image(-990, 86, image =photo6),
can3.create_image(-990, 86, image =photo7),
can3.create_image(-990, 86, image =photo8),
can3.create_image(-990, 86, image =photo9),
can3.create_image(-990, 86, image =photo10),
can3.create_image(-990, 86, image =photo11)]
 
photo12 = PhotoImage(file ='vide.gif')
photo13 = PhotoImage(file ='negatif.gif')
photo14 = PhotoImage(file ='zero.gif')
photo15 = PhotoImage(file ='10.gif')
photo16 = PhotoImage(file ='20.gif')
photo17 = PhotoImage(file ='30.gif')
photo18 = PhotoImage(file ='40.gif')
photo19 = PhotoImage(file ='50.gif')
photo20 = PhotoImage(file ='maxi.gif')
 
liste2=[can.create_image(90, 86, image =photo12),
can.create_image(-990, 86, image =photo13),
can.create_image(-990, 86, image =photo14),
can.create_image(-990, 86, image =photo15),
can.create_image(-990, 86, image =photo16),
can.create_image(-990, 86, image =photo17),
can.create_image(-990, 86, image =photo18),
can.create_image(-990, 86, image =photo19),
can.create_image(-990, 86, image =photo20)]
 
photo21 = PhotoImage(file ='vent.gif')
photo22 = PhotoImage(file ='v1.gif')
photo23 = PhotoImage(file ='v2.gif')
photo24 = PhotoImage(file ='v3.gif')
photo25 = PhotoImage(file ='v4.gif')
photo26 = PhotoImage(file ='v5.gif')
photo27 = PhotoImage(file ='v6.gif')
photo28 = PhotoImage(file ='v7.gif')
photo29 = PhotoImage(file ='v8.gif')
 
liste3=[can2.create_image(90, 86, image =photo21),
can2.create_image(-990, 86, image =photo22),
can2.create_image(-990, 86, image =photo23),
can2.create_image(-990, 86, image =photo24),
can2.create_image(-990, 86, image =photo25),
can2.create_image(-990, 86, image =photo26),
can2.create_image(-990, 86, image =photo27),
can2.create_image(-990, 86, image =photo28),
can2.create_image(-990, 86, image =photo29)]
 
 
tex1=Label(f,text='     '+u'°C',font=('LCDmono ultra',20),fg='blue')
tex2=Label(f,text='     ',font=('LCDmono ultra',20),fg='blue')
tex3=Label(f,text='     '+'km/h',font=('LCDmono ultra',20),fg='blue')
tex4=Label(f,text='STATION METEO \n Bienvenue',font=('Verdana',30,'bold'),fg='blue',bd=2,relief=SOLID)
tex5=Label(f,text='Réalisé par \n E.THOMAS',font=('Verdana',10,'bold'),fg='blue',bd=1,relief=SOLID)
 
tex6=Label(f,text=strftime("%a, %d %b %Y   \n  %H:%M:%S", gmtime()),font=('Chiller',15))
b0=Button(f, text='Programme \n de \n Convertion',width=11,height=3,font=('Chiller',15),fg='black',command=convertisseur)
b2=Button(f, text='Graphique \n Vitesse \n Vent',font=('Chiller',15),fg='black',width=11,height=3,command=vitesse)
b3=Button(f, text='Graphique \n Direction \n Vent',font=('Chiller',15),fg='black',width=11,height=3,command=direction)
b4=Button(f, text='Graphique \n Température',font=('Chiller',15),fg='black',width=11,height=3,command=temperature)
b5=Button(f, text='Quitter',font=('Chiller',15),fg='red',width=11,height=1, command = fen.quit)
b6=Button(f, text=' Alarmes \n Réglages',font=('Chiller',15),fg='black',width=11,height=3,command=alarme)
b7=Button (f, text = 'Démarrer la \n liaison série',font=('Chiller',15),fg='black',command=liaison)
 
#*********************************************************************************************************
 
 
b0.grid(row=4,column=6)
b2.grid(row=4,column=3)
b3.grid(row=4,column=4)
b4.grid(row=4,column=2)
b5.grid(row=6,column=6)
b6.grid(row=3,column=6)
b7.grid(row=3,column=1)
can.grid(row=6,column=2)
can1.grid(row=2,column=1,columnspan=6,pady=20)
can2.grid(row=6,column=3)
can3.grid(row=6,column=4)
tex1.grid(row=5,column=2)
tex2.grid(row=5,column=4)
tex3.grid(row=5,column=3)
tex4.grid(row=1,column=2,columnspan=3,sticky=N)
tex5.grid(row=1,column=1,sticky=NW)
tex6.grid(row=1,column=6,sticky=NE)
 
seconde()
 
fen.mainloop()
fen.destroy()
ser.close()
fin=1
Merci beaucoup!!


Perchman