tk11_msgbox.py 1.1 KB

123456789101112131415161718192021222324252627282930313233
  1. # View more python learning tutorial on my Youtube and Youku channel!!!
  2. # Youtube video tutorial: https://www.youtube.com/channel/UCdyjiB5H8Pu7aDTNVXTTpcg
  3. # Youku video tutorial: http://i.youku.com/pythontutorial
  4. import tkinter as tk
  5. import tkinter.messagebox
  6. window = tk.Tk()
  7. window.title('my window')
  8. window.geometry('200x200')
  9. def hit_me():
  10. #tk.messagebox.showinfo(title='Hi', message='hahahaha') # return 'ok'
  11. #tk.messagebox.showwarning(title='Hi', message='nononono') # return 'ok'
  12. #tk.messagebox.showerror(title='Hi', message='No!! never') # return 'ok'
  13. #print(tk.messagebox.askquestion(title='Hi', message='hahahaha')) # return 'yes' , 'no'
  14. #print(tk.messagebox.askyesno(title='Hi', message='hahahaha')) # return True, False
  15. print(tk.messagebox.asktrycancel(title='Hi', message='hahahaha')) # return True, False
  16. print(tk.messagebox.askokcancel(title='Hi', message='hahahaha')) # return True, False
  17. print(tk.messagebox.askyesnocancel(title="Hi", message="haha")) # return, True, False, None
  18. tk.Button(window, text='hit me', command=hit_me).pack()
  19. window.mainloop()