Python EasyGUI – Yes No Box

05 Sep, 2020
Yes No Box : It is used to display a window having a two option yes or no in EasyGUI, it can be used where there is a need to get the answer of the question in form of yes or no, it displays two option yes or no for example when we want to ask user weather he is above 18 or not we will use yes no box, it is kind of similar to continue cancel box, below is how the continue cancel box looks like
In order to do this we will use ynbox method
Syntax : ynbox(message, title, choices)
Argument : It takes 3 arguments, first string i.e message/information to be displayed, second string i.e title of the window and third is list having exactly two values which is two option for yes and no
Return : It returns True is yes is pressed else False
Example :In this we will create a yes no box, when any button is pressed it will show the specific message on the screen, below is the implementation
# importing easygui modulefrom easygui import *  # message / information to be displayed on the screenmessage = "Are you a Geek ?"  # title of the windowtitle = "GfG - EasyGUI"  # creating a yes no boxoutput = ynbox(message, title)    # if user pressed yesif output:          # message / information to be displayed on the screen    message = "Thats Great !!"       # title of the window    title = "GfG - EasyGUI"       # creating a message box    msg = msgbox(message, title)  # if user pressed Noelse:          # message / information to be displayed on the screen    message = "You should become a Geek, go to GeeksforGeeks to become one"       # title of the window    title = "GfG - EasyGUI"       # creating a message box    msg = msgbox(message, title)           
Output :
Another Example :In this we will create a yes no box and setting specific choice for yes and no button, when any button is pressed it will show the specific message on the screen, below is the implementation
# importing easygui modulefrom easygui import *  # message / information to be displayed on the screenmessage = "Are you a Geek ?"  # title of the windowtitle = "GfG - EasyGUI"  # choices for yes and no buttonchoices = ["Agree", "Disagree"]  # creating a yes no boxoutput = ynbox(message, title, choices)    # if user pressed yesif output:          # message / information to be displayed on the screen    message = "Thats Great !!"       # title of the window    title = "GfG - EasyGUI"       # creating a message box    msg = msgbox(message, title)  # if user pressed Noelse:          # message / information to be displayed on the screen    message = "You should become a Geek, go to GeeksforGeeks to become one"       # title of the window    title = "GfG - EasyGUI"       # creating a message box    msg = msgbox(message, title)           
Output :
Python-EasyGUI
Python-gui
Python
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to Install PIP on Windows ?
Python Classes and Objects
Python OOPs Concepts
Introduction To PYTHON
How to drop one or multiple columns in Pandas Dataframe
Python | os.path.join() method
Check if element exists in list in Python
How To Convert Python Dictionary To JSON?
Python | Get unique values from a list
Python | datetime.timedelta() function