DEV Community

Cover image for EasyGUI with Python, example
petercour
petercour

Posted on

EasyGUI with Python, example

EasyGui provides an easy-to-use interface for simple GUI interaction
with a user.

It does not require the programmer to know anything about
tkinter, frames, widgets, callbacks or lambda.

All GUI interactions are invoked by simple function calls that return results.

Example

#!/usr/bin/python3         
# https://pythonbasics.org                                                                                                                                                
import easygui as g
import sys

def ccbox():
    if g.ccbox('Do you agree?','Survey',choices=('Yes','No')):
        g.msgbox('Hockey')
    else:
        sys.exit(0)

ccbox()
Enter fullscreen mode Exit fullscreen mode

Creates this output:

This needs tkinter installed (on ubuntu),

sudo apt-get install python3-tk
Enter fullscreen mode Exit fullscreen mode

Because its uses tkinter to make its gui.

easygui can create different types of popups:

#!/usr/bin/python3         

import easygui as g
def msgbox(msg,title):
    g.msgbox(msg, title, ok_button='ok',image=None)

msgbox(msg = 'content',title = 'title')
Enter fullscreen mode Exit fullscreen mode

choice

Lets you choose between options

#!/usr/bin/python3         

import easygui as g

def buttonbox(msg,title):
    g.buttonbox(msg, title, choices=('button1','button2','button3'),image=None)

buttonbox(msg = 'content',title = 'title')
Enter fullscreen mode Exit fullscreen mode

Then

Resources:

Top comments (0)