Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Short font question
#1
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)
Reply
#2
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.
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures
Reply
#3
(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...
Reply
#4
Yeah, need to see code. If you have a lot of code, write a short bit that duplicates the problem.
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures
Reply
#5
(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)
Reply
#6
(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
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply
#7
Thanks, didn't knew that! But do you also know a solution for my font Tongue ?
Reply
#8
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.
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures
Reply
#9
(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
Reply
#10
No, the problem isn't turtle. Show the modified code that is still giving you problems.
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Short code for EventGhost not working Patricia 8 3,702 Feb-09-2021, 07:49 PM
Last Post: Patricia
  Load external font and does not show font in the window ATARI_LIVE 16 8,185 Feb-05-2021, 10:36 PM
Last Post: EthanPayne
  How can I make a short-key in Spyder (Python IDE)? moose 3 2,690 Nov-02-2020, 12:13 PM
Last Post: jefsummers
  Add DSIG to TTF font using ttx font tool Adrian 1 3,782 Nov-11-2017, 12:05 PM
Last Post: Adrian
  float.hex() is one bit short Skaperen 4 4,120 Jul-26-2017, 03:53 AM
Last Post: Skaperen
  short way to combine tuples and int's Annie 6 4,553 Jun-16-2017, 02:35 AM
Last Post: Annie

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020