title: threading with event in Tkinter
body: <p>In my project, when the user clicks on a button, a window asking him to wait is displayed. This window contains an animation (a spinning apron) and closes automatically when processing is finished. Only, since this processing takes time, the window freezes, so the animation only starts at the end.
  So I would like this animation to fire throughout processing without the window freezing.
  here is my class which allows to define a gif. I then use this gif (which is an Animation object) as a button, which will trigger a function:</p>
  <pre><code>class Animation():
      def __init__(self, fenetre, cheminGif, placementX, placementY, frequence, modeFonctionnement=&quot;ss&quot;, command=False):
          self.fenetre = fenetre
          self.cheminGif = path_pour_wrapExe(cheminGif)
          self.placementX = placementX
          self.placementY = placementY
          
          
          self.info = Image.open(path_pour_wrapExe(self.cheminGif))
          self.frames = self.info.n_frames  # nombre total de frames que le gif contient
          self.im = [tkinter.PhotoImage(file=self.cheminGif,format=f&quot;gif -index {i}&quot;) for i in range(self.frames)]
          self.count = 0
          self.anim = None
          self.gif_label = tkinter.Label(self.fenetre,image=&quot;&quot;,bg=&quot;black&quot;)
          self.gif_label.place(x=self.placementX, y=self.placementY)
          self.frequence = frequence
          self.modeFonctionnement = modeFonctionnement
          self.command = command
          
          
          def animation(self):
              self.im2 = self.im[self.count]
              self.gif_label.configure(image=self.im2)
              self.count += 1
              if self.count == self.frames:
                  self.count = 0
              self.anim = self.fenetre.after(self.frequence,lambda :animation(self))
              
          def stop_animation(self):
              self.fenetre.after_cancel(self.anim)
              
          def testdd(event):
              print(&quot;je survol la zone du gif&quot;)
              animation(self)
              
          def binderLeave(event):
              self.frequence = 100
              stop_animation(self)
              
          def uniqueImageAnimation(self):
              self.im2 = self.im[self.count]
              self.gif_label.configure(image=self.im2)
              
          if self.modeFonctionnement == &quot;ss&quot;: # mode animation start and stop selon evenement
              uniqueImageAnimation(self)
              self.gif_label.bind(&quot;&lt;Leave&gt;&quot;,binderLeave)
              self.gif_label.bind(&quot;&lt;Enter&gt;&quot;,testdd)
          if self.modeFonctionnement == &quot;ssc&quot;: # mode animation start and stop selon evenement avec commandement
              uniqueImageAnimation(self)
              self.gif_label.bind(&quot;&lt;Leave&gt;&quot;,binderLeave)
              self.gif_label.bind(&quot;&lt;Enter&gt;&quot;,testdd)
              self.gif_label.bind(&quot;&lt;Button-1&gt;&quot;, self.command)      
          if self.modeFonctionnement == &quot;inf&quot;: # mode animation infini sans commandement
              animation(self)
          if self.modeFonctionnement == &quot;infcom&quot;:
              animation(self)
              self.gif_label.bind(&quot;&lt;Button-1&gt;&quot;, self.command) 
              
      def detruire(self):
          self.gif_label.place_forget()
  </code></pre>
  <p>Later in my code, I retrieve the select chosen by the user, and depending on the select, the Animation button will trigger a function that executes a long process.
  What I want is that when clicking on the Animation button, the gif does not freeze and the processing is done in parallel.
  And for that, if I understood correctly, you have to use the thread. So I tried this, but I don't know how to embed the event...</p>
  <pre><code>    Animation(canvas, path_pour_wrapExe(&quot;images/cat7.gif&quot;),300,198,200,&quot;infcom&quot;,threading.Thread(target=recupererSelect).start())
  </code></pre>
  <p>I get this error message, knowing that &quot;event&quot; is in the parameter of my recupererSelect function. If I don't put it, I'm told that an argument is missing, and if I put it, it doesn't recognize it!</p>
  <p>TypeError: recupererSelect() missing 1 required positional argument: 'event'</p>
  <p>How should I proceed so that my gif which triggers my retrieveSelect function (via an event on click and the command argument of my class) can continue to animate?</p>
  <p>edit 29/06: Anyone has a suggestion please?</p>