Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from tkinter import *
- import tkinter.messagebox
- def button_pressed():
- answer = tkinter.messagebox.askyesno("Question", "Do you want to create a text file named python_hello.txt ?")
- if answer == YES:
- print("A text file called python_hello.txt has been created on your system.")
- file1 = open("python_hello.txt", 'w')
- file1.write("This is the text file you're looking for!")
- else:
- print(":(")
- root = Tk()
- root.title("Application")
- root.geometry("500x300")
- button1 = Button(root, text = "Click", fg ='red', bg ="blue", command = button_pressed)
- button1.pack(side = LEFT)
- root.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement