Je voudrais supprimer le texte que j'ai graphiquement affiché afin que je puisse écrire le nouveau texte sans chevauchement. J'ai inclus mon code ci-dessous. Merci encore pour votre temps.Comment supprimer le texte graphique Zelle de l'écran en Python?
from graphics import*
import random
# Function for winning
def youwin():
txt = Text(Point(250,100), "You are a Winner!")
txt.setTextColor(color_rgb(0,255,200))
txt.setSize(30)
txt.setFace('courier')
txt.draw(win)
# Function for losing
def youlose():
txt= Text(Point(250,100), "You are a Loser!")
txt.setTextColor(color_rgb(0,255,0))
txt.setSize(30)
txt.setFace('courier')
txt.draw(win)
# Sets a Window
win = GraphWin("My Window", 800, 600)
win.setBackground('White')
# loops 10 Times and picks out 3 random gif's.
# Then displays each image on the screen in a row.
for x in range(10):
cards = ["1.png","2.png","3.png"]
rand_card1 = random.choice(cards)
img1 = Image(Point(100, 250), rand_card1)
rand_card2 = random.choice(cards)
img2 = Image(Point(300, 250), rand_card2)
rand_card3 = random.choice(cards)
img3 = Image(Point(500, 250), rand_card3)
img1.draw(win)
img2.draw(win)
img3.draw(win)
# checks to see if you are a winner
if rand_card1 == rand_card2 and rand_card2 == rand_card3:
youwin()
else:
youlose()
# waits for a mouse click. In the future this will be a button.
win.getMouse()
img1.undraw()
img2.undraw()
img3.undraw()
#win.close()#
C'est la sortie que je reçois actuellement:
Je ne suis pas très familier avec ce que vous utilisez, mais j'imagine que vous voudrez peut-être effacer votre zone de dessin avant d'y dessiner un nouveau texte. Je chercherais une fonction d'effacement d'écran ou dessinerais un rectangle sur l'ancien texte de la même couleur que l'arrière-plan. Peut-être que quelqu'un de plus compétent que moi obtiendra ce que je dis et affichera le code exact ci-dessous ... Mais c'est ce que mon approche générale serait. –
Merci, Chris, le rectangle a fonctionné !!! Je suis sûr que je ne suis pas en train de coder efficacement, mais en tant que débutant, je vais prendre ce que je peux obtenir :) Pouvez-vous transformer votre commentaire en une réponse afin que je puisse upvote? – Jason
[Terminé.] (Https://stackoverflow.com/a/44479477/3775798) –