Я думаю, что сделал это. Я не знаю, является ли это «хорошей практикой», но она работает: D
self.list = {}
def foo(self,x,key):
self.list [key] = x
def onClick(self):
print (self.list)
return
def funcSlider(self, posX,posY,key):
w = tk.Scale(self, from_=0, to=8, orient='horizontal',command=lambda s: self.foo(s,key))
w.pack()
w.place(x=posX, y=posY, in_=self)
self.list [key] = value
button = tk.Button(self, text="button ",
command=lambda: self.funcSlider(120,33,'test'),width = 20)
button .pack(anchor="w")
button .place(x=250, y=50, in_=self)
button2 = tk.Button(self, text="Send",
command=self.onClick, width=42,bg="#4BAD2E")
button2 .pack(anchor="w")
button2 .place(x=250, y=430, in_=self)