Advertisement
Felanpro

tkinter.messagebox

Aug 15th, 2016
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.64 KB | None | 0 0
  1. from tkinter import *
  2. import tkinter.messagebox
  3.  
  4. def button_pressed():
  5.     answer = tkinter.messagebox.askyesno("Question", "Do you want to create a text file named python_hello.txt ?")
  6.     if answer == YES:
  7.         print("A text file called python_hello.txt has been created on your system.")
  8.         file1 = open("python_hello.txt", 'w')
  9.         file1.write("This is the text file you're looking for!")
  10.     else:
  11.         print(":(")
  12.  
  13. root = Tk()
  14. root.title("Application")
  15. root.geometry("500x300")
  16.  
  17. button1 = Button(root, text = "Click", fg ='red', bg ="blue", command = button_pressed)
  18.  
  19. button1.pack(side = LEFT)
  20.  
  21. root.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement