By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
464,699 Members | 1,291 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 464,699 IT Pros & Developers. It's quick & easy.

pickAFile Question!

P: 2
How would I make it that if I opened pickAFile, that if cancel is pressed in the pickAFile() dialogue box, I want to ask the user if it was a mistake. If it was a mistake, open the pickAFile() dialogue again, and repeat until it is either not a mistake, or a picture file was selected.

Thanks so much in advance!

I have this down, it's not much but its a start...

Expand|Select|Wrap|Line Numbers
  1. def exampleA():
  2.   file = pickAFile() 
  3.   picture = makePicture(file)
  4.   show(picture)
Feb 28 '13 #1
Share this Question
Share on Google+
2 Replies

Expert 100+
P: 626
What does pickAFile return when cancel is pressed? If it is None then you can use something like
Expand|Select|Wrap|Line Numbers
  1. def exampleA():
  2.     mistake = True
  3.     while mistake:
  4.         file = pickAFile() 
  5.         if file==None:
  6.             mistake=ask_if_mistake() ## returns True or False
  7.         else:
  8.             picture = makePicture(file)
  9.             show(picture)
  10.             mistake=False 
Feb 28 '13 #2

P: 2
If a picture file is selected, I want it to return the 'made' picture, otherwise if cancel was pushed and the user indicated that it was NOT a mistake to return an error message.
Feb 28 '13 #3

Post your reply

Sign in to post your reply or Sign up for a free account.