Python Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming LanguagesPython Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old August 9th, 2004, 01:37 PM
deusaero deusaero is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2004
Posts: 1 deusaero User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Question 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.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPython Programming > Problem with ProgressDialog


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway
Stay green...Green IT