tunekeeper /

from Tkinter import Tk
from Tkinter import FALSE, VERTICAL, NORMAL
from Tkinter import N, S, W, E
from Tkinter import Text
import code
from ttk import Frame, Entry, Combobox, Button, Scrollbar
import tkFileDialog
import tkMessageBox
from tkFont import Font

#f = Font(family="Helvetica", size=12)
search_types = ['Title', 'Artist', 'Album', 'Location']

def search_archive():
    """Search the archive"""
    archive_file = tkFileDialog.askopenfilename()
    s_type = search_type.get()
    search_term = search_text.get().lower()
    results =, search_term, archive_file)
    for result in results:
        results_box.insert('end', result['Title'] + " -- " + result['Album'] + \
                           " -- " + result['Artist'] + " -- " + \
                           result['Location'] + "\n\n")

def archive_disc():
    """Write the archive file"""
    dirname = tkFileDialog.askdirectory()
    save_file = tkFileDialog.asksaveasfile()
    #save_dir = tkFileDialog.askdirectory()
    code.archive(dirname, save_file)
    tkMessageBox.showinfo(message="Done Archiving")

#### GUI
root = Tk()
font = Font(family='Helvetica', size='13')
root.resizable(FALSE, FALSE)
mainframe = Frame(root, padding="12 12 12 12")
mainframe.grid(column=0, row=0, sticky=(N, W, E, S))
mainframe.columnconfigure(0, weight=1)
mainframe.rowconfigure(0, weight=1)
### Make widgets
search_text = Entry(mainframe)
search_type = Combobox(mainframe, values=search_types, state='readonly')
search_button = Button(mainframe, text='Search', command=search_archive)
archive_button = Button(mainframe, text='Archive', command=archive_disc)
results_box = Text(mainframe, font=font)
s = Scrollbar(root, orient=VERTICAL, command=results_box.yview)
results_box['yscrollcommand'] = s.set
s.grid(column=4, row=0, sticky=(N, S))
### Put widgets on grid
search_text.grid(column=0, row=1, sticky=W)
search_type.grid(column=1, row=1, sticky=W)
search_button.grid(column=2, row=1, sticky=W)
archive_button.grid(column=3, row=1, sticky=W)
results_box.grid(columnspan=4, row=4)
### Focus on search field

for child in mainframe.winfo_children():
    child.grid_configure(padx=0, pady=5)

Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.