Quantcast
Channel: Active questions tagged python - Stack Overflow
Viewing all articles
Browse latest Browse all 14097

Make PyQt5 qframes clickable to call a function and pass a different variable for each frame [duplicate]

$
0
0

I have a Grid of PyQt5 Frames and want to make every frame clickable to call a function and pass a variable.

I know that you can make it clickable and call function like this:

self.frame[0][0].mousePressEvent = self.test

but I can't pass a variable.

Is there a way to attach a specific x and y coordinate to the frames? I tried it like this but it only passes the final value of x and y:

for y in range(50):    for x in range(50):        self.pixel[x][y].mousePressEvent = lambda _: self.test(x, y)

Viewing all articles
Browse latest Browse all 14097

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>