Python Forum
Short font question - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: Short font question (/thread-22757.html)



Short font question - Pizzas391 - Nov-25-2019

Hello, I know how to make a square and how to make a font, but I have a problem, when I have the square and text on the same place, you don't see the text, only the square (sometimes both but then it flashes real fast). I guess that the text is behind the "image", how do I get it in front of the image, is there a code?

I use python 3 (graphics in turtle)


RE: Short font question - ichabod801 - Nov-25-2019

Turtle generally draws over what was there before. So if you want the text on top of the square, draw the square first and the text second.


RE: Short font question - Pizzas391 - Nov-25-2019

(Nov-25-2019, 09:59 PM)ichabod801 Wrote: Turtle generally draws over what was there before. So if you want the text on top of the square, draw the square first and the text second.

Thanks for your answer, forgot to mention it but I did that it was the most logical thing to do, didn't help though (well, kinda, than that flashing happens (like it wants to show both at the same time).

If you want to see my code, I can post it tomorrow...


RE: Short font question - ichabod801 - Nov-25-2019

Yeah, need to see code. If you have a lot of code, write a short bit that duplicates the problem.


RE: Short font question - Pizzas391 - Nov-26-2019

(Nov-25-2019, 10:48 PM)ichabod801 Wrote: Yeah, need to see code. If you have a lot of code, write a short bit that duplicates the problem.

code (i know 'goto' isn't very professional):

#winner_a
pen_a = turtle.Turtle()
pen_a.speed(0)
pen_a.color("black")
pen_a.penup()
pen_a.hideturtle()
pen_a.goto(0, 0)
pen_a.write(" ", align="center", font=("Arial", 24, "normal"))



    #winner screen
    if score_a > 0:
        winner_a = turtle.Turtle()
        winner_a.speed(0)
        winner_a.shape("square")
        winner_a.color("#32CD32")
        winner_a.shapesize(stretch_wid=600, stretch_len=800)
        winner_a.penup()
        winner_a.goto(0, 0)
        pen_a.write("Player A is the Winner", align="center", font=("Arial", 24, "normal")) pyxel.run(update,draw)



RE: Short font question - buran - Nov-26-2019

(Nov-26-2019, 04:31 PM)Pizzas391 Wrote: i know 'goto' isn't very professional
in this case goto is method of turtle object moving it around the screen
what may be considered unprofessional is using goto statement to jump between different positions in the script :-) (note there is no goto statement in python)
https://en.wikipedia.org/wiki/Goto


RE: Short font question - Pizzas391 - Nov-26-2019

Thanks, didn't knew that! But do you also know a solution for my font Tongue ?


RE: Short font question - ichabod801 - Nov-26-2019

The turtle code works fine. That is, I commented out the pyxel call (after correcting the syntax error), and the turtle code worked fine. I expect the problem is the pyxel code, although I am not really familiar with that package. It doesn't look like it's designed to work with turtle. I would note that the color you have in your code ("#32CD32") is not one of the 16 supported by pyxel.


RE: Short font question - Pizzas391 - Nov-27-2019

(Nov-26-2019, 05:12 PM)ichabod801 Wrote: The turtle code works fine. That is, I commented out the pyxel call (after correcting the syntax error), and the turtle code worked fine. I expect the problem is the pyxel code, although I am not really familiar with that package. It doesn't look like it's designed to work with turtle. I would note that the color you have in your code ("#32CD32") is not one of the 16 supported by pyxel.



Thanks for this information, didn't work though...
Think the problem is using turtle. I want to learn pygame soon so I can try that


RE: Short font question - ichabod801 - Nov-27-2019

No, the problem isn't turtle. Show the modified code that is still giving you problems.