Twitter iPhone pliant OnePlus 11 PS5 Disney+ Orange Livebox Windows 11

programme au ralenti et bloqué

1 réponse
Avatar
oliv
voilà le programme suivant affiche un bouliuer et à chaque tirage un nombre différent de boules est surligné. Seulement, au bout d'un certain nombre de tirages, le programme affiche au ralenti, et au bout d'un grand nombre de tirage il met très longtemps à se fermer, voire affiche un message d'erreur. J'ai l'impression que ce programme sature la mémoire de l'ordi
quelqu'un a-t-il une explication, ou mieux une solutio

le programme
# -*- coding: iso-8859-1 -*-
class Application
def __init__(self)

##Constructeur de la fenetre principale#
self.root =Tk(
self.root.resizable(0,0)
self.root.geometry('750x580+0+0'

##initialisation des variables##
self.maxidiz=
self.nbmaxi=self.maxidiz*10+
self.coul="blue
self.indiccoul=

###placer le bouton tirage##
self.bou3=Button(self.root, text ='tirage ',bg='light green',command =lambda : self.boulier(50)
self.bou3.place(relx=0.85, rely=0.90, anchor=CENTER


self.root.mainloop(


####les deuxfonction pour dessiner le boulier : boulier + boules#

def boulier(self,posx)

print "boulier

import random
self.tirage=random.randint(1,self.nbmaxi

h=
v=
for i in range (0,100)
self.couleurboule='yellow
if 10>i>4
self.couleurboule='orange
if 20>i>14
self.couleurboule='orange
if 30>i>24
self.couleurboule='orange
if 40>i>34
self.couleurboule='orange
if 50>i>44
self.couleurboule='orange
if 60>i>54
self.couleurboule='orange
if 70>i>64
self.couleurboule='orange
if 80>i>74
self.couleurboule='orange
if 90>i>84
self.couleurboule='orange
if 100>i>94
self.couleurboule='orange
h=h+
if i==10
v=
h=
if i==20
v=
h=

if i==30
v=
h=

if i==40
v=
h=


if i ==50
v=
self.lignecinquante = Canvas(self.root, width=245, height =8, bg="black"
self.lignecinquante.place(relx=0.215+0.033*h, rely=0.33+0.040*v, anchor=CENTER

v=
h=
if i==60
v=
h=
if i==70
v=
h=
if i==80
v=
h=
if i==90
v=1
h=
self.boules(h,v,i

def boules(self,h,v,i)

self.boule = Canvas(self.root, width=24, height =24
self.boule.create_oval(22,22, 4, 4, width =1, outline ='black', fill =self.couleurboule
self.boule.create_line(0, 12, 5, 12, width =2)
self.boule.create_line(22, 12, 25, 12, width =2)
self.boule.place(relx=0.40+0.033*h, rely=0.33+0.039*v, anchor=CENTER
if i<self.tirage:
self.boule.config(bg='blue'



# Programme principal
from Tkinter import
import webbrowse
import o
f = Application() # instanciation de l'objet applicatio

--
oliv

-----------------------------------------------------------------------
Voir theme: http://www.frbox.net/viewtopic-560073.htm

Envoyé de http://www.frbox.ne

1 réponse

Avatar
Michel Claveau
Bonsoir !

Je ne pratique pas TK.
Mais, je me pose une question : tu crées beaucoup de boules (+lignes
+canevas) ; mais, quand sont-elles détruites ?

--
@-salutations

Michel Claveau