
August 9th, 2004, 01:37 PM
|
|
Registered User
|
|
Join Date: Aug 2004
Posts: 1
Time spent in forums: < 1 sec
Reputation Power: 0
|
|
Problem with ProgressDialog
Okay, this is probably a simple matter that I'm making more complicated than necessary (  ) but here goes:
The portion of the program I'm having trouble with should copy a number of files from one directory to another (replacing any identically-named files already present in the destination directory). Nothing challenging there, it works fine. It also displays a ProgressDialog showing how far along it is. Here's the code for this part of the prog:
Code:
for file in files:
prog = prog + 1
if file in ftp_files:
rem_file = os.path.join(temp_ftp_dir, file)
os.remove(rem_file)
ftp_files.remove(file)
elif file in web_files:
rem_file = os.path.join(temp_web_dir, file)
os.remove(rem_file)
web_files.remove(file)
if re.match("[.][nN][eE][fF]", file[-4:]):
print prog
frame.pddlg.Update(prog, "Copying file "+str(prog)+" of "+str(numimages)+": "+file)
shutil.copy2(file, os.path.join(temp_ftp_dir, file))
elif re.match("[.jJ][jJpP][pPeE][eEgG]", file[-4:]):
frame.pddlg.Update(prog, "Copying file "+str(prog)+" of "+str(numimages)+": "+file)
shutil.copy2(file, os.path.join(temp_web_dir, file))
else:
frame.pddlg.Update(prog, "Error copying file "+str(prog)+" of "+str(numimages)+": "+file+"!\nFile is of an invalid format!")
frame.pddlg.Destroy()
Before this code, the ProgressDialog has been created, all needed variables assigned, etc.
Now, say there are 8 files in the list to be copied. The first seven will copy correctly, and the Dialog will display correctly ("copying 7 of 8", etc). When it hits the last file, it runs through the loop as far as frame.pddlg.Update, calls frame.pddlg.Update ("copying 8 of 8"), then stops. After manually closing the ProgressDialog, the last file is copied, and life goes on. I had this problem once before, but I'll be damned if I can remember how I fixed it.
|