title: Tkinter -Python3 : turn a literal value in a list into a integral value in a list UPDATE
body: <p>I once posted a question that was very vague and so I decided to be more precise after some research and tutorials. I looked at examples from StackOverflow, and I assembled them together to see if I can get a favorable result. (COPYRIGHT:The code is not mine!)</p>
  
  <p>Here is the layout: </p>
  
  <p>I allow the person to enter a number that is also the name of a rule that will be used in the program. </p>
  
  <p>I have a 1 row of rectangles that looks like a board of 8 columns. Each rectangle, when clicked, changes to another color. There should be a button "OK" that once the person has chose the rule and clicked some rectangles, it should be sent to the code. I would like that the changement of color equals to a value that enters in a list. So in other words, there are 8 values in a list to be entered into the code when the button 'OK' is clicked. For the moment, I would like to see the list that was entered to be posted on the canvas, under the board. </p>
  
  <p>I don't how to add these values to the list, I am blocked when I try to name the values so that it can enter into the list easily, but it doesn't work. Thanks in advance for any advises and if it's still to vague, please let me know so that I can try to be more clear. ^^' </p>
  
  <p>Here is the code that I assembled so far from examples: </p>
  
  <pre><code>    from Tkinter import *
  
      [couleur_resulat = \[\]
      'black'==1
      'white'==0 
  
      class One_Rectangle (): 
          def __init__(self, can, depart_x, depart_y, size):
              self.can=can
              self.id= self.can.create_rectangle((depart_x, depart_y, depart_x+size,depart_y+size), fill='white')
              self.can.tag_bind(self.id, '&lt;ButtonPress-1&gt;', self.set_couleur) 
  
              self.couleur_change=True
  
          def set_couleur(self, event=None): 
              self.couleur_change = not self.couleur_change
              couleur='white' 
              if not self.couleur_change: 
                  couleur='black'  
  
              self.can.itemconfigure(self.id, fill=couleur)
  
  
      fenetre =Tk()
  
      canvas= Canvas(fenetre,width=500, height=500, background='white')
  
      canvas.pack(side=BOTTOM, padx=5, pady=5) 
  
      OR0=One_Rectangle (canvas,110,20, 20)
      OR1=One_Rectangle (canvas,130,20, 20)
      OR2=One_Rectangle (canvas,150,20, 20)
      OR3=One_Rectangle (canvas,170,20, 20)
      OR4=One_Rectangle (canvas,190,20, 20)
      OR5=One_Rectangle (canvas,210,20, 20)
      OR6=One_Rectangle (canvas,230,20, 20)
      OR7=One_Rectangle (canvas,250,20, 20)
      OR8=One_Rectangle (canvas,270,20, 20)
  
      B1=Button(fenetre, text='Quitter', command=fenetre.quit).pack(side=RIGHT, padx=5, pady=5)
      B2=Button(fenetre, text='Relancer').pack(side=LEFT, padx=5, pady=5)   #Mettre une commande pour relancer le programme lorsque c'est termine 
      B3=Button(fenetre, text='OK').pack(side=RIGHT,padx=5, pady=5) #On doit mettre une commande qui recoit et envoie le numero au code GET? 
  
      text1= Label(fenetre, text= 'Regles (1-255):')     
      entr1= Entry(fenetre)
      text1.pack(side= LEFT)
      entr1.pack(side=RIGHT)  
  
  
      fenetre.mainloop()][1]
  </code></pre>
  
  <p>Here is what I receive</p>
  
  <p><img src="https://i.stack.imgur.com/wNFYt.png" alt=""></p>
  
  <hr>
  
  <p>UPDATE: </p>
  
  <p>I have inserted the code that was proposed and I made some modifications. I get a list of the colors, but not in number and not in one single list.For example: 
  ['white']['black']['white']and so on 
   What should I do in order to have for the black = 0 and for the white= 1 and for it to enter all in one list at the same time? I would like to receive this
  [0,0,1,0,0,1,0,1,0]</p>
  
  <pre><code>    from Tkinter import *
  
  couleur_resultat = list(['white' for i in range(9)]) 
  
  
  class One_Rectangle (): 
      def __init__(self, can, depart_x, depart_y, size,data, index):
          self.can=can
          self.id= self.can.create_rectangle((depart_x, depart_y, depart_x+size,depart_y+size), fill='white')
          self.can.tag_bind(self.id, '&lt;ButtonPress-1&gt;', self.set_couleur) 
  
          self._data= data                
          self._index = index = index     
  
          self.couleur_change=True
  
      def set_couleur(self, event=None): 
          self.couleur_change = not self.couleur_change
          couleur='white' 
  
          if not self.couleur_change: 
              couleur='black' 
  
          self._data[self._index] = couleur  
  
          self.can.itemconfigure(self.id, fill=couleur)
  
  
  
  fenetre =Tk()
  
  canvas= Canvas(fenetre,width=500, height=500, background='white')
  
  canvas.pack(side=BOTTOM, padx=5, pady=5) 
  
  
  OR0=One_Rectangle (canvas,110,20, 20, couleur_resultat, 0)
  OR1=One_Rectangle (canvas,130,20, 20, couleur_resultat, 1)
  OR2=One_Rectangle (canvas,150,20, 20, couleur_resultat, 2)
  OR3=One_Rectangle (canvas,170,20, 20, couleur_resultat, 3)
  OR4=One_Rectangle (canvas,190,20, 20, couleur_resultat, 4)
  OR5=One_Rectangle (canvas,210,20, 20, couleur_resultat, 5)
  OR6=One_Rectangle (canvas,230,20, 20, couleur_resultat, 6)
  OR7=One_Rectangle (canvas,250,20, 20, couleur_resultat, 7)
  OR8=One_Rectangle (canvas,270,20, 20, couleur_resultat, 8)
  
  
  
  B1=Button(fenetre, text='Quitter', command=fenetre.quit).pack(side=RIGHT, padx=5, pady=5)
  
  B3=Button(fenetre, text='OK', command= lambda: on_OK_pressed()).pack(side=RIGHT,padx=5, pady=5) 
  
  
  def on_OK_pressed():  
      for couleur in couleur_resultat: 
          'black'==1
          'white'==0 
  
          print [couleur] 
  
  
  fenetre.mainloop()
  </code></pre>