Use lambda expression to act on button click event, PyQt5 pass parameters

Generally, the click event of the button we use in PyQt5 is generally written in the following way
write picture description here

But if we need to pass parameters, this method will not work, we need to use lambda expressions to pass parameters, such as the following way of writing

write picture description here
write picture description here

The self.whichbtn after the lamdba above is the method name, and the parameter behind the parentheses is a reference to a button passed here. The reference of the lamdba expression helps us solve many problems and can be learned in depth.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325651151&siteId=291194637