Bonjour, j'aimerai réaliser une sorte de moniteur série sur tkinter qui recoit les infos envoyées sur le port série par l'Arduino et les affiche sur un widget texte. J'ai déjà ce 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
from tkinter import *
import tkinter as tk
import tkinter.messagebox
import tkinter.filedialog
from PIL import ImageTk, Image
import serial
 
 
#CRéation de la fenetre
root = tk.Tk() #On initialise la fenetre
root.title('Inetrface')#On nomme la fenetre
 
 
 
 
#Creation de l'arriere plan et de la taille de la fenetee
image1 = ImageTk.PhotoImage(Image.open("Fichiers annexes\Fondd.png"))
w = image1.width()
h = image1.height()
root.geometry("%dx%d+0+0" % (w, h))
fond = tk.Label(root, image=image1)
fond.pack()
 
log = Text( root, width=30, height=30, takefocus=0)
log.place(x=1300, y=300, anchor='w')
 
# make a scrollbar
scrollbar = Scrollbar(root)
scrollbar.pack(side=RIGHT, fill=Y)
 
# attach text box to scrollbar
log.config(yscrollcommand=scrollbar.set)
scrollbar.config(command=log.yview)
 
 
 
arduinoData = serial.Serial('COM8',9600)
 
def quitter():
    root.destroy()
 
 
def Acqard():
    arduinoData.write(b'1')
 
def stopacq():
    arduinoData.write(b'2')
 
 
#Creation du bouton de validation
Bouton = tk.Button(root, text ="LANCER L'ACQUISITION",command = Acqard, font = ('Calibri', 15),  overrelief= 'ridge', bg= "#922c17", fg ="white")
Bouton.place(x=765, y=530, anchor='w')
 
#Création du bouton d'arret de la focntion
Bouton = tk.Button(root, text ="Arreter le scan",command = stopacq, font = ('Calibri', 15),  overrelief= 'ridge', bg= "#922c17", fg ="white")
Bouton.place(x=365, y=530, anchor='w')
 
#Création du bouton de quitter
Bouton = tk.Button(root, text ='Quitter',command = quitter, font = ('Calibri', 15), overrelief= 'ridge', bg= "#47280C", fg ="white")
Bouton.place(x=1550, y=900, anchor='se' )
 
 
 
 
root.mainloop()
 
while 1:
    var = arduinoData.read()
    log.insert('0.0', var)
 
 
root.update

Seulement, le while ne fonctionne pas...

Des idées?