Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from PyQt5.QtWidgets import QRadioButton, QApplication, QVBoxLayout, QWidget
- def onClicked(button):
- if button.text() == 'Button1':
- if button.isChecked():
- print("Button1 is checked")
- if button.text() == 'Button2':
- if button.isChecked():
- print("Button2 is checked")
- app = QApplication([])
- window = QWidget()
- RadioButton1 = QRadioButton('Button1')
- RadioButton2 = QRadioButton('Button2')
- RadioButton1.toggled.connect(lambda:onClicked(RadioButton1))
- RadioButton2.toggled.connect(lambda:onClicked(RadioButton2))
- layout = QVBoxLayout()
- layout.addWidget(RadioButton1)
- layout.addWidget(RadioButton2)
- window.setLayout(layout)
- window.setGeometry(200, 200, 300, 150)
- window.setWindowTitle('RadioButton Example')
- window.show()
- app.exec_()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement