Exercise 199 || Solution
Create a Python program using the Tkinter library, which displays a dialog box that ask user to type his name and display a dialog box asking him to enter his name and displays the welcome message followed by his name as shown in the figure below.
Solution
from tkinter import *
def action():
name = entryName.get()
lblDisplay['text'] = "Welcome " + name + " !"
# You can also use the following syntax :
#lblDisplay.configure(text = "Welcome " + name + " !")
root = Tk()
root.geometry("375x150")
# Create Label and Entry Name
lblName = Label(root , text= "Enter your name : " , width = 20 )
lblName.place(x = 10 , y = 20)
entryName = Entry(root, width = 25)
entryName.place(x = 175 , y = 20)
# Create label to display result
lblDisplay = Label(root , text='...........')
lblDisplay.place(x = 175 , y = 100)
# Create button to execute action
btnAction = Button(root , text = "Validate" , width = 25 , command = action)
btnAction.place(x = 175 , y = 50)
root.mainloop()
Younes Derfoufi
my-courses.net
my-courses.net
Excellent pieces. Keep posting such kind of info on your
page. Im really impressed by your site.
Hi there, You’ve performed an incredible job. I will definitely digg it and in my view suggest to my friends.
I’m sure they’ll be benefited from this website.