PYQT the slot function of the Multiple-button click event to send the signal button.

Source: Internet
Author: User

Key functions: Qpushbutton's Setobjectname ()/objectname ()

Personal Note: Press the function or area to bind the button's click event to a different slot function.

From pyqt5.qtwidgets import (Qapplication, Qwidget, Qpushbutton, Qhboxlayout,                                         qlineedit) from Pyqt5.qtgui import *< C1/>from Pyqt5.qtcore Import *  import sys  def clickhandle ():    # #main代表按钮的容器widget的对象    button = Main.sender ()    print (Button.objectname ()) If __name__ = = ' __main__ ':                       app=qapplication (SYS.ARGV)      main= Qwidget ()          latout = Qhboxlayout ()    main.setlayout (latout)        but_1 = Qpushbutton (' but_1 ')    but_1. Setobjectname (' but_1 ')    but_1.clicked.connect (clickhandle)    but_2 = Qpushbutton (' but_2 ')    but_2. Setobjectname (' but_2 ')    but_2.clicked.connect (clickhandle)        edit_1 = Qlineedit ()    edit_2 = Qlineedit ()        latout.addwidget (but_1)    latout.addwidget (but_2)        latout.addwidget (edit_1)    Latout.addwidget (edit_2)        Main.show ()      app.exec_ ()

PYQT the slot function of the Multiple-button click event to send the signal button.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.