Im working on my first big project, a GUI library for movie files (much like in itunes). so far i have the ability to list the movies title director and year in a list box as well as add movies to the database, however it is only text no actual movie files. is there a way for me to link the movie file to the text in the listbox?

what i am specifically looking for is when the user is adding the title year director and such (using Tkinter Entry widget) a ask file dialog will show up for the user to select the movie. so later i can click on it in the list and it will open the movie

global titleadd, directoradd, yearadd
    addboard = Tkinter.Toplevel()
    addboard.title("Add a movie")
    #addboard(padx=10, pady=10)
    print "add"
    #adding the title
    lbtitle = Tkinter.Label(addboard, text = "Enter the movie's title:")
    lbtitle.grid(row = 1, column = 1)
    titleadd = StringVar()
    entitle = Tkinter.Entry(addboard, textvariable = titleadd)
    entitle.grid(row = 1, column = 3)
    entitle.insert(0, "Title")

    #adding the director
    lbdirector = Tkinter.Label(addboard, text = "Enter the mmovie's director:")
    lbdirector.grid(row = 2, column = 1)
    directoradd = StringVar()
    endirector = Tkinter.Entry(addboard, textvariable = directoradd)
    endirector.grid(row = 2, column = 3)
    endirector.insert(0, "Director")
    #adding the year
    lbyear = Tkinter.Label(addboard, text = "Enter the movie's year:")
    lbyear.grid(row = 3, column = 1)
    yearadd = StringVar()
    enyear = Tkinter.Entry(addboard, textvariable = yearadd)
    enyear.grid(row = 3, column = 3)
    enyear.insert(0, "Year")
    #if a value is left blank program will ask what to do
    #to be added later
    #The button and the commands to put it all together
    btnok = Tkinter.Button(addboard, text = "Continue", command = addcontinue)
    btnok.grid(row= 5, column = 4)
    btncancel = Tkinter.Button(addboard, text = "Cancel", command=addboard.destroy)
    btncancel.grid(row = 5, column = 1)

i know i havent been too clear, also this isnt the full program as im running close to 500 lines right now but i can post it if needed

Just save the path to the movie file into the database. Then you call the movie name from the data base by splitting the path. eg...

filename= pathtofile.split("/")[-1].split(".")[0]

Then you get the filename

is there a way for me to link the movie file to the text in the listbox

Each listbox entry corresponds to a number, i.e. curselection returns the line number. You can link the number selected to a file using a dictionary.

awesome, how would i do the link your talking about? its exactly what i need!

ok so i have a movie added to the pickle file and i have a dialog to select the path to the file but pickle does not accept file objects, is there some way i can save it another way? im currently looking into other database saving methods but it'd be a shame to have to re-write everything that deals with pickle

Just link to the file name, not save file object. You must probably use full path names à la os.path.abspath.

still really unsure of what and how to do that. what ideally i would like is while adding a movie, a dialog box opens to ask for the file, i have this now what i would like is save the data in some form of dictionary so that when i call on the id the file location is also called. it will need to be able to add the id and the location to an existing list instead of writing over the existing data

maybe something like id:location?

or as i am currently using pickle is there a way to float the file location to ASCII and then when it is loaded change it back into a machine readable file location

file = /usr/moviefolder/movie perhaps?

or am i missing the ball completley and could you describe how exactly i could achieve this?

pickle works like any other DB if you know how to use it very well.

You can save the file into a pckle and provide its it by incrementing the entries.

If you are new with python or having problem with pickle, I recommend anydb module for you which comes as a standard instalation with python.The module works like a dict.

from my HTC phone. :)

thanks ill try that, the problem with pickle is it wont accept a file path as is is not definate ie)a file can be moved into a new folder. thanks for the heads up on anydb ill try that