I'm trying to get a user's proxy information using a simple TK GUI with the following code:
def getProxyCredentials(proxy, username, password):
root = Tk()
#define the entry boxes for username password and proxy
proxyBox = Entry(root)
proxyBox.insert(0, 'some.default.proxy:8080')
userBox = Entry(root)
pwdbox = Entry(root, show = '*')
Label(root, text = 'Proxy Server').pack(side = 'top')
proxyBox.pack(side = 'top')
Label(root, text = 'Username').pack(side = 'top')
userBox.pack(side = 'top')
Label(root, text = 'Password').pack(side = 'top')
pwdbox.pack(side = 'top')
def onokclick():
proxy = proxyBox.get()
username = userBox.get()
password = pwdbox.get()
root.destroy()
return None
Button(root, command=onokclick, text = 'OK').pack(side = 'top')
root.mainloop()
return True
When I call the function outside, all the string fields do not change.
proxy = ''
username = ''
password = ''
getProxyCredentials(proxy, username, password)
The passed in variables are still blank even though they are assigned within the function. Strings are passed by reference, so they should no longer be blank. What am I missing/not doing correctly?