Skip to content
geeksforgeeks
  • Courses
    • DSA to Development
    • Get IBM Certification
    • Newly Launched!
      • Master Django Framework
      • Become AWS Certified
    • For Working Professionals
      • Interview 101: DSA & System Design
      • Data Science Training Program
      • JAVA Backend Development (Live)
      • DevOps Engineering (LIVE)
      • Data Structures & Algorithms in Python
    • For Students
      • Placement Preparation Course
      • Data Science (Live)
      • Data Structure & Algorithm-Self Paced (C++/JAVA)
      • Master Competitive Programming (Live)
      • Full Stack Development with React & Node JS (Live)
    • Full Stack Development
    • Data Science Program
    • All Courses
  • Tutorials
    • Data Structures & Algorithms
    • ML & Data Science
    • Interview Corner
    • Programming Languages
    • Web Development
    • CS Subjects
    • DevOps And Linux
    • School Learning
  • Practice
    • Build your AI Agent
    • GfG 160
    • Problem of the Day
    • Practice Coding Problems
    • GfG SDE Sheet
  • Contests
    • Accenture Hackathon (Ending Soon!)
    • GfG Weekly [Rated Contest]
    • Job-A-Thon Hiring Challenge
    • All Contests and Events
  • Python Tutorial
  • Interview Questions
  • Python Quiz
  • Python Glossary
  • Python Projects
  • Practice Python
  • Data Science With Python
  • Python Web Dev
  • DSA with Python
  • Python OOPs
Open In App
Next Article:
Python | Message Encode-Decode using Tkinter
Next article icon

Message Boxes using PyAutoGUI

Last Updated : 26 May, 2020
Comments
Improve
Suggest changes
Like Article
Like
Report

PyAutoGUI is a Python module which can automate your GUI and programmatically control your keyboard and mouse. This article illustrates the GUI functions to create display boxes.
If you want to know more about PyAutoGUI and its ability to automate your keyboard and mouse, follow this article : Mouse and Keyboard Automation using PyAutoGUI

PyAutoGUI does not come with python, so go to command prompt and type the following :

 pip3 install PyAutoGUI

alert() : Displays a simple message box with text and a single OK button. Returns the text of the button clicked on.




# Python Program to show alert() function
import pyautogui
  
pyautogui.alert('GeekforGeeks alert box')
 
 

Output : It will display the alert box with the given text and when clicked OK it will return ‘OK’

 
confirm() : Displays a message box with OK and Cancel buttons. Number and text of buttons can be customized. Returns the text of the button clicked on.




# Python Program to show confirm() function
import pyautogui
pyautogui.confirm('Geek Shall I proceed?')
 
 

Output : It will display the alert box with the given text and on clicking the button it will return the text on the button. In this case its ‘OK’

To have multiple select options –




# Python Program to show confirm() function
# with multiple options
import pyautogui
pyautogui.confirm('Enter option Gfg', buttons =['A', 'B', 'C'])
 
 

Output : On clicking A, it will return ‘A’ as output.

 
prompt() : Displays a message box with text input, and OK & Cancel buttons. Returns the text entered, or None if Cancel was clicked.




# Python Program to show prompt() function
import pyautogui
pyautogui.prompt('What is your name?')
 
 

Output : It will return the text entered, in this case ‘GeekForGeeks’ or None if cancelled was clicked.

 

password() : Displays a message box with text input, and OK & Cancel buttons. Typed characters appear as *. Returns the text entered, or None if Cancel was clicked




# Python Program to show password() function
import pyautogui
pyautogui.password('Enter password (text will be hidden)')
 
 

Output : It will return the text/password entered, in this case ‘GeekForGeeks’ or None if cancelled was clicked.



Next Article
Python | Message Encode-Decode using Tkinter
author
akshay_sharma08
Improve
Article Tags :
  • Python
  • Python-gui
  • Python-PyAutoGUI
Practice Tags :
  • python

Similar Reads

  • Python EasyGUI - Message Box
    Message Box : It is used to display a window having a message or information in EasyGUI, it can be used where there is a need to display some message or some important information, it contains message and a "Ok" button which when pressed closes the message, below is how the message box looks like
    2 min read
  • Spam bot using PyAutoGUI
    PyAutoGUI is a Python module that helps us automate the key presses and mouse clicks programmatically. In this article we will learn to develop a spam bot using PyAutoGUI. Spamming - Refers to sending unsolicited messages to large number of systems over the internet.  This mini-project can be used f
    2 min read
  • PyQt5 - Message Box
    In this article, we will discuss the Message Box Widget of the PyQT5 module. It is used to display the message boxes. PyQt5 is a library used to create GUI using the Qt GUI framework. Qt is originally written in C++ but can be used in Python. The latest version of PyQt5 can be installed using the co
    3 min read
  • Python | Message Encode-Decode using Tkinter
    Prerequisite : Basics of TkinterPython offers multiple options for developing GUI (Graphical User Interface). Out of all the GUI methods, tkinter is most commonly used method. It is a standard Python interface to the Tk GUI toolkit shipped with Python. Python with tkinter outputs the fastest and eas
    5 min read
  • Create a Yes/No Message Box in Python using tkinter
    Python offers a number Graphical User Interface(GUI) framework but Tk interface or tkinter is the most widely used framework. It is cross-platform which allows the same code to be run irrespective of the OS platform (Windows, Linux or macOS). Tkinter is lightweight, faster and simple to work with. T
    4 min read
  • Python Tkinter - Message
    Python offers multiple options for developing a GUI (Graphical User Interface). Out of all the GUI methods, Tkinter is the most commonly used method. It is a standard Python interface to the Tk GUI toolkit shipped with Python. Python with Tkinter is the fastest and easiest way to create GUI applicat
    3 min read
  • Create a Telegram Bot using Python
    In this article, we are going to see how to create a telegram bot using Python. In recent times Telegram has become one of the most used messaging and content sharing platforms, it has no file sharing limit like Whatsapp and it comes with some preinstalled bots one can use in any channels (groups in
    6 min read
  • Send message to Telegram user using Python
    Have you ever wondered how people do automation on Telegram? You may know that Telegram has a big user base and so it is one of the preferred social media to read people. What good thing about Telegram is that it provides a bunch of API's methods, unlike Whatsapp which restricts such things. So in t
    3 min read
  • Python Compiler Using Django
    In this article, we will explore the creation of a Python compiler using Django. Users can input their Python code into the designated code area, and upon clicking the "Run" button, the compiler will generate the corresponding output. What is Python Compiler?A Python compiler is a program or tool th
    4 min read
  • Python EasyGUI – Integer Box
    Integer Box : It is used to get the integer input from the user, input should be integer input not string which happens in enter box. It displays the title, message to be displayed, place to enter a integer input and a pair of "Ok", "Cancel" button which is used confirm the input. We can set some de
    3 min read
geeksforgeeks-footer-logo
Corporate & Communications Address:
A-143, 7th Floor, Sovereign Corporate Tower, Sector- 136, Noida, Uttar Pradesh (201305)
Registered Address:
K 061, Tower K, Gulshan Vivante Apartment, Sector 137, Noida, Gautam Buddh Nagar, Uttar Pradesh, 201305
GFG App on Play Store GFG App on App Store
Advertise with us
  • Company
  • About Us
  • Legal
  • Privacy Policy
  • In Media
  • Contact Us
  • Advertise with us
  • GFG Corporate Solution
  • Placement Training Program
  • Languages
  • Python
  • Java
  • C++
  • PHP
  • GoLang
  • SQL
  • R Language
  • Android Tutorial
  • Tutorials Archive
  • DSA
  • Data Structures
  • Algorithms
  • DSA for Beginners
  • Basic DSA Problems
  • DSA Roadmap
  • Top 100 DSA Interview Problems
  • DSA Roadmap by Sandeep Jain
  • All Cheat Sheets
  • Data Science & ML
  • Data Science With Python
  • Data Science For Beginner
  • Machine Learning
  • ML Maths
  • Data Visualisation
  • Pandas
  • NumPy
  • NLP
  • Deep Learning
  • Web Technologies
  • HTML
  • CSS
  • JavaScript
  • TypeScript
  • ReactJS
  • NextJS
  • Bootstrap
  • Web Design
  • Python Tutorial
  • Python Programming Examples
  • Python Projects
  • Python Tkinter
  • Python Web Scraping
  • OpenCV Tutorial
  • Python Interview Question
  • Django
  • Computer Science
  • Operating Systems
  • Computer Network
  • Database Management System
  • Software Engineering
  • Digital Logic Design
  • Engineering Maths
  • Software Development
  • Software Testing
  • DevOps
  • Git
  • Linux
  • AWS
  • Docker
  • Kubernetes
  • Azure
  • GCP
  • DevOps Roadmap
  • System Design
  • High Level Design
  • Low Level Design
  • UML Diagrams
  • Interview Guide
  • Design Patterns
  • OOAD
  • System Design Bootcamp
  • Interview Questions
  • Inteview Preparation
  • Competitive Programming
  • Top DS or Algo for CP
  • Company-Wise Recruitment Process
  • Company-Wise Preparation
  • Aptitude Preparation
  • Puzzles
  • School Subjects
  • Mathematics
  • Physics
  • Chemistry
  • Biology
  • Social Science
  • English Grammar
  • Commerce
  • World GK
  • GeeksforGeeks Videos
  • DSA
  • Python
  • Java
  • C++
  • Web Development
  • Data Science
  • CS Subjects
@GeeksforGeeks, Sanchhaya Education Private Limited, All rights reserved
We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge that you have read and understood our Cookie Policy & Privacy Policy
Lightbox
Improvement
Suggest Changes
Help us improve. Share your suggestions to enhance the article. Contribute your expertise and make a difference in the GeeksforGeeks portal.
geeksforgeeks-suggest-icon
Create Improvement
Enhance the article with your expertise. Contribute to the GeeksforGeeks community and help create better learning resources for all.
geeksforgeeks-improvement-icon
Suggest Changes
min 4 words, max Words Limit:1000

Thank You!

Your suggestions are valuable to us.

What kind of Experience do you want to share?

Interview Experiences
Admission Experiences
Career Journeys
Work Experiences
Campus Experiences
Competitive Exam Experiences