In this article we will see how we can add or show image in the button box. Button box is used to display a window having multiple buttons in EasyGUI, it can be used where there is condition to select one among lot of buttons for example buttons in lift at a time user can opt only one option, below is how the normal button box looks like
When we invoke the buttonbox function (or other functions that display a button box, such as msgbox, indexbox, ynbox, etc.), we can specify the keyword argument image=img where img is the filename of an image. The file can be .gif. Usually, we can use other images such as .png.
In order to do this we will use
Syntax : buttonbox(text, title, image=img, choices=button_list)
Argument : It takes 4 arguments, first string i.e text to be displayed, second string i.e title of the window and third and forth is keyword argument which is image source and the button choices
Return : It returns the text of the button that the user selected
In this we will create a button box with a image, and user will be allowed to select any button and message will appear according to the message, below is the implementation
Another Example :
Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.
To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course. And to begin with your Machine Learning Journey, join the Machine Learning – Basic Level Course