In this tutorial, we are going to talk about how we connect a button in PyQt5 to a specific task. If you don't know about PyQt5 buttons or their functionalities, you can get all the knowledge about it by reading the How to Create Buttons In PyQt5 and Animate them using Image and CSS post.
I'm using the "self.my_button.clicked.connect(self.my_task)" command to make a connection between my task and button. Also, I put my task under a def function as below and connect to my def function when the button is pressed using the "clicked.connect()" function.
def my_task(self):
print("we successfully connected the Button.")
print("You can put any of your tasks under the def function")
print("we successfully connected the Button.")
print("You can put any of your tasks under the def function")
in my def function, I set a print text to confirm that button is pressed.
Note: You need to keep in mind that you need to put "self" inside the def function you created. "def my_task(self)"
0 Comments