Saturday, October 25, 2025
HomeLanguagesPython EasyGUI – Boolean Box

Python EasyGUI – Boolean Box

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




# importing easygui module
from easygui import *
 
# message / information to be displayed on the screen
message = "Select any one button"
 
# title of the window
title = "GfG - EasyGUI"
 
# creating a index box
output = boolbox(message, title)
 
# showing new message according to the buttons pressed
# if output is 1
if output == 1:
     
    # message / information
    message = "First Button is pressed"
     
     
# if output is 0
elif output == 0:
     
    # message / information
    message = "Button rather than first button is pressed"
     
 
# title of the window
title = "GfG - EasyGUI"
  
# creating a message box
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




# importing easygui module
from easygui import *
 
# message / information to be displayed on the screen
message = "Select any one button"
 
# title of the window
title = "GfG - EasyGUI"
 
# buttons
buttons = ["First", "Second"]
 
# creating a boolean box
output = boolbox(message, title, buttons)
 
# showing new message according to the buttons pressed
# if output is 1
if output == 1:
     
    # message / information
    message = "First Button is pressed"
     
     
# if output is 0
elif output == 0:
     
    # message / information
    message = "Button rather than first button is pressed"
     
 
# title of the window
title = "GfG - EasyGUI"
  
# creating a message box
msg = msgbox(message, title)
    


Output : 

Dominic
Dominichttp://wardslaus.com
infosec,malicious & dos attacks generator, boot rom exploit philanthropist , wild hacker , game developer,
RELATED ARTICLES

Most Popular

Dominic
32361 POSTS0 COMMENTS
Milvus
88 POSTS0 COMMENTS
Nango Kala
6728 POSTS0 COMMENTS
Nicole Veronica
11892 POSTS0 COMMENTS
Nokonwaba Nkukhwana
11954 POSTS0 COMMENTS
Shaida Kate Naidoo
6852 POSTS0 COMMENTS
Ted Musemwa
7113 POSTS0 COMMENTS
Thapelo Manthata
6805 POSTS0 COMMENTS
Umr Jansen
6801 POSTS0 COMMENTS