May-22-2018, 02:58 AM
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:
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
