QCheckBox 사용법
·
사소한 아이의 소소한 스킬/PyQT5
import sys from PyQt5.QtWidgets import QApplication, QWidget, QCheckBox, QVBoxLayout from PyQt5.QtCore import Qt class MyApp(QWidget): def __init__(self): super().__init__() self.initUI() def initUI(self): cb = QCheckBox('Show title', self) # Text 설정 cb.setText("SetText") # Text 가져오기 print(cb.text()) # 상태 변경 cb.toggle() # 상태 확인하기 print(cb.isChecked()) # 상태 변경 이벤트 cb.stateChanged.connect(self.cha..
QDialog&QMessageBox 사용법
·
사소한 아이의 소소한 스킬/PyQT5
import sys, os from PyQt5.QtWidgets import * class BaseWindow(QWidget): def __init__(self): super().__init__() self.initUI() def initUI(self): self.lbl = QLabel("EXAMPLE") self.btn_1 = QPushButton("QInputDialog") self.btn_1.clicked.connect(self.Input_showDialog) self.btn_2 = QPushButton("QColorDialog") self.btn_2.clicked.connect(self.Color_showDialog) self.btn_3 = QPushButton("QFontDialog") self..
QSpinBox 사용법
·
사소한 아이의 소소한 스킬/PyQT5
import sys from PyQt5.QtWidgets import QApplication, QWidget, QLabel, QSpinBox, QDoubleSpinBox, QVBoxLayout class MyApp(QWidget): def __init__(self): super().__init__() self.initUI() def initUI(self): self.lbl1 = QLabel('QSpinBox') self.spinbox = QSpinBox() self.spinbox.setMinimum(-10) self.spinbox.setMaximum(30) # self.spinbox.setRange(-10, 30) self.spinbox.setSingleStep(2) self.lbl2 = QLabel('..
QDateTimeEdit 사용법
·
사소한 아이의 소소한 스킬/PyQT5
import sys from PyQT5.QtWidgets import QApplication, QWidget, QLabel, QDateTimeEdit, QVBoxLayout from PyQT5.QtCore import QDateTime class MyApp(QWidget): def __init__(self): super().__init__() self.initUI() def initUI(self): self.lbl = QLabel('QTimeEdit') self.lbl2 = QLabel('QTimeEdit') self.datetimeedit = QDateTimeEdit(self) self.datetimeedit.setDateTime(QDateTime.currentDateTime()) self.dateti..
QComboBox 사용법
·
사소한 아이의 소소한 스킬/PyQT5
import sys from PyQt5.QtWidgets import QApplication, QWidget, QComboBox, QLabel, QVBoxLayout from PyQt5.QtCore import Qt class MyApp(QWidget): def __init__(self): super().__init__() self.initUI() def initUI(self): # 라벨 생성 self.l = QLabel('Option1', self) # 콤보 박스 생성 self.cb = QComboBox(self) # 콤보 아이템 추가 self.cb.addItem('Option1') self.cb.addItem('Option2') self.cb.addItem('Option3') self.cb.addIt..
QThread & Custom Signal 예시
·
사소한 아이의 소소한 스킬/PyQT5
이번에는 QThread 사용법이다. 다른 언어에서도 다 사용하듯 1개의 쓰레드로 모든 기능을 처리한다는 것은 불가능에 가깝다. 특히나 UI가 있다면 더더욱.. (프리징현상 어쩔꺼야...) 그리하여 이번엔 QTthread이다. 정말 간단한 예제이며 QT에서는 QThread말고 QRunnable 등 다른 여러가지 Thread 사용법들이 있다.. 차차 하나씩 알아보고 이번엔 간단한 QThread만 알아보도록 하자 from PySide6.QtCore import * from PySide6.QtWidgets import * import sys import time # 내 돈 balance = 100 # 돈을 1씩 계속 없애는 QThread class Balance_decrease(QThread): # Custom..
QRadioButton 사용법
·
사소한 아이의 소소한 스킬/PyQT5
import sys from PyQt5.QtWidgets import QApplication, QWidget, QCheckBox, QRadioButton, QVBoxLayout from PyQt5.QtCore import Qt class MyApp(QWidget): def __init__(self): super().__init__() self.initUI() def initUI(self): rbtn1 = QRadioButton('First Button', self) # 라디오 버튼 텍스트 변경 rbtn1.setText('Change Text') # 라디오 버튼 텍스트 가져오기 print(rbtn1.text()) # 라디오 버튼 체크상태 확인 print(rbtn1.isChecked()) # 라디오 버튼 체..
Window, Label, Button 사용법
·
사소한 아이의 소소한 스킬/PyQT5
개인적으로는 라이센스때문에 PySide6를 사용하나.... PyQT5와 별 차이가 없기에.. PyQT5 관련된 자료를 올려보려고 한다.. 일단 처음엔 MainWindow와 간단한 라벨, 버튼 띄우기다 import sys from PyQt5.QtWidgets import QApplication, QWidget, QPushButton, QVBoxLayout class MyApp(QWidget): def __init__(self): super().__init__() self.initUI() def initUI(self): btn1 = QPushButton('&Button1', self) btn1.setCheckable(True) btn1.toggle() btn2 = QPushButton(self) btn2.s..