-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMessage_Box.py
52 lines (44 loc) · 1.21 KB
/
Message_Box.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
from tkinter import *
from tkinter import messagebox
window = Tk()
def clicked():
messagebox.showinfo(
title = "Title of the window",
message = "This is the message"
)
messagebox.showwarning(
title = "WARNING!",
message = "This is a warning message"
)
messagebox.showerror(
title = "ERROR TITLE",
message = "This is an Error messages"
)
# Returns True or False
print("Agreed!") if messagebox.askokcancel(
title = "Ask me Cancel",
message = "Do you want to do something?"
) else print("Cancelled")
# Also returns True or False
print("You wanted Pizza") if messagebox.askyesno(
title = "Ask Yes or No",
message = "Do you want pizza?"
) else print("You don't want Pizza!")
answer = messagebox.askyesnocancel(
title = "Ask Question",
message = "Do you like coding?",
icon = "error"
)
if answer == True:
print("You like coding!")
elif answer == False:
print("You don't like coding!")
else:
print("You avoided the question!")
button = Button(
window,
text = "click me",
command = clicked
)
button.pack()
window.mainloop()