Earlier this week, I was reading my copy of “Hello World” by Warren D. Sande and Carter Sande and in its chapter on graphical user interfaces, it mentioned a library called EasyGui. It’s the first and only Python GUI project I’ve seen that’s not event-driven. Instead, EasyGui is basically a set of dialogs that can be opened on demand. This package would be handy for command line programs that need to get information from the user using a dialog or for teaching new programmers about simple GUIs. Let’s take a quick look at what EasyGui can do. We’ll use some of the examples from the book.
EasyGui is based on Tkinter, which is built into Python. It’s also just one little python script that you can just drop somewhere in the python path so you can use it. I put mine in the site-packages folder. Let’s take a look at a few examples.
The message box is great for letting the user know information about their programs status. Here’s how you make one:
import easygui easygui.msgbox("Hello, world!")
The enterbox dialog allows the programmer to prompt the user to enter a string of text.
import easygui flavor = easygui.enterbox("What is your favorite ice cream flavor?") easygui.msgbox ("You entered " + flavor)
The buttonbox dialog is passed a list of strings to create a set of choices that are represented as buttons.
import easygui flavor = easygui.buttonbox("What is your favorite ice cream flavor?", choices = ['Vanilla', 'Chocolate', 'Strawberry'] ) easygui.msgbox ("You picked " + flavor)
There are more dialogs that EasyGui provides that are not covered here. Check out its documentation for more information.
1 thought on “A Quick EasyGui Tutorial”
This will helpful to us EasyGui is based on Tkinter, which is built into Python. Itâ€™s also just one little python script that we can just drop somewhere in the python path so you can use it.Thanks for your great post G-d bless 😉
Comments are closed.