simple file button - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: GUI (https://python-forum.io/forum-10.html) +--- Thread: simple file button (/thread-10457.html) |
simple file button - Epilepsy - May-22-2018 Hi everyone, can you help me, i need a simple file button, to select an image and copy to a some other directory. Help me please, I have this: from tkinter import * from tkinter import ttk from tkinter.filedialog import askopenfilename root = Tk( ) #This is where we lauch the file manager bar. def OpenFile(): name = askopenfilename(initialdir="C:/Users/", filetypes =(("All files", "*.*")), title = "Choose a file." ) #Using try in case user types in unknown file or closes without choosing a file. try: with open(name,'r') as UseFile: copy(name,"asd/"+name) except: print("No file exists") Title = root.title( "File Opener") label = ttk.Label(root, text ="I'm BATMAN!!!",foreground="red",font=("Helvetica", 16)) label.pack() #Menu Bar menu = Menu(root) root.config(menu=menu) file = Menu(menu) file.add_command(label = 'Open', command = OpenFile) file.add_command(label = 'Exit', command = lambda:exit()) menu.add_cascade(label = 'File', menu = file)But I have problemas with the copy function RE: simple file button - Barrowman - May-22-2018 What problems do you have? |