EasyGUI – Code Box
Code Box : It is used to show and get the text to/from the user which is in form of code i.e not in word-wrap form, text can be edited using any keyboard input, it takes input in form of string. It displays the title, message to be displayed, place to alter the given text and a pair of “Ok”, “Cancel” button which is used confirm the text. It is similar to text box but used to show code text, below is how the enter box looks like
In order to do this we will use
codeboxmethodSyntax : codebox(message, title, text)
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 string which is the editable text
Return : It returns the altered text and None if cancel is pressed
Example :
In this we will create a code box with editable text, and will show the specific text on the screen according to the altered text, below is the implementation
# importing easygui modulefrom easygui import * # message to be displayedmessage = "Below is the text to edit" # window titletitle = "Window Title GfG" # long code texttext = """<gfg> EasyGUI is a module for very simple,very easy GUI programming in Python.EasyGUI is different from otherGUI generators in that EasyGUI is NOT event-driven. </gfg>""" # creating a code boxoutput = codebox(message, title, text) # showing the outputprint("Alterted Text ")print("================")print(output) |
Output :
Alterted Text ================ 'gfg> great EasyGUI module is a module for very simple, very easy GUI programming in Python. EasyGUI is different from otherGUI generators in that EasyGUI is NOT event-driven. '/gfg>
Another Example :
In this we will create a code box without editable text, and will show the specific text on the screen according to the altered text, below is the implementation
# importing easygui modulefrom easygui import * # message to be displayedmessage = "Below is the text to edit" # window titletitle = "Window Title GfG" # creating a code boxoutput = codebox(message, title) # showing the outputprint("Alterted Text ")print("================")print(output) |
Output :
Alterted Text ================ gfg a b v c c c /gfg
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


