from PyQt5.QtCore import Qt
from PyQt5.QtWidgets import (
QApplication, QWidget, QMainWindow,
QVBoxLayout, QHBoxLayout, QFormLayout, QGridLayout, QStackedLayout,
QPushButton, QComboBox, QLineEdit, QCheckBox, QRadioButton,
)
class Window(QWidget):
def init(self):
super().init()
layVer = QVBoxLayout()
self.comBox = QComboBox()
self.comBox.addItems(["One", "Two", "Three"])
self.comBox.activated.connect(lambda x: self.onComBox(x))
layVer.addWidget(self.comBox)
self.setLayout(layVer)
layHor = QHBoxLayout()
self.cheBox1 = QCheckBox("A")
layHor.addWidget(self.cheBox1)
self.setLayout(layHor)
layVer.addLayout(layHor)
def onCheBox(self, s):
print(s)
def onComBox(self, s):
print(s, self.comBox.currentText())
if name == “main”:
app = QApplication([])
win = Window()
win.show()
app.exec_()