ejyoo's 개발 노트

pyQt5. button 클릭 시 label text 변경 본문

BackEnd/Python

pyQt5. button 클릭 시 label text 변경

ejyoovV 2021. 5. 7. 10:52

designer 입력 Qt Designer 실행

디자인 설계

버튼과 라벨 추가

 

 

전체코드 

import sys
from PyQt5.QtWidgets import QApplication, QWidget, QMainWindow
from PyQt5 import uic 

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

class WindowClass(QMainWindow, form_class): 
    def __init__(self): 
        super().__init__() 
        self.setupUi(self)
        
        self.pb.clicked.connect(self.btnClick)

        
    def btnClick(self):
        print("버튼이 클릭되었습니다.")
        self.lbl.setText("GootEvening")
        

if __name__ == "__main__": 
    app = QApplication(sys.argv) 
    myWindow = WindowClass() 
    myWindow.show() 
    app.exec_()

코드 이미지 상세

'BackEnd > Python' 카테고리의 다른 글

HeidiSQL 설치 및 DB 생성  (0) 2021.05.11
MySQL 설치  (0) 2021.05.11
python db 연결 위한 mysql 설치  (0) 2021.05.10
BeautifulSoup 설치  (0) 2021.05.10
파이썬 설치 및 이클립스 설치 후 환경설정  (0) 2021.04.30