easygui

Installation and Overview

Easygui is by far the easiest GUI (Graphical user interface)

Message Box

This runs as

msgbox

eg.msgbox("Hello World", ok_button="How mad is that")

The ok_button expands to fit your text.

So you could provide the text of an adventure in the top and then have the button saying continue.

Yes No Box

When the user selects Yes the ynbox returns a 1

When the user selects a No the ynbox returns a 0

You can use this in an if else selection to change the route of the programme.

yn1=eg.ynbox("Do you wish to enter the cave of doom?")

if yn1 == 1:

    eg.msgbox("Welcome to the caves")

else:

    eg.msgbox("Bye")

The ynbox looks like this

ynbox

If the user selects Yes this msgbox is run

msgbox_yes

If you selected No an identical message box would have been run with Bye above the OK button.

You can also include other options

eg.ynbox(msg="Do you wish to Vote?", title="Vote Now by stealyourvote.com", image="vote.gif")

This would display as

vote

Boolbox

The boolbox outputs either 1 if yes is selected or 0 if no is selected.

boolbox

In this example the variable is checked to see if it contains a 1. If it does then Vote is printed.

Button Box

The button box allows you to set up multiple buttons. Only one can be chosen.

buttonbox

The text of the button chosen is returned.

So in this example if Second is chosen then the user is informed that their choice was correct

If either of the other buttons is chosen the user is informed that their choice is wrong.

Continue or Cancel Box

The ccbox returns a 1 if continue or the x are selected and a 0 if cancel is selected.

In this example if Continue is selected continue is printed out.

If Cancel is selected cancel is printed out.