skip420

Yes-No-box

Sep 19th, 2021
689
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import tkinter as tk
  2. from tkinter import messagebox
  3.  
  4. root= tk.Tk()
  5.  
  6. canvas1 = tk.Canvas(root, width = 300, height = 300)
  7. canvas1.pack()
  8.  
  9. def ExitApplication():
  10.     MsgBox = tk.messagebox.askquestion ('Exit Application','Are you sure you want to exit the application',icon = 'warning')
  11.     if MsgBox == 'yes':
  12.        root.destroy()
  13.     else:
  14.         tk.messagebox.showinfo('Return','You will now return to the application screen')
  15.        
  16. button1 = tk.Button (root, text='Exit Application',command=ExitApplication,bg='brown',fg='white')
  17. canvas1.create_window(150, 150, window=button1)
  18.  
  19. root.mainloop()
  20.  
RAW Paste Data