콤보박스는 많은 선택지 중에서 하나를 선택할 수 있는 기능입니다. 선택지가 펼쳐지며 사용자가 원하는 것을 고를 수 있습니다. import sys from PyQt5.QtWidgets import QApplication, QWidget, QLabel, QComboBox class comboBoxApp(QWidget): def __init__(self): super().__init__() self.initUI() def initUI(self): self.lb1 = QLabel('선택하세요.', self) self.lb1.move(10,20) combo_box = QComboBox(self) combo_box.addItem('떡볶이') combo_box.addItem('순대') combo_box.addItem..
라디오 버튼은 여러 선택 중에서 1개만 선택할 때 사용합니다. 선택한 버튼에 따라 다르게 출력되는 기능을 만들었습니다. import sys from PyQt5.QtWidgets import QApplication, QWidget, QRadioButton, QHBoxLayout, QLabel from PyQt5.QtCore import Qt class Radiodemo(QWidget): def __init__(self, parent=None): super(Radiodemo, self).__init__(parent) layout = QHBoxLayout() b1 = QRadioButton('첫 번째 버튼') b1.setChecked(True) b1.toggled.connect(lambda: self.btns..
체크박스를 사용해서 체크했을 때, 체크를 풀었을 때 상황에 따라 다양한 옵션을 적용할 수 있습니다. import sys from PyQt5.QtWidgets import QApplication, QWidget, QCheckBox from PyQt5.QtCore import Qt class QCheckBoxApp(QWidget): def __init__(self): super().__init__() self.initUI() def initUI(self): checkbox1 = QCheckBox('첫 번째 체크박스', self) checkbox2 = QCheckBox('두 번째 체크박스', self) checkbox1.move(20,10) checkbox2.move(20, 30) checkbox1.toggl..
위젝 중에서 라벨 기능을 사용하면 원하는 글자를 출력할 수 있습니다. import sys from PyQt5.QtWidgets import QApplication, QWidget, QLabel, QVBoxLayout from PyQt5.QtCore import Qt class QLabelApp(QWidget): def __init__(self): super().__init__() self.initUI() def initUI(self): label1 = QLabel("첫 번째 라벨",self) label2 = QLabel("두 번째 라벨", self) print(f'--> Qt.AlignCenter : { Qt.AlignCenter }') print(f'--> Qt.AlignVCenter : {Qt.Ali..