본문 바로가기
반응형

PyQt59

Day 5. PyQt5 (QListWidget, QLineEdit) 책에서는 QListWidget을 QComboBox와 비교하고 있다. 저자의 설명은 QComboBox와 유사한 위젯이며 차이가 있다면 스크롤이 가능하다는 점과 다중선택을 예로 들고있다. 뭐든지 연관성을 갖고 접근하면 재미있기 마련인데 저자의 해당 부분 설명은 나름 인상깊었다. QComboBox에서도 선택된 아이템이 변경되면 발생하는 signal과 유사한 signal이 발생된다. item이 바뀌면 currentItemChangedf라는 signal을 통해 QListItem을 보낸다. 또 현재 아이템의 text과 바뀌면 currentTextChanged signal을 통해서 현재의 text 값을 보낸다. 코드를 봐보도로 하자. import sys from PyQt5.QtWidgets import QApplic.. 2021. 3. 10.
Day 4. PyQt5 (QCheckBox, QComboBox) QCheckBox는 이름에서도 알 수 있듯이 체크가 가능한 박스가 있는 위젯을 말한다. 가장 간단한 예로 체크가 되어있는 것과 체크가 되어있지 않은 것 이분법적으로 접근할 경우 사용가능한 위젯이다. import sys from PyQt5.QtCore import Qt from PyQt5.QtWidgets import QApplication, QMainWindow, QCheckBox class MainWindow(QMainWindow): def __init__(self): super().__init__() self.setWindowTitle("My App") widget = QCheckBox("This is a checkbox") widget.setCheckState(Qt.Checked) #widget.s.. 2021. 3. 5.
Day 3. PyQt5 (QLabel) import sys from PyQt5.QtCore import Qt from PyQt5.QtWidgets import QApplication, QMainWindow, QLabel, QLineEdit, QVBoxLayout, QWidget class MainWindow(QMainWindow): def __init__(self): super().__init__() self.setWindowTitle("My App") widget = QLabel("Hello") font = widget.font() font.setPointSize(30) widget.setFont(font) widget.setAlignment(Qt.AlignHCenter | Qt.AlignVCenter) self.setCentralWidge.. 2021. 2. 9.
Day 2. PyQt5 (Signal and Slot) 책에서는 Signal과 Slot에 대해 간략하게 설명하고 있다. 원문을 그대로 옮기면 아래와 같다. Signals are notifications emitted by widgets when something happens. Slots is the name Qt uses for the receivers of signals. 즉, signal이라고 하면 키보드를 누르거나 마우스를 클릭하거나 input box에 어떤 내용이 입력되거나 하는 등의 액션을 생각하면 쉽다. 그리고 slot은 앞서 설명된 signal을 수신하여 처리하는 method로 생각하면 쉽다. import sys from PyQt5.QtCore import Qt from PyQt5.QtWidgets import QApplication, QMai.. 2021. 2. 9.
반응형