First, let's make our pumpkin and its properties.
class Pumpkin:
def __init__(self):
self.eyes="No eyes"
self.nose="No nose"
self.mouth="No mouth"
self.misc="No extras"
self.expression="No expression"
So, basically, this program is where you carve a pumpkin, and you can choose the shape of your face. Let's go the simple way, and start the visual part of the program now. But, first, I want to practice an old thing I wrote a long time ago. Put this at the top of your program:
import easygui, time
Alright, now you know I want to practice EasyGUI again! Well, here's what I did under the def __init__(self): block:
print("Time to carve some pumpkins!")
time.sleep(4)
print("First things first...")
time.sleep(4)
choices=easygui.buttonbox("How do you want to shape the eyes?", choices=["Triangles", "Circles", "Squares", "Fireballs", "Stars", "Ovals", "Swirls"])
So, you should get this when you run the program so far:
Time to carve some pumpkins!
First things first...
Then a window that says:
Well, once you click a button, the program just ends (since there's no lines after the EasyGUI). Well, just to prove that EasyGUI actually did something, add this to the program:
if choices == "Triangles":
Pumpkin.eyes='Triangle'
elif choices == "Circles":
Pumpkin.eyes='Round'
elif choices == "Squares":
Pumpkin.eyes='Square'
elif choices == "Fireballs":
Pumpkin.eyes='Fire'
elif choices == "Stars":
Pumpkin.eyes='Star'
elif choices == "Ovals":
Pumpkin.eyes='Oval'
else:
Pumpkin.eyes='Swirly'
print("The pumpkin has", Pumpkin.eyes, "eyes.")
This is what I got when I picked Swirls.
Time to carve some pumpkins!
First things first...
The pumpkin has Swirly eyes.
So, there you go. The process repeats for the nose, so here's the rest of the program.
time.sleep(4)
print("Okay, let's do the nose.")
time.sleep(3)
choices=easygui.buttonbox("What shape do you want the nose to be?", choices=["Triangle", "Circle", "Arrowhead", "Fireball", "Swirl", "Square", "Oval", "Star"])
if choices == "Triangles":
Pumpkin.nose='Triangle'
elif choices == "Circles":
Pumpkin.nose='Round'
elif choices == "Squares":
Pumpkin.nose='Square'
elif choices == "Fireballs":
Pumpkin.nose='Fire'
elif choices == "Stars":
Pumpkin.nose='Star'
elif choices == "Ovals":
Pumpkin.nose='Oval'
elif choices == "Arrowhead":
Pumpkin.nose="Arrowhead"
else:
Pumpkin.nose='Swirly'
print("The pumpin has a", Pumpkin.nose, "nose.")
time.sleep(4)
print("Now, the mouth! But first...")
choices=easygui.buttonbox("What expression do you want the mouth to have?", choices=["Smile", "Laugh", "Scowl"])
if choices == "Smile":
Pumpkin.expression='Smile'
elif choices == "Laugh":
Pumpkin.expression='Laughing face'
else:
Pumpkin.expression='Scowl'
print("The pumpkin has a", Pumpkin.expression, ".")
time.sleep(4)
print("Now...")
choices=easygui.buttonbox("What do you want the mouth to look like?", choices=["Round, banana-like", "Spiky", "Curly", "Square", "Flaming"])
if choices == "Round, banana-like":
Pumpkin.mouth='Round'
elif choices == "Spiky":
Pumpkin.mouth='Spiky'
elif choices == "Curly":
Pumpkin.mouth='Curly'
elif choices == "Square":
Pumpkin.mouth='Square'
else:
Pumpkin.mouth='Flaming'
print("The pumpkin has a", Pumpkin.mouth, "mouth.")
time.sleep(4)
print("Here's your entire combination:")
time.sleep(3)
easygui.msgbox("A pumpkin with", Pumpkin.eyes, "eyes, a", Pumpkin.nose, "nose, and a", Pumpkin.mouth, " ", Pumpkin.expression, ".")
easygui.msgbox("Happy Halloween!")
When I ran the program, I got this:
Time to carve some pumpkins!
First things first...
The pumpkin has Fire eyes.
Okay, let's do the nose.
The pumpin has a Arrowhead nose.
Now, the mouth! But first...
The pumpkin has a Smile .
Now...
The pumpkin has a Round mouth.
Here's your entire combination:
Traceback (most recent call last):
File "C:/Python33/Pumpkins.py", line 79, in <module>
easygui.msgbox("A pumpkin with", Pumpkin.eyes, "eyes, a", Pumpkin.nose, "nose, and a", Pumpkin.mouth, " ", Pumpkin.expression, ".")
TypeError: msgbox() takes from 0 to 5 positional arguments but 9 were given
Uh oh... It seems that you'll always run into problems when you program. This article is getting too long. Looks like Halloween is going to continue tomorrow!
I challenge you to turn all the button boxes into enter boxes!
HAPPY HALLOWEEN!