easygui

Installation and Overview
Easygui
is by far the easiest GUI (Graphical user interface)
It is easy to use because it doesn't refresh objects within the same canvas but creates a new screen. 
To use it inside Portable Python you need to download the zipped up file at the bottom of the page.
Extract the files and then copy the easygui.py file into \App\Lib\site-packages
Easygui is not being actively looked after/developed but I have found many great features for Python
novices to use in Python 3.xx

Importing the Library
import easygui as eg #place this code at the top to use easygui

Message Box
eg.msgbox("Hello World", ok_button="How mad is that")
This runs as
msgbox
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.





ċ
easygui.zip
(20k)
Philip Bagge,
7 Jul 2015, 14:48
Comments