I tried to make a function which create a button with a command (action) on a window but I can't specify a self variable.
The function :
def addButton(self,text,row,column,pady,action):
action = "Window."+str(action)
print(action)
button = Button(self.Window, text=str(text), command=lambda:exec(action))
button.grid(row=int(row),column=int(column),pady=int(pady),sticky=EW)
self.buttons.append(button)
I'll be grateful if someone can help me
getattris your friend: docs.python.org/3/library/functions.html#getattr. Your question is unclear, so I can't help tell you exactly what to do, but you can usegetattrto retrieve the callable object that you want to be your action. It would look something like:action_obj = getattr(Window, action)