Advertisement
Guest User

Untitled

a guest
Mar 29th, 2017
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.89 KB | None | 0 0
  1. class FileSelection:
  2. # Get the selected filename and print it to the console
  3. def file_ok_sel(self, w):
  4. print "%s" % self.filew.get_filename()
  5.  
  6. def destroy(self, widget):
  7. gtk.main_quit()
  8.  
  9. def __init__(self):
  10. #Create a new file selection widget
  11. self.filew = gtk.FileSelection("File selection")
  12. self.filew.hide_fileop_buttons()
  13. self.filew.get_focus()
  14.  
  15.  
  16. self.filew.connect("destroy", self.destroy)
  17. # Connect the ok_button to file_ok_sel method
  18. self.filew.ok_button.connect("clicked", self.file_ok_sel)
  19.  
  20. # Connect the cancel_button to destroy the widget
  21. self.filew.cancel_button.connect("clicked",lambda w: self.filew.destroy())
  22.  
  23. # Lets set the filename, as if this were a save dialog,
  24. # and we are giving a default filename
  25. self.filew.set_filename("penguin.png")
  26.  
  27. self.filew.show()
  28.  
  29. def main(self):
  30. gtk.main()
  31. print "selection"*10
  32. return 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement