Réponse acceptée !
Voila, comme promis, voici un exemple avec WxPython
import shutil
import wx
import wx.lib.dialogs
class
MyFrame(wx.Frame):
def__init__(self, parent, title):
wx.Frame.__init__(self, parent, -1, title,size=((10, 10)))
dlg = wx.FileDialog(
self, message="Choisiser les fichiers à copier",
defaultFile="", wildcard="Tous les fichier|*.*", style=wx.OPEN | wx.MULTIPLE )
if dlg.ShowModal() == wx.ID_OK:
fichier = dlg.GetPaths()
dlg1 = wx.DirDialog(self, "Choisisez le répertoir d'arrivée",
style=wx.DD_DEFAULT_STYLE|wx.DD_NEW_DIR_BUTTON)
if dlg1.ShowModal() == wx.ID_OK:
destination=dlg1.GetPath()
i=0
msg=''
while i<len(fichier):
shutil.copy (fichier[i],destination)
msg=msg+'<< '+str(fichier[i])+ ' >> à bien été copier dans << ' +\
str(destination)+' >>.\n'
i=i+1
dlgok = wx.lib.dialogs.ScrolledMessageDialog(self, msg, "Confirmation")
dlgok.ShowModal()
else:
d1 = wx.MessageDialog(self, 'Vous avez mis fin à la procédure',
'Information',
wx.OK | wx.ICON_INFORMATION
)
d1.ShowModal()
d1.Destroy()
else:
d = wx.MessageDialog(self, 'Vous avez mis fin à la procédure',
'Information',
wx.OK | wx.ICON_INFORMATION
)
d.ShowModal()
d.Destroy()
self.Close()
class
MyApp(wx.App):
defOnInit(self):
frame = MyFrame(None, "")
self.SetTopWindow(frame)
frame.Show(True)
return
True
app = MyApp(True)
app.MainLoop()
En résumer, pour copier un fichier, il faut faire shutil.copy (fichier,destination) mais pour simplement déplacer, il faut faire shutil.move(fichier, dst). Je précise que dans les deux cas, fichier doit être le chemain d'accé du fichier et que répertoire est chemain d'accé du destination de destination. Il ne faut pas ouvlier de faire import shutil.
Bonne continuation
________
Aéra 