I have some problems when I want to pass an argument defined by a function1, to a function2 that I'm calling by pressing a button.
I'd like to print 'ABC' when I press the button, by passing 'ABC', defined in function1, to function2 when I press the button.
I also need to keed the definition of 'ABC' in function1 and to print by using function2.
I'd like to avoid global variables.
Thank you
from tkinter import *
from tkinter import ttk
def function1():
var1=str('ABC')
print(var1)
return var1
def function2(var1):
print('var1='+str(var1))
def function3():
root = Tk()
button = ttk.Button(root, text = "Click Me")
button.pack()
var1=str()
button.config(command=lambda:function2(var1))
root.mainloop()
function1()
function3()