コード例 #1
0
 def __init__(self):
     wx.Frame.__init__(self, None, wx.ID_ANY,
                       "File Transfer", size=(500,300))
     panel = wx.Panel(self, wx.ID_ANY)
     self.currentDirectory = os.getcwd()
     
     wx.StaticText(panel, label='This will help you choose modified files that need to be transferred', pos=(100,50))
     wx.StaticText(panel, label='The last check was done on: {}'.format(db_tab.disp_tab()), pos =(100,80))
     
     
     dirDlgBtn1 = wx.Button(panel, label="Choose the Folder to be checked",pos=(150,120))
     dirDlgBtn2 = wx.Button(panel, label="Choose the Folder to move files into", pos =(150,150))
     
     dirDlgBtn1.Bind(wx.EVT_BUTTON, self.folderMod)
     dirDlgBtn2.Bind(wx.EVT_BUTTON, self.folderMove)
     proCeed = wx.Button(panel,label="Proceed", pos=(150,200))
     proCeed.Bind(wx.EVT_BUTTON, self.fileTrans)
コード例 #2
0
    def __init__(self,master):
        self.frame1 = ttk.Frame(master)
        self.frame1.pack()
        self.frame2 = ttk.Frame(master)
        self.frame2.pack()
        self.label1 = ttk.Label(self.frame1, text = "This program allows you to check files modified and move them to a new folder")
        self.label1.grid(row=0,column=0)
        self.label2 = ttk.Label(self.frame1, text = "The last file check was done on: "+str(db_tab.disp_tab()))
        self.label2.grid(row=1,column=0)
        
        def folderMod():
            global sourceFold
            sourceFold = filedialog.askdirectory(initialdir = os.getcwd(), title = 'Choose the folder',
                                          mustexist =1)
            
        
        #DirDialog to check modified folder
        def folderMove():
            global destFold
            destFold = filedialog.askdirectory(initialdir = os.getcwd(), title = 'Choose the folder',
                                          mustexist =1)
            

        def fileTrans():
            global file_es, sourceFold
            print("Source: "+sourceFold)
            print("Destination: "+destFold)
        
            for fil_es in os.listdir(sourceFold):
            
                print("last modified: {}" .format(time.ctime(os.path.getmtime(sourceFold+"/"+fil_es))))
                if (time.time() - os.stat(sourceFold+"/"+fil_es).st_mtime)/(60*60) < 24:
                    shutil.move(sourceFold+"/"+fil_es,destFold)
        
            #Invoking message box
            messagebox.showinfo(title ="File Transfer Info",message = "File Transfer Successful")
            
            #calling database
            db_tab.update_tab()
        
        #buttons
        self.button1 = ttk.Button(self.frame2,text = "Choose the folder for file check",
                                  command = folderMod)
        self.button1.grid(row=0,column=0)
        self.button2 = ttk.Button(self.frame2,text = "Choose the folder for moving modified files",
                                  command = folderMove)
        self.button2.grid(row=0,column=1)
        self.button3 = ttk.Button(self.frame2,text = "Initiate move", command = fileTrans)
        self.button3.grid(row=1,column=0,columnspan = 2)