Widget 배치 시작 코드

# -*- coding: UTF-8 -*-
import sys
from PyQt5.QtWidgets import *
from PyQt5.QtCore import Qt
from PyQt5 import QtGui
class App(QWidget):
    def __init__(self):
        super(App, self).__init__()
        self.setWindowTitle('Window!!!')
        self.setGeometry(100, 100, 500, 600)
        # move(가로, 세로), resize(가로, 세로)
        self.addTitle()
        self.addInput()
        self.addResult()
        self.addButtons()
    def addTitle(self):
        self.label = QLabel('야구 게임!!!', self)
        self.label.resize(500, 80)
        self.label.setAlignment(Qt.AlignCenter)
        #글자 크기 변경 
        font = QtGui.QFont()
        font.setPointSize(30)
        self.label.setFont(font)
    def addInput(self):
        #입력 : 
        self.input_title = QLabel('입력 : ', self)
        self.input = QLineEdit(self)
    def addResult(self):
        self.result = QTextEdit(self)
    def addButtons(self):
        self.btn_reset = QPushButton(self)
        self.btn_reset.setText('초기화')
        self.btn_confirm = QPushButton(self)
        self.btn_confirm.setText('확인')
if __name__ == '__main__':
    app = QApplication(sys.argv)
    window = App()
    window.show()
    sys.exit(app.exec_())

Last updated