DEV Community

Cover image for EasyGUI with Python, example
petercour
petercour

Posted on

2 1

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:

AWS Q Developer image

Your AI Code Assistant

Ask anything about your entire project, code and get answers and even architecture diagrams. Built to handle large projects, Amazon Q Developer works alongside you from idea to production code.

Start free in your IDE

Top comments (0)

AWS Security LIVE!

Join us for AWS Security LIVE!

Discover the future of cloud security. Tune in live for trends, tips, and solutions from AWS and AWS Partners.

Learn More