Using EasygGUI to talk to the user
EasyGUI is another Python module, rather like the Turtle module, that you can use in your programs to get input from the user. It creates and displays some ready-made graphic user interface dialog boxes that you can customise.
To use it you must add 'easygui' to the import statement at the beginning of your program. Then use the pre-made easygui functions to make dialog boxes for user interaction. |
import turtle,easygui |
Examples of EasyGUI boxes
import turtle,easygui
def polygon(howmanysides):
for i in range(howmanysides):
turtle.forward(30)
turtle.right(360/howmanysides)
result = easygui.buttonbox("Choose your shape",choices=("Hexagon","Octagon","Square"))
if result == "Hexagon":
polygon(6)
if result == "Octagon":
polygon(8)
if result == "Square":
polygon(4)
turtle.exitonclick()
import turtle,easygui
def polygon(howmanysides):
for i in range(howmanysides):
turtle.forward(30)
turtle.right(360/howmanysides)
result = easygui.passwordbox("Enter the secret code word")
if result == "secret":
polygon(20)
else:
easygui.msgbox("Access denied!")
turtle.exitonclick()