[gcompris-devel] help! canvas refresh

Bruno Coudoin bruno.coudoin at free.fr
Tue Dec 23 14:30:02 UTC 2003


Here is a working code:

  def show_bang(self, a):
    print "show_bang a="+str(a)
    if a==1:
      self.bang_item.set(x=150,y=50)
    elif a==2:
      self.bang_item.set(x=550,y=50)
    elif a==3:
      self.bang_item.set(x=150,y=250)
    else :
      self.bang_item.set(x=550,y=250)
   
           
  def repeat(self):
    print("Gcompris_melody repeat.")
    #self.bang_item.show()
    timer = 0
    for a in self.solution[:]:
      gcompris.sound.play_ogg("melody/son"+str(self.a))
      self.show_bang_timer = gtk.timeout_add(timer, self.show_bang, a)
      timer = timer + 1000


What happens is that sound.play_ogg is multithreaded and queued. You get
the hand always after the call, not after the sound is played.
Here, we loop at full speed and I arm the timer with a second interval.

Never use timer.sleep in gcompris or you sleep the whole gcompris
process including the main event loop. The result is never what you
want.

For the cursor, you can create one but the process is not so easy. Look
at src/gcompris/cursor.h to add your own.

Bruno.


Le mar 23/12/2003 à 21:15, José JORGE a écrit :
> Em Terça, 23 de Dezembro de 2003 19:45, o Bruno Coudoin escreveu:
> > That's strange. There is some rare occasion that needs a forced update.
> >
> > Can you send me your code that I can check.
> I join it
> It is confused code but I've been trying lots of things to get the refresh.
> 
> The idea is 
> 
> for each sound in solution :
>   play the sound
>   show cursor.png over the sound
>   sleep 1
> 
> And I only can view the cursor at the end of the for
> 
> José





More information about the Gcompris-devel mailing list