<html>
<head>
<style>
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 10pt;
font-family:Verdana
}
</style>
</head>
<body class='hmmessage'>
Hello, thanks for your answer. Gerdus van Zyl, I tried your idea and it's much better, but not perfect. The speed is ok, but, I don't know why, there are more than one image which follow the mouse (trails).<BR>Here is a part of my code :<BR>class Echiquier(gtk.DrawingArea):<BR><BR> def __init__(self, largeurCase, positionDepartDonnee, echiquier, fen, blancsAJouer):<BR>         super(Echiquier, self).__init__()<BR> <BR>         [...]<BR>         self.connect("expose-event", self.expose, blancsAJouer)<BR>         self.add_events(gtk.gdk.BUTTON_PRESS_MASK | gtk.gdk.BUTTON_RELEASE_MASK | gtk.gdk.BUTTON1_MOTION_MASK)<BR>         self.connect("button-press-event", self.piecePrise)<BR>         self.connect("motion-notify-event", self.pieceBouge)<BR>         self.connect("button-release-event", self.pieceRelache)<BR>         self.echiquier = echiquier<BR>         self.FEN = fen<BR> <BR>         [...]<BR> <BR>         self.pionBlanc = gtk.gdk.pixbuf_new_from_file_at_size('Images/pionB.svg', self.largeurCase, self.largeurCase)<BR>         self.cavalierBlanc = gtk.gdk.pixbuf_new_from_file_at_size('Images/cavalierB.svg', self.largeurCase, self.largeurCase)<BR>         [...]<BR> <BR> def piecePrise(self, widget, evenement):<BR>         if evenement.button == 1:<BR>                 #We remove the piece from the board and we get its (x, y) when the user click on the board<BR>                 self.pieceSelectionneeX = int(evenement.y / self.largeurCase)<BR>                 self.pieceSelectionneeY = int(evenement.x / self.largeurCase)<BR>                 self.pieceSelectionnee = self.echiquier[self.pieceSelectionneeX][self.pieceSelectionneeY]<BR>                 self.echiquier[self.pieceSelectionneeX][self.pieceSelectionneeY] = 'VIDE'<BR> <BR> def pieceBouge(self, widget, evenement):<BR>         if evenement.is_hint:<BR>                 self.posSourisX, self.posSourisY, state = event.window.get_pointer()<BR>         else:<BR>                 self.posSourisX = evenement.x<BR>                 self.posSourisY = evenement.y<BR>                 state = evenement.state<BR>         if state & gtk.gdk.BUTTON1_MASK:<BR>                 #We draw the piece at its new (x, y) when the user moves the mouse<BR>                 contexte = self.window.cairo_create()<BR>                 surface = None<BR>                 if self.pieceSelectionnee == 'PION_B':<BR>                         surface = self.pionBlanc<BR>                 elif self.pieceSelectionnee == 'PION_N':<BR>                         surface = self.pionNoir<BR>                 [...]<BR>                 self.posX = self.posSourisX - self.largeurCase / 2<BR>                 self.posY = self.posSourisY - self.largeurCase / 2<BR>                 contexte.set_source_pixbuf(surface, self.posX, self.posY)<BR>                 contexte.paint()<BR>                 self.queue_draw_area(self.posX - self.largeurCase, self.posY - self.largeurCase, self.posX + self.largeurCase * 2, self.posX + self.largeurCase * 2)<BR> <BR> def pieceRelache(self, widget, evenement):<BR>         #We put the piece at its begining (x, y) when the user releases the mouse button<BR>         self.echiquier[self.pieceSelectionneeX][self.pieceSelectionneeY] = self.pieceSelectionnee<BR>         self.pieceSelectionneeX = -1<BR>         self.pieceSelectionneeY = -1<BR>         self.pieceSelectionnee = 'VIDE'<BR>         self.queue_draw_area(0, 0, self.largeurCase * 8, self.largeurCase * 8)<BR> <BR> def expose(self, widget, evenement, blancsAJouer):<BR>         #We draw again the board<BR>         contexte = widget.window.cairo_create()<BR> <BR>         contexte.set_source_rgb(1, 1, 1)<BR>         contexte.rectangle(0, 0, self.largeurCase * 8, self.largeurCase * 8)<BR>         contexte.fill()<BR> <BR>         contexte.set_source_rgb(0.81, 0.81, 0.81)<BR> <BR>         #We place the piece which follow the mouse<BR>         for i in range(8):<BR>                 for j in range(8):<BR>                         if (i + j) % 2 == 1:<BR>                                 contexte.rectangle(i * self.largeurCase, j * self.largeurCase, self.largeurCase, self.largeurCase)<BR>                                 contexte.fill()<BR>         if self.pieceSelectionnee != 'VIDE':<BR>                 surface = None<BR>                 if self.pieceSelectionnee == 'PION_B':<BR>                         surface = self.pionBlanc<BR>                 elif self.pieceSelectionnee == 'PION_N':<BR>                         surface = self.pionNoir<BR>                 [...]<BR>                 contexte.set_source_pixbuf(surface, self.posX, self.posY)<BR>                 contexte.paint()<BR>How can I improve it ? I don't want trails.<BR><BR>Thanks for your answer.<BR><BR><br /><hr />Créez un personnage à votre image pour votre WL Messenger <a href='http://go.microsoft.com/?linkid=9656622' target='_new'>Venez voir</a></body>
</html>