Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
PyQt signals and slots example.py
from PyQt5.QtWidgets import QApplication, QWidget, QVBoxLayout, QSlider, QProgressBar
from PyQt5.QtCore import Qt
app = QApplication([])
window = QWidget()
layout = QVBoxLayout()
slider = QSlider(Qt.Horizontal)
progressBar = QProgressBar()
layout.addWidget(progressBar)
layout.addWidget(slider)
# slider.valueChanged - сигнал, progressBar.setValue - слот
slider.valueChanged.connect(progressBar.setValue)
window.setWindowTitle('Signal & slot')
window.setLayout(layout)
window.resize(300, 150)
window.show()
app.exec_()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment