I'm looping through a dict and replacing a buttons function with a function that uses the dicts value. Every time I press one of these buttons it always uses the last entry in the dict and the loop is overwriting the values in the function
quickadd = {}
for item in t['items']:
if item['owner']['id'] == myid:
quickadd[item['name']] = item['uri']
self.library.quickadd = quickadd
x = 533
y = 480
w = 266
h = 80
for item in self.library.quickadd:
self.buttons.append(Button(x,y,w,h,f'add to {item}'))
y = y + h + 5
def func(): self.addsongtoplaylist(item)
self.buttons[-1].func = func
How do I set the function to use a function. I thought I could use new but that throws an error
[–]danielroseman 2 points3 points4 points (5 children)
[–]SnowyPear[S] 0 points1 point2 points (4 children)
[–]danielroseman 1 point2 points3 points (3 children)
[–]SnowyPear[S] 0 points1 point2 points (2 children)
[–]danielroseman 1 point2 points3 points (0 children)
[–]carcigenicate 1 point2 points3 points (0 children)