PYTHON

PYQT란? PYQT를 이용하여 파이썬 프로그래밍하기

9400 2023. 1. 2. 19:30

PyQt란 ? 

PyQt는 Python + Qt를 합쳐서 지은 이름으로, C++ 기반의 GUI Framework인 Qt를 Python에서 사용할 수 있게 만든 패키지로

즉, 파이썬에서 GUI(Graphical User Interface) 프로그래밍을 할 때 사용하는 대표적인 패키지이다.

 

 

designer 프로그램을 사용하여 

인터페이스를 만들고 

저장후

 

.ui --> pyqt의 화면단

.py --> 파이선으로 프로그래밍 공간으로 사용한다.

 

 

사용예제) 

text바꾸기

 

import sys
from PyQt5.QtWidgets import *
from PyQt5 import uic

form_class = uic.loadUiType("main01.ui")[0]


class WindowClass(QMainWindow, form_class) :
    def __init__(self) :
        super().__init__()
        self.setupUi(self)
        
        self.pb.clicked.connect(self.myclick)
        
    def myclick(self):
        self.lbl.setText("Good Evening");

        
        
if __name__ == "__main__" :
    #QApplication : 프로그램을 실행시켜주는 클래스
    app = QApplication(sys.argv) 
    #WindowClass의 인스턴스 생성
    myWindow = WindowClass() 
    #프로그램 화면을 보여주는 코드
    myWindow.show()
    #프로그램을 이벤트루프로 진입시키는(프로그램을 작동시키는) 코드
    app.exec_()

 

변경 완료