#defines the homepage
def homescreen():
global button1
global button2
global button3
# sprite = codesters.Circle(x, y, diameter, "color")
head1 = codesters.Text("Home Screen",0,200)
head1.set_size(1.5)
button1 = codesters.Circle(-130, -190, 70, "blue")
button1.say("Button 1")
button2 = codesters.Circle(0, -190, 70, "blue")
button2.say("Button 2")
button3 = codesters.Circle(130, -190, 70, "blue")
button3.say("Button 3")
#Calls the function to create the homepage
homescreen()
#Click function for Button 1 - an image or word could be added to the button
#The click event would then be changed to the image or text name.
#Inside each click event there is a way to return to the homepage. This is
#another click event based in the goback sprite.
def click(button1):
sprite = codesters.Sprite("White_Rec_456")
backbutton = codesters.Circle(-190, 130, 70, "blue")
goback = codesters.Text("Home", -190, 130, "white")
goback.set_size(.85)
# sprite = codesters.Text("text")
spritet = codesters.Text("Sample Screen")
spritet.goto( -9, 210)
spritet.set_size(1.5)
sprite1 = codesters.Sprite("kitten")
sprite1.goto( -6, 26)
sprite = codesters.Text("This is a kitten.")
sprite.goto(-15, -163)
def click(goback):
sprite = codesters.Sprite("White_Rec_456")
homescreen()
goback.event_click(click)
button1.event_click(click)
#Click function for Button 2 - an image or word could be added to the button
#The click event would then be changed to the image or text name
#Inside each click event there is a way to return to the homepage. This is
#another click event based in the goback sprite.
def click(button2):
sprite = codesters.Sprite("White_Rec_456")
backbutton = codesters.Circle(-190, 130, 70, "blue")
goback = codesters.Text("Home", -190, 130, "white")
goback.set_size(.85)
# sprite = codesters.Text("text")
spritet = codesters.Text("Sample Screen")
spritet.goto( -9, 210)
spritet.set_size(1.5)
sprite1 = codesters.Sprite("dog")
sprite1.goto( -6, 26)
sprite = codesters.Text("This is a dog.")
sprite.goto(-15, -163)
def click(goback):
sprite = codesters.Sprite("White_Rec_456")
homescreen()
goback.event_click(click)
button2.event_click(click)
#Click function for Button 3 - an image or word could be added to the button
#The click event would then be changed to the image or text name
#Inside each click event there is a way to return to the homepage. This is
#another click event based in the goback sprite.
def click(button3):
sprite = codesters.Sprite("White_Rec_456")
backbutton = codesters.Circle(-190, 130, 70, "blue")
goback = codesters.Text("Home", -190, 130, "white")
goback.set_size(.85)
# sprite = codesters.Text("text")
spritet = codesters.Text("Sample Screen")
spritet.goto( -9, 210)
spritet.set_size(1.5)
sprite1 = codesters.Sprite("ghost")
sprite1.goto( -6, 26)
sprite = codesters.Text("This is a ghost.")
sprite.goto(-15, -163)
def click(goback):
sprite = codesters.Sprite("White_Rec_456")
homescreen()
goback.event_click(click)
button3.event_click(click)
-
Run Code
-
-
Stop Running Code
-
Show Chart
-
Show Console
-
Codesters How To (opens in a new tab)