Advertisement
ChallengerAppeared

4searchGUI.py

Sep 12th, 2013
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.64 KB | None | 0 0
  1. #       4chan thread image collector GUI front end
  2. #
  3. #
  4. #
  5. #       Author:
  6. #       Date:   19/Aug/2013
  7. #       License: GNU General Public License
  8. #
  9. #       Purpose:
  10. #           GUI front end for 4search.py
  11.  
  12. from Tkinter import *
  13. import Tkinter
  14. from tkFileDialog import askdirectory
  15. from os import system
  16.  
  17. # Called when the Browse button is clicked
  18. # Sets the directory box to the result of a directory dialog
  19. def browseCallBack():
  20.     _dir.set(askdirectory())
  21.  
  22. # Called when the Download button is clicked
  23. # Calls the command line program with the given arguments
  24. def goCallBack():
  25.     system("4search.py "+_url.get()+" -d \""+_dir.get()+"\"");
  26.  
  27. # Make a 500 by 145 px window
  28. top = Tk()
  29. top.geometry("500x145")
  30.  
  31. # create variable holders for the URL and download directory
  32. _dir = StringVar()
  33. _url = StringVar()
  34.  
  35. # Create a label for the URL text
  36. urllbl = Tkinter.Label(text="URL")
  37.  
  38. # Create a text box to control the URL
  39. urlbox = Tkinter.Entry(top, textvariable=_url,width=490)
  40.  
  41. # Create a label for the Download location text
  42. dirlbl = Tkinter.Label(text="Download Location")
  43.  
  44. # Create a text box to control the download location
  45. dirbox = Tkinter.Entry(top, textvariable=_dir,width=490)
  46.  
  47. # Create a button to open the directory browse dialog
  48. browsebtn = Tkinter.Button(
  49.     top,
  50.     text="Browse for download location",
  51.     command = browseCallBack)
  52.  
  53. # Create a button to start the download process
  54. gobtn = Tkinter.Button(top, text="Download", command=goCallBack)
  55.  
  56. # Pack the widgets into the GUI
  57. urllbl.pack()
  58. urlbox.pack()
  59. dirlbl.pack()
  60. dirbox.pack()
  61. browsebtn.pack()
  62. gobtn.pack()
  63.  
  64. # Run the mainloop
  65. top.mainloop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement