Advertisement
Guest User

Untitled

a guest
Jun 19th, 2019
211
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.71 KB | None | 0 0
  1. import tkinter as tk
  2. import tkinter.filedialog as fd
  3. base=tk.Tk()
  4. def open():
  5. file=fd.askopenfile(mode ='r', filetypes =[('Python Files', '*.py')])
  6. if file is not None:
  7. content = file.read()
  8. print(content)
  9. file.close()
  10.  
  11.  
  12. def exit():
  13. base.destroy()
  14.  
  15.  
  16. def find():
  17. print("file found")
  18.  
  19.  
  20. menubar=tk.Menu(base)
  21. filemenu=tk.Menu(menubar,tearoff=0)
  22. menubar.add_cascade(label="File",menu=filemenu)
  23. filemenu.add_command(label="open",command=open)
  24. filemenu.add_separator()
  25. filemenu.add_command(label="exit",command=exit)
  26. editmenu=tk.Menu(menubar,tearoff=0)
  27. menubar.add_cascade(label="edit",menu=editmenu)
  28. editmenu.add_command(label="find",command=find)
  29. base.config(menu=menubar)
  30. base.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement