Bonjour,
Je suis sous python 3.4.3 et j'ai le problème suivant:
Il faudrait exécuter le class qu'une seule fois et ensuite quitter la loop de la class pour passer à la suite du programme. La partie du code où est la Class est la suivante :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72 root = Tk() app=Application(master=root) app.mainloop() root.destroy() class Application(Frame): def Left(self): global x global y global Tabl x=x-30 can.coords(Per,x,y) print ("lol") def Right(self): global x global y global Tabl x=x+30 can.coords(Per,x,y) print ("lol") def Top(self): global x global y global Tabl y=y-30 can.coords(Per,x,y) print ("lol") def Bottom(self): global x global y global Tabl y=y+30 can.coords(Per,x,y) print ("lol") def createWidgets(self): self.LEFT = Button(self) self.LEFT["text"] = "Gauche" self.LEFT["fg"] = "blue" self.LEFT["command"] = self.Left self.LEFT["command"] = self.quit #Ici j'aimerais qu'il exécute self.Left une seule fois puis qu'il arrête tout. En gros il faudrait exécuter self.Left et ensuite self.quit. self.LEFT.pack({"side": "left"}) self.RIGHT = Button(self) self.RIGHT["text"] = "Droite" self.RIGHT["fg"] = "purple" self.RIGHT["command"] = self.Right self.RIGHT["command"] = self.quit self.RIGHT.pack({"side": "right"}) self.TOP = Button(self) self.TOP["text"] = "Haut" self.TOP["fg"] = "green" self.TOP["command"] = self.Top self.TOP["command"] = self.quit self.TOP.pack({"side": "top"}) self.BOTTOM = Button(self) self.BOTTOM["text"] = "Bas" self.BOTTOM["fg"] = "red" self.BOTTOM["command"] = self.Bottom self.BOTTOM["command"] = self.quit self.BOTTOM.pack({"side": "bottom"}) def __init__(self, master=None): Frame.__init__(self, master) self.pack() self.createWidgets()
Je vous remercie d'avance pour votre aide.
Partager