I am new to Python and I am writing a program just for fun. My program consists of three .py files (say a.py, b.py, c.py). a will either call functions inside b, or c, depending on the user option. After completing the first round, he asks if the user wants to continue or just exit the program. If they chose to continue, he again asks if he should work b or c.
The problem I ran into is that the first time a will call the functions either perfectly, but also smoothly, and then when I choose to continue, it calls any function again fine, it will enter the function, but then function gets stuck in the first step.
The program does not exit without giving an error. It accepts the raw_input variable, but it will not continue. I was wondering if there is a way to get it to accept the variable, and then continue the process (make it "peel off"). I already tried passing the pass on the next line. This did not work.
Here are the steps you need to follow, starting with the request, to continue:
Continue = tkMessageBox.askyesno('Cypher Program', 'I have completed the task' + '\nWould you like to do anything else?') ## This is in a.py; if Continue == True: cyp() def cyp(): global root root = Tk() root.title("Cypher Program") root['padx'] = 40 root['pady'] = 20 textFrame = Frame(root) Label(root, text = 'What would you like to do?').pack(side = TOP) widget1 = Button(root, text = 'Encrypt a file', command = encrypt) widget1.pack(side = LEFT) widget2 = Button(root, text = 'Decrypt a file', command = decrypt) widget2.pack(side = RIGHT) widget3 = Button(root, text = 'Quit', command = quitr) widget3.pack(side = BOTTOM) root.mainloop() def encrypt(): root.destroy() encrypt3.crypt() ##Then from there it goes to b.py; def crypt(): entry('Enter a file to encrypt:', selectFile) def entry(msg1, cmd): global top top = Toplevel() ##changed it to Toplevel top.title("File Encrypion") top['padx'] = 40 top['pady'] = 20 textFrame = Frame(top) entryLabel = Label(textFrame) entryLabel['text'] = msg1 entryLabel.pack(side = LEFT) global entryWidget entryWidget = Entry(textFrame) entryWidget['width'] = 50 entryWidget.pack(side = LEFT) textFrame.pack() button = Button(top, text = "Submit", command = cmd) button.pack() button.bind('<Return>', cmd) top.mainloop() def selectFile(): if entryWidget.get().strip() == "": tkMessageBox.showerror("File Encryption", "Enter a file!!") else: global enc enc = entryWidget.get().strip() + '.txt' top.destroy() ##gets stuck here ##This is the rest of crypt(). It never returns to the try statement try: view = open(enc) except: import sys sys.exit(badfile()) text = ''