Python EasyGUI – Yes No Box
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 whether 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
Python3
from easygui import *
message = "Are you a Geek ?"
title = "GfG - EasyGUI"
output = ynbox(message, title)
if output:
message = "Thats Great !!"
title = "GfG - EasyGUI"
msg = msgbox(message, title)
else :
message = "You should become a Geek, go to GeeksforGeeks to become one"
title = "GfG - EasyGUI"
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
Python3
from easygui import *
message = "Are you a Geek ?"
title = "GfG - EasyGUI"
choices = ["Agree", "Disagree"]
output = ynbox(message, title, choices)
if output:
message = "Thats Great !!"
title = "GfG - EasyGUI"
msg = msgbox(message, title)
else :
message = "You should become a Geek, go to GeeksforGeeks to become one"
title = "GfG - EasyGUI"
msg = msgbox(message, title)
|
Output :
Last Updated :
10 Apr, 2023
Like Article
Save Article
Share your thoughts in the comments
Please Login to comment...