MessageBox - The Advantages of Learning Python Programming for Beginners: A Comprehensive Guide

Latest

Dive into the world of Python programming with our comprehensive resources

Music

logo

Friday, February 3, 2023

MessageBox

 

In this article, I will give an example of using messagebox in Python.   

I write the name entered in the entry as the text of the message in the messagebox.

 

For messagebox,

 

from tkinter import messagebox

 

Let's add the library to the form.

 


 

 

 

 

 

 

 

 

 

Figure 1

 

 


 




messagebox.py

 

from tkinter import *

from tkinter import messagebox

 

root = Tk()

root.title('messagebox..bs')

root.geometry('260x260')

 

def Message():

    name = tbox.get()

    return messagebox.showinfo('message',f'Hi! {name}, Open your heart, welcome the day, the missing sun, the clouds, the bird and most importantly welcome life.')

   

 

Label(root, text="Please enter name!",font=('Arial',14,'normal')).pack(pady=10)

tbox = Entry(root,width=20,font=('Arial',14,'normal'))

tbox.pack(pady=15)

 

Button(root, text="Click here", command=Message,width=20,height=2,bg="deepskyblue",fg="white",font=('Arial',12,'bold')).pack(pady=20)

 

root.mainloop()

 

I wish you happy coding days until we meet in the next article.

No comments:

Post a Comment

Featured post

Python Introduction

What is Python? Python is an interpreted, object-oriented, high-level programming language with dynamic semantics. Its high-level built ...