In this article, I will give an example of MessageBox. In this example, when the button in the form is clicked, a message is displayed on the screen.
Figure 1
Figure 2
import tkinter as tk
from tkinter import messagebox
root= tk.Tk()
root.title("python example...bs")
canvas1 = tk.Canvas(root, width = 300, height = 300)
canvas1.pack()
def ExitApplication():
MsgBox = tk.messagebox.askquestion ('Exit Application','Are you sure you want to exit the application'+'\n'+"Uygulamadan cikmak icin emin misiniz?",icon = 'warning')
if MsgBox == 'yes':
root.destroy()
else:
tk.messagebox.showinfo('Return','You will now return to the application screen'+'\n'+"Uygulama ekranina geri doneceksiniz",icon = 'info')
button1 = tk.Button (root, text='Exit Application'+'\n'+"(Uygulamadan Cikis)",command=ExitApplication,width=20,height=2,font='arial 14 bold',bg='deepskyblue',fg='white')
canvas1.create_window(150, 150, window=button1)
root.mainloop()
Happy coding.
No comments:
Post a Comment