#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2017
    Posts
    20
    Rep Power
    0

    [Python 3 + Tkinter] File Loader can't find .avi files, help needed!


    Hey python programmers...

    I am learn tkinter and i try to make an .avi file loader with an listbox of imported avi files...
    But my script (or program) can't find the .avi files you will be import...

    This is my code:
    Code:
    from tkinter import *
    from tkinter import ttk
    from tkinter.filedialog import askopenfilename
    
    main = Tk()
    
    def Open():
        name = askopenfilename(initialdir = 'C:/', filetypes = [('AVI Files', '*.avi')], title = "Open File")
    
        print(name)
    
        try:
            with open(name) as filename:
    
                listbox.insert(END, str(filename.name()))
                print(filename.name())
    
        except:
            print("Session Failed !")
    
    
    def Exit():
        print("Exit...")
        exit()
    
    
    Title = main.title('AVI File Loader')
    label = ttk.Label(main, text = 'Load Movies')
    label.pack()
    
    menu = Menu(main)
    main.config(menu=menu)
    main.geometry("150x250+300+300")
    
    file_label = Label(main, text = 'Files')
    file_label.pack()
    
    file = Menu(menu)
    file.add_command(label = 'Import', command = Open)
    file.add_command(label = 'Exit', command = Exit)
    menu.add_cascade(label = 'File', menu = file)
    
    listbox = Listbox(main)
    listbox.pack(fill = BOTH, expand = 1)
    
    
    main.mainloop()
    What is the reasion thad my script can't find my .avi files... this is an test... i try to figure out,
    how i can create GUI's in tkinter... now i try to make an .avi file loader, just you can see the
    name of the avi files... into the listbox...

    Can you give my two just codes (or reather code corrections), please ?...
    - 1) To correct my code for load .avi files
    - 2) To correct my code for load multiply .avi files in an directory

    Thanks for help... Jamie.
  2. #2
  3. Contributing User
    Devshed God 1st Plane (5500 - 5999 posts)

    Join Date
    Aug 2011
    Posts
    5,910
    Rep Power
    509
    program works on operating system Ubuntu 17.10 python version

    Python 3.6.3 (default, Oct 3 2017, 21:45:48)
    [GCC 7.2.0] on linux

    "works" I was able to navigate to a directory containing .avi files, choose one, and the program printed that file name in the console.
    [code]Code tags[/code] are essential for python code and Makefiles!

IMN logo majestic logo threadwatch logo seochat tools logo