Python EasyGUI – Boolean Box
Last Updated :
23 Dec, 2021
Boolean Box : It is used to display a window having a multiple options i.e buttons in EasyGUI, it can be used where there is a need to get if the first selection option as it returns 1 for button having index 0 and for other button it returns 0, it is slightly different from index box, below is how the boolean box looks like
In order to do this we will use boolbox method
Syntax : boolbox(message, title, buttons)
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 of strings i.e buttons exactly having two buttons
Return : It returns return 1 if first button is pressed else 0 for other buttons selected by the user
Example :
In this we will create a index box, when any button is pressed it will show the specific message on the screen according to the index, below is the implementation
Python3
from easygui import *
message = "Select any one button"
title = "GfG - EasyGUI"
output = boolbox(message, title)
if output = = 1 :
message = "First Button is pressed"
elif output = = 0 :
message = "Button rather than first button is pressed"
title = "GfG - EasyGUI"
msg = msgbox(message, title)
|
Output :
Another Example :
In this we will create a index box with added buttons, when any button is pressed it will show the specific message on the screen according to the index, below is the implementation
Python3
from easygui import *
message = "Select any one button"
title = "GfG - EasyGUI"
buttons = ["First", "Second"]
output = boolbox(message, title, buttons)
if output = = 1 :
message = "First Button is pressed"
elif output = = 0 :
message = "Button rather than first button is pressed"
title = "GfG - EasyGUI"
msg = msgbox(message, title)
|
Output :
Share your thoughts in the comments
Please Login to comment...