Python Turtle module writing doesn't show up on screen

Question:

I am looking to create a starting screen for a simple game, this is the StartingScreen class (in starting_screen.py):

from turtle import Turtle

class StartingScreen(Turtle):
    def __init__(self):
        super().__init__()
        self.penup()
        self.color("white")
        self.hideturtle()
        self.write(arg="First to 5 wins!", align="center", font=("Courier", 25, "normal"))

And this is where I call it:

from turtle import Screen
from starting_screen import StartingScreen
screen = Screen()
screen.bgcolor("black")
screen.setup(width=800, height=600)
screen.title("Pong Game")
starting_screen = StartingScreen
screen.exitonclick()

However when I run it all I get is an empty black screen. Any ideas on how to make it show up?

I have tried just creating a simple turtle and writing with that, which works, but I would like to get it working with it’s own class.

Asked By: szn13

||

Answers:

You forgot to add parentheses starting_screen = StartingScreen.

it should we like this


starting_screen = StartingScreen()

enter image description here

Answered By: codester_09
Categories: questions Tags:
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.