I'm using JES version 5.010. I'm trying to do this assignment for school:
For the first part of the assignment, you are going to write a function that will select, using pickAFile(), a picture file to be opened. If cancel is pressed in the pickAFile() dialogue box, then you must 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. If a picture file is selected, return the 'made' picture, otherwise (i.e. cancel was pushed and the user indicated that it was NOT a mistake) return an error message. NOTE: the JES function requestString (see JES Functions-->Input/Output) should be used when asking the user if the pressing of 'cancel' was a mistake.
For some reason my if statement, if f==None, isn't working properly and I have no clue why. My code is below
def assign3PartA():
noFile = True
while noFile:
f = pickAFile()
if f==None: #This is what isn't working
noFile=mistake()
noFile = False
print "Invalid option, you must select a picture to continue!"
else: #Working fine
pic = makePicture(f)
show(pic)
break
def mistake():
ask = requestString("Did you press cancel by mistake? Enter yes or no. ")
if ask == "yes" or ask == "Yes":
return True
elif ask == "No" or ask == "no":
return False
else:
print "Try again. Please enter either yes or no."
mistake()
I have also tried if f is None as well and that didn't work. Any help you can give is appreciated.