bonjour tout le monde je suis un nouveau sur python car je me suis plus intéressé a arduino j'ai donc voulu conjuguer les deux et créé une interface tkinter voici mon 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
 
from tkinter import Tk, Label, Button
from tkinter import ttk
import tkinter as TK
from tkinter import *
import serial
import time
 
#/!\/!\/!\/!\/!\/!\/!\/!\/!\/!\/!\/!\/!\/!\/!\/!\/!\/!\/!\/!\/!\/!\
# attention ce programme ne fonctionne que si
#on boucle un print"hello"
#sur l'arduino sinon la fenetre windows se"gele"
#et le prgm cesse de fonctionner
#/!\/!\/!\/!\/!\/!\/!\/!\/!\/!\/!\/!\/!\/!\/!\/!\/!\/!\/!\/!\/!\/!\
class MyFirstGUI:
    def __init__(self, master):
      global var
      global box_value
 
      self.master = master
      master.title("A simple GUI")
      master.configure(width=325,height=600)
      var = TK.StringVar()
      u=TK.IntVar
      donnee = StringVar()
      donnee2 = TK.StringVar()
      index = IntVar()
      box_value = StringVar()
 
 
 
      self.box = ttk.Combobox( textvariable=box_value,value=box_value)
      self.box['values'] = ('300', '1200', '2400','4800','9600','19200','38400','57600')
 
      self.box.current(0)
      self.box.place(x=10,y=220)
 
 
      self.champ_label1 = Label(master, bg='white', text="Serial com for arduino",relief=FLAT) 
      self.champ_label1.place(x=42,y=0)
      self.champ_label2 = Label(master, bg='white', text="select the usb com: ",relief=FLAT) 
      self.champ_label2.place(x=0,y=40) 
      self.bouton_1 = Radiobutton(master, text="com0", variable=var, value='COM0') 
      self.bouton_2 = Radiobutton(master, text="com1", variable=var, value='COM1') 
      self.bouton_3 = Radiobutton(master, text="com2", variable=var, value='COM2') 
      self.bouton_4 = Radiobutton(master, text="com3", variable=var, value='COM3')  
      self.bouton_5 = Radiobutton(master, text="com4", variable=var, value='COM4') 
      self.bouton_6 = Radiobutton(master, text="com5", variable=var, value='COM5') 
      self.bouton_7 = Radiobutton(master, text="com6", variable=var, value='COM6') 
      self.bouton_8 = Radiobutton(master, text="com7", variable=var, value='COM7') 
      self.bouton_9 = Radiobutton(master, text="com8", variable=var, value='COM8') 
      self.bouton_10 = Radiobutton(master, text="com9", variable=var, value='COM9') 
 
      self.bouton_1.place(x=10 , y =70 ) 
      self.bouton_2.place(x=100, y = 70)
      self.bouton_3.place(x=190, y =70 ) 
      self.bouton_4.place(x=10, y = 95)
      self.bouton_5.place(x= 100, y =95 ) 
      self.bouton_6.place(x=190, y = 95)
      self.bouton_7.place(x=10, y = 120) 
      self.bouton_8.place(x=100, y =120 )
      self.bouton_9.place(x=190, y = 120) 
      self.bouton_10.place(x=10, y = 145)
 
      self.champ_label5=Label(master,bg='white',text='numero de port com choissi à : ',relief=FLAT)
      self.champ_label5.place(x=0 ,y=260 )
      self.champ_label = Label(master, bg='white', textvariable= var,relief=FLAT) 
      self.champ_label.place(x=205,y=260)
 
      self.champ_label6=Label(master,bg='white',text=' et nombre de baud choissi à : ',relief=FLAT)
      self.champ_label6.place(x=0 ,y=280 )
 
      self.champ_label3 = Label(master, bg='white', textvariable=box_value, relief=FLAT) 
      self.champ_label3.place(x=200,y=280) 
 
      self.champ_label6=Label(master,bg='white',text='cliquez sur ready pour lancez la communication',relief=FLAT)
      self.champ_label6.place(x=0,y=320)
 
      self.champ_label7=Label(master,bg='white',text='serie avec les parametre choisi',relief=FLAT)
      self.champ_label7.place(x=0,y=340)
 
      self.S = Scrollbar(master)
      self.T = Text(master, height=4, width=28)
      self.S.place(x=283,y=427)
      self.T.place(x=0,y=425)
 
      saisir=StringVar() # prevoir la variable pour recevoir le texte saisi 
      self.saisir=saisir
      saisir.set("mettre le texte par défaut ici") 
      self.saisie=Entry(master,textvariable=saisir, width=40,justify=CENTER) 
      self.saisie.place(x=0,y=500)
      self.bouton_11=Button(master,text="ready",command=self.valid)
      self.bouton_12=Button(master,text="quittter",command=master.quit)
 
      self.bouton_11.place(x=10 ,y=370)
      self.bouton_12.place(x=240 ,y=370)
      self.bouton_13=Button(master,text="valider",command=self.valid2)
 
 
    def valid2 (self):
         txtentry=self.saisir.get()
         ser.write(txtentry.encode('ascii'))
         print("data sent")
    def valid (self) :
 
     global ser
     donnee =var.get()
 
     print("donnee= ")
     print(donnee)
     donnee2=box_value.get()
     print(donnee2)
     ser = serial.Serial(donnee,donnee2)
     print (ser)
     self.bouton_13.place(x=10 ,y=530 )
     self.bouton_14=Button(self.master,text="setup",command=ser.close)
     self.bouton_14.place(x=240,y=530)
     while True:
        if ser.isOpen():
            x = ser.readline()
            y=str(x)[2:-5]
            self.S.config(command=self.T.yview)
            self.T.config(yscrollcommand=self.S.set)
            self.T.insert(END, y)
            self.master.update()
        else:
            break
root = Tk()
my_gui = MyFirstGUI(root)
root.mainloop()
petit problème comme indiqué au debut de mon programme la fenêtre plante je precise que j'utilise python portable 3.2.5.1

merci de votre aide ^^