I
I
in Touch2020-08-10 09:16:38
PyQt
in Touch, 2020-08-10 09:16:38

How to pass an argument to a function on button click in PyQt5?

Problem: by standardly binding a function to a button, arguments cannot be passed to it.

def active_1(x):
    print(x*2)

ui.btn.clicked.connect(active_1)

Is it possible to do something so that when you click on btn, active_1 passes 1 as an argument?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexey Yarkov, 2020-08-10
@KenLIne

ui.btn.clicked.connect(lambda: active_1(1))

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question