How can I get the value of 'username' inside the function Login() to use it on another python program? -


from tkinter import *  root = tk() root.geometry("230x100")  l1 = label(root, text="login page", bg = "blue", fg = "white") l1.pack(fill = x, ipadx = 5, ipady = 5)  v = stringvar(root, value='enter username here') e1 = entry(root, textvariable=v) e1.pack(side = left, padx = 5, pady = 5)  def login():     username = v.get()     print "username '" + username + "'"  b1 = button(root, text ="login" , command = login) b1.pack(side = right, fill = x, pady=5)  mainloop() 

i have been trying value of 'username' in function login() use on python program.

i have tried setting global variable , changing scope not getting anything.

i need use value of 'username' outside function login(). please provide insights.

think scope moment. when program ends, memory (meaning variables, objects, etc.) released. 2 ways can think of pass 1 program is:

1) write username value file next program can read part of startup.

2) have third "controller" or "launcher" program runs program above, takes return value program, passes value parameter next program.

but in case, have save value past scope of program above.


Comments

Popular posts from this blog

java - SSE Emitter : Manage timeouts and complete() -

jquery - uncaught exception: DataTables Editor - remote hosting of code not allowed -

java - How to resolve error - package com.squareup.okhttp3 doesn't exist? -