Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

Tkinter menu for play movie found in comouter


#--*-- coding:utf-8 --*--
#-----------Import Some module's-------------------------------------
from Tkinter import *
from tkFileDialog import askopenfilename
import os, subprocess

#-----------Define Global Variable here------------------------------

#List of variant movie extensions
file_implement=["mkv", "avi", "mp4"]
#Define dictionary for add name and readlpath
real_path=[]
d={}

#-----------Define Function's----------------------------------------

def search_movie():
"""Search for movie in target folder"""
movie_sr_name=[]
for root,dirname,filename in os.walk("/home/borko/Video"):
for movie_file in filename:
if movie_file.startswith(tuple([i for i in ("Sample", "sample")])):
continue
if movie_file.endswith(tuple([i for i in file_implement])):
d[movie_file]=os.path.join(root,movie_file)


def Popalni():
"""After start serch_movie insert result in mylist Form"""
search_movie()
for i in sorted(d.keys()):
mylist.insert(END,i)
mylist.see(END)
mylist.update()


def choose():
"""Sort dictionary and load real path to movie"""
firstIndex = mylist.curselection()[0]
val = d[sorted(d.keys())[firstIndex]]
os.system("%s '"'%s'"'" % ("vlc", val))


def Open_Directory():
"""Use for add additional file"""
name = askopenfilename()
print name


#-----------Tkinter define----------------------------------------
root = Tk()
root.title("Film's playlist")
root.geometry("500x250")
#Scrol bar settings
scrollbar = Scrollbar(root)
scrollbar.pack( side = RIGHT, fill=Y )

#Menu Bar settings
menubar = Menu(root)
filemenu = Menu(menubar, tearoff=0)
filemenu.add_command(label="Load_All", command=Popalni)
filemenu.add_command(label="Open_Directory", command=Open_Directory)
filemenu.add_command(label="Edit")
filemenu.add_separator()
filemenu.add_command(label="Exit", command=root.quit)
menubar.add_cascade(label="Menu", menu=filemenu)
root.config(menu=menubar)

mylist = Listbox(root, yscrollcommand = scrollbar.set , bg="#99CC99")

frame=Frame(root)
frame.pack()
#Label(text="Anchor").pack(side=LEFT)
chooseButton = Button(frame, text="Load_Movie", command=Popalni ,bg="#FFCC00")
chooseButton.pack(side=LEFT,anchor=NW)
chooseButton1 = Button(frame, text="Run_Movie", command=choose, bg="#FFCC00")
chooseButton1.pack(anchor=NW)
mylist.pack( side = LEFT, fill = BOTH, expand=1 )
scrollbar.config( command = mylist.yview )


if __name__ == "__main__":
mainloop()




This post first appeared on Linux Command's, please read the originial post: here

Share the post

Tkinter menu for play movie found in comouter

×

Subscribe to Linux Command's

Get updates delivered right to your inbox!

Thank you for your subscription

×