Guest User

Untitled

a guest
Jan 16th, 2018
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1. from Tkinter import *
  2. globalFilename = ""
  3. class Master:
  4. def __init__(self, top):
  5. self.filename = ""
  6. frame_e = Frame(top)
  7. frame_e.pack()
  8. self.t_filename = StringVar()
  9.  
  10. entry = Entry(frame_e, textvariable=self.t_filename, bg="white")
  11. entry.pack()
  12. entry.focus_force()
  13.  
  14. saveButton = Button(frame_e, text="Save", command=self.on_button)
  15. saveButton.pack(side=BOTTOM, anchor=S)
  16.  
  17.  
  18. def on_button(self):
  19. self.filename = self.t_filename.get()
  20. print self.filename
  21. root.quit()
  22. root.destroy()
  23.  
  24.  
  25. root = Tk()
  26. root.geometry("100x100+100+50")
  27.  
  28. M = Master(root)
  29. print M.filename
  30. root.mainloop( )
  31. print M.filename
  32. globalFilename = M.filename
  33. print globalFilename
Add Comment
Please, Sign In to add comment