Je veux utiliser wx.CallLater: J'ai deux fonctions et ils doivent s'appeler en boucle, mais avec une pause de 3 secondes avant chaque appel. Le problème est: Quand mon programme est dans "goto01" il attend correctement 3 secondes avant que "Notify" ne soit appelé. Mais quand le programme est dans "Notify" alors "goto01" est appelé immédiatement. Pourquoi n'y a-t-il pas de pause de 3 secondes à ce stade? Voici mon code & dans la dernière ligne de chacune des fonctions tant que j'ai un événement wx.CallLater:wx.CallLater ne fonctionne pas pour moi
self.speed = 3000
def Notify(self):
self.zeit.Destroy()
self.zeitint = self.zeitint + 1
time = round(self.zeitint/2)
self.zeit = wx.StaticText(self.friendlygamepanel, -1, '%d. Spielminute'%(time), (325+self.dx,9))
try:
self.ticker.Destroy()
self.picplayer1but.Destroy()
except:
pass
if self.zeitint % 2 == 1:
self.ticker = wx.TextCtrl(self, -1, teamname[0]+' ist im Ballbesitz.',
size=(340, 320), pos=(195+self.dx,160), style=wx.TE_RICH2|wx.TE_MULTILINE|wx.TE_NO_VSCROLL)
self.ticker.SetBackgroundColour((128,191,130))
self.ticker.SetStyle(0, len(teamname[0]), wx.TextAttr("BLACK", wx.NullColour, self.font))
wx.CallLater(int(self.speed),self.goto01(players,self.playerpics))
else:
self.ticker = wx.TextCtrl(self, -1, oppteamname[0]+' ist im Ballbesitz.',
size=(340, 320), pos=(195+self.dx,160), style=wx.TE_RICH2|wx.TE_MULTILINE|wx.TE_NO_VSCROLL)
self.ticker.SetBackgroundColour((205,173,65))
self.ticker.SetStyle(0, len(oppteamname[0]), wx.TextAttr("BLACK", wx.NullColour, self.font))
wx.CallLater(int(self.speed),self.goto01(oppplayers,self.oppplayerpics))
def goto01(self,theplayer,thepicture):
if self.zeitint % 2 == 1:
picpos = 0
else:
picpos = 460
self.whichplayer = random.randint(0,2)
self.whichoppplayer = random.randint(0,2)
last = self.ticker.GetLastPosition()
self.ticker.AppendText('\n\n'+theplayer[self.whichplayer][0]+' hat den Ball.')
self.ticker.SetStyle(last, last+2+len(theplayer[self.whichplayer][0]), wx.TextAttr("BLACK", wx.NullColour, self.font))
self.picplayer1 = wx.Image(thepicture[self.whichplayer], wx.BITMAP_TYPE_BMP).ConvertToBitmap()
self.picplayer1but = wx.BitmapButton(self.friendlygamepanel,-1,self.picplayer1,pos=(90+self.dx+picpos,180))
if self.zeitint < 60:
wx.CallLater(int(self.speed),self.Notify)
millisecondes Ca y est, vous avez écrit 'numberOfSecs' – FogleBird
Trop vrai. Désolé pour ça. Fixé! –