본문 바로가기
Python

[Python]PyQt Widgets

by YJHTPII 2024. 5. 7.
반응형

 

 

 

https://www.pythonguis.com/tutorials/pyqt-basic-widgets/

 

PyQt5 Widgets — QCheckBox, QComboBox, QPushButton, QLabel, QSlider

PyQt5 has a huge library of widgets, including buttons, checkboxes, list boxes, and sliders or dials. Learn how to use them in your apps. In Qt, like in most GUI frameworks, widget is the name given to a component of the UI that the user can interact with.

www.pythonguis.com

 

 

import sys

from PyQt5.QtWidgets import (
    QApplication,
    QCheckBox,
    QComboBox,
    QDateEdit,
    QDateTimeEdit,
    QDial,
    QDoubleSpinBox,
    QFontComboBox,
    QLabel,
    QLCDNumber,
    QLineEdit,
    QMainWindow,
    QProgressBar,
    QPushButton,
    QRadioButton,
    QSlider,
    QSpinBox,
    QTimeEdit,
    QVBoxLayout,
    QWidget,
)

# Subclass QMainWindow to customize your application's main window
class MainWindow(QMainWindow):
    def __init__(self):
        super().__init__()

        self.setWindowTitle("Widgets App")

        layout = QVBoxLayout()
        widgets = [
            QCheckBox,
            QComboBox,
            QDateEdit,
            QDateTimeEdit,
            QDial,
            QDoubleSpinBox,
            QFontComboBox,
            QLCDNumber,
            QLabel,
            QLineEdit,
            QProgressBar,
            QPushButton,
            QRadioButton,
            QSlider,
            QSpinBox,
            QTimeEdit,
        ]

        for w in widgets:
            layout.addWidget(w())

        widget = QWidget()
        widget.setLayout(layout)

        # Set the central widget of the Window. Widget will expand
        # to take up all the space in the window by default.
        self.setCentralWidget(widget)

app = QApplication(sys.argv)
window = MainWindow()
window.show()
app.exec()
반응형

'Python' 카테고리의 다른 글

Python Task Scheduler  (0) 2024.11.20
[Python]파이썬 출력 화면 지우기  (0) 2024.05.10
[Python] Candle Stick Chart  (0) 2024.05.07
Dragon Moving Banner  (0) 2024.05.07
[Errno 13] Permission denied: '/dev/ttyUSB0'  (0) 2024.05.02

댓글