2020-11-20 파이썬

jsbak·2020년 11월 20일
0

PYTHON

목록 보기
6/24

PyQT
anaconda Prompt 실행 - designer 입력 - Qt Designer 창이 열림
확장자명? *.ui

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

#UI파일 연결
#단, UI파일은 Python 코드 파일과 같은 디렉토리에 위치해야한다.
form_class = uic.loadUiType("pushbuttonTest.ui")[0]
#연결할 이름이 들어감

#화면을 띄우는데 사용되는 Class 선언
class WindowClass(QMainWindow, form_class) :
    def __init__(self) :
        super().__init__()
        self.setupUi(self)

        #버튼에 기능을 연결하는 코드
        self.btn_1.clicked.connect(self.button1Function)
        self.btn_2.clicked.connect(self.button2Function)

    #btn_1이 눌리면 작동할 함수
    def button1Function(self) :
        print("btn_1 Clicked")

    #btn_2가 눌리면 작동할 함수
    def button2Function(self) :
        print("btn_2 Clicked")


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

오늘자

상속받는 방법

참고 : https://wikidocs.net/28#_9

상속 받은 부모의 init( ~ )가 현재의 CLASS에 init( ~ )에 있어야한다.

python은 멀티 상속이 된다.

# 파이썬은 다른 만들어진것을 가져다 쓰기 수월하게 되어있다??
class Animal:
    def __init__(self):
        # defalut public 그냥 퍼블릭으로쓴다. 어거지로 private 안씀
        self.age = 0
        #__init__ 생성자
        print("constructor")
    def getOld(self):
        self.age += 1
    
class Protoss:
    def __init__(self):
        self.mindcontrol = 1
    def thought(self):
        self.mindcontrol += 1 

# python은 멀티 상속이 된다.
class Human(Animal, Protoss):
    def __init__(self):
        Animal.__init__(self)
        Protoss.__init__(self)
        # 부모 클래스의 __init__를 호출해야한다.
        self.name = "김철수"
    def changeName(self, name):
       self.name = name 
profile
끄적끄적 쓰는곳

0개의 댓글