
4searchGUI.py
# 4chan thread image collector GUI front end
#
#
#
# Author: Andrew Melnick
# Date: 19/Aug/2013
# License: GNU General Public License
#
# Purpose:
# GUI front end for 4search.py
from Tkinter import *
import Tkinter
from tkFileDialog import askdirectory
from os import system
# Called when the Browse button is clicked
# Sets the directory box to the result of a directory dialog
def browseCallBack():
_dir.set(askdirectory())
# Called when the Download button is clicked
# Calls the command line program with the given arguments
def goCallBack():
system("4search.py "+_url.get()+" -d \""+_dir.get()+"\"");
# Make a 500 by 145 px window
top = Tk()
top.geometry("500x145")
# create variable holders for the URL and download directory
_dir = StringVar()
_url = StringVar()
# Create a label for the URL text
urllbl = Tkinter.Label(text="URL")
# Create a text box to control the URL
urlbox = Tkinter.Entry(top, textvariable=_url,width=490)
# Create a label for the Download location text
dirlbl = Tkinter.Label(text="Download Location")
# Create a text box to control the download location
dirbox = Tkinter.Entry(top, textvariable=_dir,width=490)
# Create a button to open the directory browse dialog
browsebtn = Tkinter.Button(
top,
text="Browse for download location",
command = browseCallBack)
# Create a button to start the download process
gobtn = Tkinter.Button(top, text="Download", command=goCallBack)
# Pack the widgets into the GUI
urllbl.pack()
urlbox.pack()
dirlbl.pack()
dirbox.pack()
browsebtn.pack()
gobtn.pack()
# Run the mainloop
top.mainloop()