Got the solution for this,
Had to declare userData
as global
, that made my solution.
Get user input from Entry (Tkinter) on click of Button
Frage
Code objective: to get User data on click of Button using Tkinter and Code as follows:
class myClass:
def OnClick():
userData = entry.get()
root.destroy()
return userData
def myFunction()
<My code which creates GUI>
button = Button (app, text="Submit", command=OnClick)
button.grid()
root.focus_set()
root.mainloop()
return userData
Object = myClass()
GetUserData = Object.myFunction()
print GetUserData
As user Enters a number on GUI and Clicks on Button, OnClick()
function should return that value to myFunction()
then it should return for GetUserData
, but this code is not working as my objective.
Lösung
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow