On Thursday, March 17, 2016 at 12:19:39 PM UTC-4, kevin...@gmail.com wrote: > Hello: > > Working with python 2.7. > > I have a module promptUser_PWord that will prompt a user for their user name > and pword. Works fine stand alone. > I also have a module, genXLS that does a bunch of processing it has worked > fine for months. And a class Unamepword define as follows: > class Unamepword: > ## > ## class to hold user name and pWord for Database > uName = None > pWord = None > def __init__(self, uStr, pStr): > self.uName = uStr > self.pWord = pStr > > There are scenarios where running genXLS requires the user to be prompted for > their user name and password. > > The final line of promptUser_PWord are: > user_pword = Unamepword(dbUser, pWord) > return user_pword > > > And in genXLS I have > ## prompt the user for a User name a& pWord > user_pword = promptUser_PWord() > > I get the error > File "H:\dev\eclipse\workspace\genXls\src\genXls\promptUser_PWord.py", line > 58 > return user_pword > SyntaxError: 'return' outside function > > > Here is my complete newbee question: > How do I stich these pieces together so the user will be prompted and the > values (contained in the class Unamepword) will be passed back to genXLS ? > > Many thanks for your attention to this matter. > > KD
As requested , full code for promptUser_PWord import base64 import os import _winreg import winerror from cryptography.fernet import Fernet from cryptography.hazmat.backends import default_backend from cryptography.hazmat.primitives import hashes from cryptography.hazmat.primitives.kdf.pbkdf2 import PBKDF2HMAC from Tkinter import * from unamepword import Unamepword def butContinue(): global dbUser global pWord global pwKey dbUser = entryName.get() pWord = entryPWord.get() root1.quit() dbUser = "" pWord = "" root1 = Tk() ##root1.geometry("500x250") lblTop = Label(root1, text= 'Please enter Database User Name & Password ', font="Helvetica 14").grid(row=0, column=0, columnspan=3 , pady=5) lblDB = Label(root1, text= 'User Name').grid(row=2, column=0 ) lblPWord = Label(root1, text= 'Password').grid(row=3,column=0) entryName = Entry(root1) entryName.grid(row=2, column=1, pady=5) entryPWord = Entry(root1) entryPWord.grid(row=3, column=1, pady = 5) butGo = Button(root1, text=" Continue " , command=butContinue ).grid(row=5, column=1, sticky=W, pady=10) root1.mainloop() print "After the MainLoop" print dbUser print pWord if dbUser is None or pWord is None or dbUser.strip() == "" or pWord.strip() == "" : print "** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** **" print "** Missing a value CANNOT continue ** ** ** " print "** Bye " ## sys.exit() user_pword = Unamepword(dbUser, pWord) return user_pword -- https://mail.python.org/mailman/listinfo/python-list