라디오 버튼은 여러 선택 중에서 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..
GUI에는 수많은 버튼이 들어갑니다. 각 버튼마다 표시되는 방법과 역할을 직접 지정할 수 있습니다. import sys from PyQt5.QtWidgets import QApplication, QWidget, QPushButton, QVBoxLayout class QPushButtonApp(QWidget): def __init__(self): super().__init__() self.initUI() def initUI(self): btn1 = QPushButton('버튼1', self) btn2 = QPushButton('버튼2', self) btn3 = QPushButton('버튼3', self) btn1.setCheckable(True) btn1.toggle() btn2.setText('버튼이름'..