File for Copying the Directory to other location which the user can specify

import sys
import os
import tkMessageBox
from Tkinter import *
from tkCommonDialog import Dialog
import shutil
import tkFileDialog
import win32com.client

win = Tk()
win.title("Copying the Directory to specified location")
win.geometry("600x600+200+50")
win.resizable()
src = \[code\]
des= \[/code\] 
class Copy():
    
    def __init__(self):
        def srce():
            src = tkFileDialog.askdirectory(title = "The source folder is ")
            textboxsrc.delete(0,END)
            textboxsrc.insert(0,src)
            print src
            return src
        
        textboxsrc = Entry(win, width="70")
        textboxsrc.insert(0,'Enter master file name')
        textboxsrc.pack()
        textboxsrc.place(relx=0.40, rely=0.06, anchor=CENTER)
        bu = Button(text = "Source",font = "Verdana 12 italic bold",bg = "Purple",fg= "white", command= srce)
        bu.pack(fill =X, expand=YES)
        bu.place(relx=0.85, rely=0.06, anchor=CENTER)

        def dest():
            des = tkFileDialog.askdirectory(title = "TheDestination folder is ")
            textboxdes.delete(0,END)
            textboxdes.insert(0,des)
            print des
            return des
                    
        textboxdes = Entry(win, width="70")
        textboxdes.insert(0,'Enter master file name')
        textboxdes.pack()
        textboxdes.place(relx=0.40, rely=0.13, anchor=CENTER)
        bu1 = Button(text = "Destination",font = "Verdana 12 italic",bg = "Purple",fg= "white", command= dest)
        bu1.pack(fill =X, expand=YES)
        bu1.place(relx=0.85, rely=0.13, anchor=CENTER)


    def start():
        
        #try:
        shutil.copytree(src,des)
        #except :
            #tkMessageBox.showwarning("Copying file",  "Error while copying\n(%s)" )
        
    bn =Button(text = "Copy",font = "Verdana 12 italic", bg = "Purple",fg= "white",command=start)
    bn.pack(fill =X, expand = YES)
    bn.place(relx=0.50, rely=0.25, anchor=CENTER)

    
obj= Copy()


win.mainloop()



Copying the Directory from one Location to Another

import sys
import os
import tkMessageBox
from Tkinter import *
from tkCommonDialog import Dialog
import shutil
import tkFileDialog
import win32com.client

win = Tk()
win.title("Copying the Dorectory to specified location")
win.geometry("600x600+200+50")
win.resizable()
class Copy:
   
    def __init__(self,Obj):
        
        la = Label(win, text = "Source Directory is",font = "verdana 12 italic bold", width = 20,fg = "Red", bg = "WHITE", )
        la.grid(row=1, column =1)
        abc = "tk_chooseDirectory"
        bu = Button(text="Source", font = "Verdana 12 italic", command= abc )
        bu.grid(row =1 , column =3)     
        e=Entry()
        e["text"]= os.path.dirname(abc)
        e.grid(row=1, column=2)
        
        la1 = Label(win, text = "DestibationDirectory is",font = "verdana 12 italic bold", width = 20,fg = "Red", bg = "WHITE", )
        la1.grid(row=2, column =1)
        abc1 = "tk_chooseDirectory"
        bu1 = Button(text="Destination", font = "Verdana 12 italic", command=abc1)
        bu1.grid(row =2 , column =3)
        e1=Entry()
        e1["text"]= os.path.dirname(abc1)
        e1.grid(row=2, column=2)
        
        def start():
            try:
                shutil.copytree(abc, abc1)
            except :
                tkMessageBox.showwarning("Copying file",  "Error while copying\n(%s)" )
        bu2 = Button(text="Copy", font= "Verdana 12 bold", command =start)
        bu2.grid(row =3, column =2)
        
obj = Copy(win)
win.mainloop()




Copyright(c) 2017 - PythonBlogs.com
By using this website, you signify your acceptance of Terms and Conditions and Privacy Policy
All rights reserved