diff options
Diffstat (limited to 'examples/widgets/tutorials/cannon/t5.py')
-rw-r--r-- | examples/widgets/tutorials/cannon/t5.py | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/examples/widgets/tutorials/cannon/t5.py b/examples/widgets/tutorials/cannon/t5.py new file mode 100644 index 000000000..ed5d085f8 --- /dev/null +++ b/examples/widgets/tutorials/cannon/t5.py @@ -0,0 +1,41 @@ +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause + +# PySide6 tutorial 5 + + +import sys + +from PySide6.QtCore import Qt +from PySide6.QtGui import QFont +from PySide6.QtWidgets import (QApplication, QLCDNumber, QPushButton, + QSlider, QVBoxLayout, QWidget) + + +class MyWidget(QWidget): + def __init__(self, parent=None): + super().__init__(parent) + + quit = QPushButton("Quit") + quit.setFont(QFont("Times", 18, QFont.Bold)) + + lcd = QLCDNumber(2) + + slider = QSlider(Qt.Horizontal) + slider.setRange(0, 99) + slider.setValue(0) + + quit.clicked.connect(qApp.quit) # noqa: F821 + slider.valueChanged.connect(lcd.display) + + layout = QVBoxLayout(self) + layout.addWidget(quit) + layout.addWidget(lcd) + layout.addWidget(slider) + + +if __name__ == '__main__': + app = QApplication(sys.argv) + widget = MyWidget() + widget.show() + sys.exit(app.exec()) |